mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 09:01:14 +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
|
|
@ -5,6 +5,7 @@
|
|||
### Added
|
||||
|
||||
- Added "none" option to `doubleEscapeAction` setting to disable double-escape behavior entirely ([#973](https://github.com/badlogic/pi-mono/issues/973) by [@juanibiapina](https://github.com/juanibiapina))
|
||||
- Added OSC 52 clipboard support for SSH/mosh sessions. `/copy` now works over remote connections. ([#1069](https://github.com/badlogic/pi-mono/issues/1069) by [@gturkoglu](https://github.com/gturkoglu))
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
|||
|
|
@ -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