mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 03:00:38 +00:00
feat(coding-agent): add OSC 52 clipboard support for SSH/mosh sessions
Fixes #1069
This commit is contained in:
parent
20ca6836b0
commit
9ee58fdea9
2 changed files with 8 additions and 7 deletions
|
|
@ -3,6 +3,11 @@ import { platform } from "os";
|
|||
import { isWaylandSession } from "./clipboard-image.js";
|
||||
|
||||
export function copyToClipboard(text: string): void {
|
||||
// Always emit OSC 52 - works over SSH/mosh, harmless locally
|
||||
const encoded = Buffer.from(text).toString("base64");
|
||||
process.stdout.write(`\x1b]52;c;${encoded}\x07`);
|
||||
|
||||
// Also try native tools (best effort for local sessions)
|
||||
const p = platform();
|
||||
const options = { input: text, timeout: 5000 };
|
||||
|
||||
|
|
@ -42,12 +47,7 @@ export function copyToClipboard(text: string): void {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
if (p === "linux") {
|
||||
const tools = isWaylandSession() ? "wl-copy, xclip, or xsel" : "xclip or xsel";
|
||||
throw new Error(`Failed to copy to clipboard. Install ${tools}: ${msg}`);
|
||||
}
|
||||
throw new Error(`Failed to copy to clipboard: ${msg}`);
|
||||
} catch {
|
||||
// Ignore - OSC 52 already emitted as fallback
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue