Centralize TUI clipboard decisions in terminal capabilities (#63797)

## Why

Terminal checks for clipboard behavior are spread across the clipboard
worker, local settings, and right-click paste handling.

## What changed

Use `terminal_capabilities` to determine whether the terminal forwards
copy shortcuts or handles paste itself, whether X11 primary selection is
available, and how to send OSC 52 through tmux or GNU Screen. Have TUI
callers use the same SSH and WSL session checks.

Keep the automatic copy-on-select decision in settings and base it on
whether the terminal forwards the copy shortcut. Route tmux clipboard
copies through the client buffer with OSC 52 as a fallback.

GitOrigin-RevId: 623599783b70d66a06c52458fc82305a422cf507
This commit is contained in:
Eric Traut
2026-11-25 01:42:33 +00:00
committed by copyberry
parent 8603da0718
commit bede3b5df8
25 changed files with 194 additions and 159 deletions
+3 -3
View File
@@ -7,8 +7,8 @@ use std::time::Instant;
/// Constructed on the clipboard worker, never on the UI thread.
pub(crate) fn reader() -> impl FnMut(Instant) -> Result<String, String> {
#[cfg(target_os = "linux")]
let windows =
(super::is_probably_wsl() && !crate::clipboard_copy::is_ssh_session()).then(|| {
let windows = (super::is_probably_wsl() && !crate::terminal_capabilities::is_ssh_session())
.then(|| {
use std::sync::mpsc;
let (requests, reads) = mpsc::sync_channel::<(
@@ -54,7 +54,7 @@ pub(crate) fn reader() -> impl FnMut(Instant) -> Result<String, String> {
.map_err(|_| "could not start clipboard reader".to_string())
});
move |deadline| {
if crate::clipboard_copy::is_ssh_session() {
if crate::terminal_capabilities::is_ssh_session() {
return Err("clipboard text is unavailable over SSH".into());
}
#[cfg(target_os = "linux")]