fix(coding-agent): skip X11-only native addon for /copy on Linux
The @mariozechner/clipboard native addon uses clipboard-rs, which is X11-only and does not retain selection ownership after set_text resolves. On Wayland-only compositors (Hyprland, Niri, ...) /copy reported success without populating the clipboard. Skip the native addon on Linux and let wl-copy/xclip/xsel handle text writes; they properly daemonize. closes #4177
This commit is contained in:
@@ -35,11 +35,20 @@ function emitOsc52(text: string): boolean {
|
||||
export async function copyToClipboard(text: string): Promise<void> {
|
||||
let copied = false;
|
||||
|
||||
const p = platform();
|
||||
|
||||
// Prefer direct clipboard writes. Emitting OSC 52 first can make terminals
|
||||
// write the same native clipboard concurrently with the addon, and very large
|
||||
// OSC 52 payloads can desynchronize terminal rendering.
|
||||
//
|
||||
// On Linux, skip the native addon. The underlying `clipboard-rs` crate is
|
||||
// X11-only and does not retain selection ownership after `set_text`
|
||||
// resolves, so on Wayland-only compositors (Hyprland, Niri, ...) and even
|
||||
// some X11 sessions the call resolves successfully without populating the
|
||||
// clipboard. The platform tools below (wl-copy, xclip, xsel) properly
|
||||
// daemonize and keep ownership.
|
||||
try {
|
||||
if (clipboard) {
|
||||
if (clipboard && p !== "linux") {
|
||||
await clipboard.setText(text);
|
||||
copied = true;
|
||||
}
|
||||
@@ -52,7 +61,6 @@ export async function copyToClipboard(text: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
const p = platform();
|
||||
const options: NativeClipboardExecOptions = { input: text, timeout: 5000, stdio: ["pipe", "ignore", "ignore"] };
|
||||
|
||||
if (!copied) {
|
||||
|
||||
Reference in New Issue
Block a user