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(keybindings): key conflict identities off canonical key tokens
enes1b673eb9263f
diff --git a/src/shared/keybindings.test.ts b/src/shared/keybindings.test.tsindex c950f44a6..954efe3d1 100644--- a/src/shared/keybindings.test.ts+++ b/src/shared/keybindings.test.ts@@ -118,6 +118,14 @@ describe('bindingIdentity', () => {it('keeps them distinct on mac', () => {expect(bindingIdentity('Cmd+K', true)).not.toBe(bindingIdentity('Ctrl+K', true))})+ it('collapses alias key spellings onto one identity', () => {+ expect(bindingIdentity('Cmd+Esc', true)).toBe(bindingIdentity('Cmd+Escape', true))+ expect(bindingIdentity('Cmd+Return', true)).toBe(bindingIdentity('Cmd+Enter', true))+ })+ it('still separates a modifier from a bare key, and a hold chord from a keyed one', () => {+ expect(bindingIdentity('Cmd+Delete', true)).not.toBe(bindingIdentity('Delete', true))+ expect(bindingIdentity('Cmd+Alt', true)).not.toBe(bindingIdentity('Cmd+Alt+D', true))+ })})describe('findKeybindingConflicts', () => {@@ -135,6 +143,16 @@ describe('findKeybindingConflicts', () => {{ binding: 'Cmd+K', commandIds: ['app.commandPalette', 'canvas.fitAll'] }])})+ it('reports the canonical spelling, not the override as written', () => {+ expect(findKeybindingConflicts({ 'canvas.fitAll': ['cmd+k'] }, true)).toEqual([+ { binding: 'Cmd+K', commandIds: ['app.commandPalette', 'canvas.fitAll'] }+ ])+ // canvas.fitAll precedes node.newTerminal in the registry, so the override is the+ // entry-creating spelling here — the assertion above cannot see the canonicalization.+ expect(findKeybindingConflicts({ 'canvas.fitAll': ['cmd+t'] }, true)).toEqual([+ { binding: 'Cmd+T', commandIds: ['canvas.fitAll', 'node.newTerminal'] }+ ])+ })it('flags a cross-spelling collision on non-mac (Ctrl+K vs Cmd+K)', () => {const conflicts = findKeybindingConflicts({ 'canvas.fitAll': ['Ctrl+K'] }, false)expect(conflicts.map((c) => c.commandIds)).toEqual([['app.commandPalette', 'canvas.fitAll']])diff --git a/src/shared/keybindings.ts b/src/shared/keybindings.tsindex 28b24cea8..dc2ade2d5 100644--- a/src/shared/keybindings.ts+++ b/src/shared/keybindings.ts@@ -189,7 +189,10 @@ export function getEffectiveBindings(}/** Platform-resolved identity: two spellings that press the same physical modifiers + key get- * the same identity (`Cmd+K` === `Ctrl+K` on non-mac, but not on mac). */+ * the same identity (`Cmd+K` === `Ctrl+K` on non-mac, but not on mac). The key segment runs+ * through `serializeShortcut` so ALIAS spellings collapse too (`Cmd+Esc` === `Cmd+Escape`,+ * `Cmd+Return` === `Cmd+Enter`) — without that a hand-edited `Cmd+Return` override would sit+ * invisibly on top of the `Cmd+Enter` default. */export function bindingIdentity(binding: string, isMac: boolean): string {const p = parseShortcut(binding)const m = resolvedModifiers(p, isMac)@@ -199,7 +202,9 @@ export function bindingIdentity(binding: string, isMac: boolean): string {m.alt ? 'A' : '',m.shift ? 'S' : '',':',- p.key ?? '(hold)'+ p.key === null+ ? '(hold)'+ : serializeShortcut({ cmd: false, ctrl: false, alt: false, shift: false, key: p.key })].join('')}@@ -230,7 +235,11 @@ export function findKeybindingConflicts(for (const def of COMMAND_DEFINITIONS) {for (const binding of getEffectiveBindings(def.id, overrides, isMac)) {const key = `${conflictBucket(def.scope)} ${bindingIdentity(binding, isMac)}`- const entry = byBucketAndIdentity.get(key) ?? { binding, ids: new Set<CommandId>() }+ const entry = byBucketAndIdentity.get(key) ?? {+ // Canonicalized, so a hand-edited `cmd+k` override is reported as `Cmd+K`.+ binding: serializeShortcut(parseShortcut(binding)),+ ids: new Set<CommandId>()+ }entry.ids.add(def.id)byBucketAndIdentity.set(key, entry)}