Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(terminal): copy shortcut preventDefault, non-Latin layouts, live scrollback
enes712805f9bd23
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 2d88c20f1..e2fe36068 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -182,6 +182,7 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasNconst fontSize = useSettings((s) => s.settings.fontSize)const fontFamily = useSettings((s) => s.settings.fontFamily)const cursorBlink = useSettings((s) => s.settings.cursorBlink)+ const tmuxScrollback = useSettings((s) => s.settings.tmuxScrollback)const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)const accountChip = accountChipLabel(data.accountId, claudeAccounts)const bodyRef = useRef<HTMLDivElement>(null)@@ -399,9 +400,13 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN// Cmd+C (mac) / Ctrl+Shift+C (Linux, Windows) copy the terminal selection — xterm renders to a// canvas, so the DOM-selection copy used elsewhere can't see it. Plain Ctrl+C is left alone so// it still sends SIGINT.+ // Returning false only tells xterm to skip the key — xterm never gets to its own+ // preventDefault(), so the browser default would still run: in the Server Edition (and in+ // `npm run dev` with DevTools attached) Ctrl+Shift+C is Chromium's inspect-element picker.term.attachCustomKeyEventHandler((e) => {if (!term.hasSelection() || !isCopyShortcut(e)) return truewindow.nodeTerminal.clipboard.writeText(term.getSelection())+ e.preventDefault()return false})@@ -642,19 +647,21 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN// eslint-disable-next-line react-hooks/exhaustive-deps}, [data.respawnNonce])- // Live-apply font/cursor settings to the running terminal.+ // Live-apply font/cursor/scrollback settings to the running terminal, so a Settings change+ // reaches the terminals already on the canvas instead of only the next fresh one.useEffect(() => {const term = termRef.currentif (!term) returnterm.options.fontSize = fontSizeterm.options.fontFamily = fontFamilyterm.options.cursorBlink = cursorBlink+ term.options.scrollback = xtermScrollback(tmuxScrollback)try {fitRef.current?.fit()} catch {// ignore}- }, [fontSize, fontFamily, cursorBlink])+ }, [fontSize, fontFamily, cursorBlink, tmuxScrollback])const toggleCollapse = () =>setNodes((ns) =>diff --git a/src/renderer/terminal/terminal-config.test.ts b/src/renderer/terminal/terminal-config.test.tsindex 4aa6f857f..2e819833a 100644--- a/src/renderer/terminal/terminal-config.test.ts+++ b/src/renderer/terminal/terminal-config.test.ts@@ -4,6 +4,7 @@ import { xtermScrollback, XTERM_SCROLLBACK_MAX, isCopyShortcut, type CopyShortcuconst ev = (p: Partial<CopyShortcutEvent>): CopyShortcutEvent => ({type: 'keydown',key: 'c',+ code: 'KeyC',metaKey: false,ctrlKey: false,altKey: false,@@ -36,7 +37,7 @@ describe('isCopyShortcut', () => {})it('ignores other keys, keyups and extra modifiers', () => {- expect(isCopyShortcut(ev({ metaKey: true, key: 'v' }))).toBe(false)+ expect(isCopyShortcut(ev({ metaKey: true, key: 'v', code: 'KeyV' }))).toBe(false)expect(isCopyShortcut(ev({ metaKey: true, type: 'keyup' }))).toBe(false)expect(isCopyShortcut(ev({ metaKey: true, altKey: true }))).toBe(false)expect(isCopyShortcut(ev({ ctrlKey: true, shiftKey: true, metaKey: true }))).toBe(false)@@ -45,4 +46,26 @@ describe('isCopyShortcut', () => {it('accepts an uppercase key (Shift makes Ctrl+Shift+C report "C")', () => {expect(isCopyShortcut(ev({ ctrlKey: true, shiftKey: true, key: 'C' }))).toBe(true)})++ it('copies on a non-Latin layout, where e.key is not "c" (physical KeyC)', () => {+ // Cyrillic layout: the C key reports 'с' (U+0441), Greek reports 'ψ'.+ expect(isCopyShortcut(ev({ metaKey: true, key: 'с', code: 'KeyC' }))).toBe(true)+ expect(isCopyShortcut(ev({ ctrlKey: true, shiftKey: true, key: 'с', code: 'KeyC' }))).toBe(true)+ expect(isCopyShortcut(ev({ ctrlKey: true, shiftKey: true, key: 'ψ', code: 'KeyC' }))).toBe(true)+ // Plain Ctrl on the same layout still reaches the pty as SIGINT.+ expect(isCopyShortcut(ev({ ctrlKey: true, key: 'с', code: 'KeyC' }))).toBe(false)+ })++ it('does not copy when neither the printed nor the physical key is C', () => {+ expect(isCopyShortcut(ev({ metaKey: true, key: 'ц', code: 'KeyW' }))).toBe(false)+ })++ it('copies on Cmd+Shift+C too (no competing binding; asserted, not accidental)', () => {+ expect(isCopyShortcut(ev({ metaKey: true, shiftKey: true }))).toBe(true)+ })++ it('leaves AltGr combos alone (ctrl+alt+shift+C must not copy)', () => {+ expect(isCopyShortcut(ev({ ctrlKey: true, altKey: true, shiftKey: true }))).toBe(false)+ expect(isCopyShortcut(ev({ ctrlKey: true, altKey: true }))).toBe(false)+ })})diff --git a/src/renderer/terminal/terminal-config.ts b/src/renderer/terminal/terminal-config.tsindex c8726e79a..a1ea5b392 100644--- a/src/renderer/terminal/terminal-config.ts+++ b/src/renderer/terminal/terminal-config.ts@@ -19,6 +19,7 @@ export function xtermScrollback(tmuxScrollback: number): number {export interface CopyShortcutEvent {type: stringkey: string+ code: stringmetaKey: booleanctrlKey: booleanaltKey: boolean@@ -29,11 +30,19 @@ export interface CopyShortcutEvent {* True for the keydowns that should copy the terminal selection: Cmd+C (mac) and* Ctrl+Shift+C (Linux, Windows). Plain Ctrl+C is deliberately NOT one of them — it must keep* reaching the pty as SIGINT.+ *+ * The key is matched on the printed letter (`e.key`, so Dvorak/AZERTY follow the letter the user+ * actually presses) OR on the physical `KeyC` position (`e.code`) — on a non-Latin layout+ * (Cyrillic 'с', Greek 'ψ') `e.key` is never 'c', and without the fallback an xterm selection+ * would have no keyboard copy at all (the OS Edit menu only copies the DOM selection, not+ * xterm's canvas one).+ *+ * Cmd+Shift+C is deliberately allowed as well: nothing else binds it and it is a harmless+ * near-miss of Cmd+C. AltGr combos (which report ctrl+alt) never copy.*/export function isCopyShortcut(e: CopyShortcutEvent): boolean {if (e.type !== 'keydown') return false- const key = e.key.toLowerCase()- if (key !== 'c') return false+ if (e.key.toLowerCase() !== 'c' && e.code !== 'KeyC') return falseconst cmdC = e.metaKey && !e.ctrlKey && !e.altKeyconst ctrlShiftC = e.ctrlKey && e.shiftKey && !e.metaKey && !e.altKeyreturn cmdC || ctrlShiftC