fix(terminal): support browser clipboard shortcuts

Copy selected terminal output with Ctrl/Cmd+C without sending an interrupt, and route browser paste consistently through the terminal transport.
This commit is contained in:
2026-07-22 12:52:19 +02:00
parent c80dbf9737
commit d14cdc1151
4 changed files with 87 additions and 1 deletions
@@ -4,6 +4,7 @@ import {
getTerminalScrollbackLimit,
isCurrentWebSocket,
shouldRetryWebSocketClose,
shouldCopyTerminalSelection,
} from "./terminal.tsx";
describe("getTerminalScrollbackLimit", () => {
@@ -30,3 +31,29 @@ describe("getTerminalScrollbackLimit", () => {
);
});
});
describe("shouldCopyTerminalSelection", () => {
it("copies a selected terminal region with Ctrl+C or Cmd+C", () => {
expect(
shouldCopyTerminalSelection(
{ ctrlKey: true, metaKey: false, key: "c" },
true,
),
).toBe(true);
expect(
shouldCopyTerminalSelection(
{ ctrlKey: false, metaKey: true, key: "C" },
true,
),
).toBe(true);
});
it("keeps Ctrl+C as a terminal interrupt without a selection", () => {
expect(
shouldCopyTerminalSelection(
{ ctrlKey: true, metaKey: false, key: "c" },
false,
),
).toBe(false);
});
});