From f0c272e0b1f00de51b8864630c512e2080e94405 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Fri, 4 Sep 2026 14:33:24 +0100 Subject: [PATCH] feat(maestro): copy terminal selection to clipboard xterm.js has no built-in copy-on-select; mirror onSelectionChange to navigator.clipboard. Co-Authored-By: Claude Sonnet 5 --- web/src/attach.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/src/attach.ts b/web/src/attach.ts index 02c3e5e..948d633 100644 --- a/web/src/attach.ts +++ b/web/src/attach.ts @@ -450,6 +450,12 @@ export function createAttachConnection( const resizeDisp = term.onResize(({ cols, rows }) => { sendControl({ type: "Resize", cols, rows }); }); + // xterm has no built-in copy-on-select; mirror the selection to the + // clipboard ourselves (best-effort — insecure contexts lack the API). + const selectionDisp = term.onSelectionChange(() => { + const text = term.getSelection(); + if (text) void navigator.clipboard?.writeText(text).catch(() => {}); + }); window.addEventListener("resize", onResize); const visual = window.visualViewport ?? null; @@ -505,6 +511,7 @@ export function createAttachConnection( visual?.removeEventListener("resize", onResize); dataDisp.dispose(); resizeDisp.dispose(); + selectionDisp.dispose(); releaseWebgl(); try { ws.close();