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();