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
feat(settings): explicit dictation-overlap gates in the recorder commit path
enes2a67c8543fcd
diff --git a/src/renderer/components/settings/sections/ShortcutsSection.test.tsx b/src/renderer/components/settings/sections/ShortcutsSection.test.tsxindex df0aa6160..b787a7bf9 100644--- a/src/renderer/components/settings/sections/ShortcutsSection.test.tsx+++ b/src/renderer/components/settings/sections/ShortcutsSection.test.tsx@@ -291,4 +291,34 @@ describe('commitCandidate', () => {expect(commitCandidate('canvas.fitAll', 'Cmd+Alt+F', 'add')).toEqual({ ok: true })expect(kb()['canvas.fitAll']).toEqual(['Cmd+Alt+G', 'Cmd+Alt+F'])})++ // Dictation is its own conflict bucket (Task 1), so NEITHER of the three gates above can see an+ // overlap with it — the detector is silent by design and the load path deliberately permits one.+ // These two gates are what makes `conflictBucket`'s "the Settings UI REFUSES to create one" true.+ it("refuses binding another command onto Dictate's keyed chord, naming Dictate", () => {+ setKb({ 'speech.dictation': ['Cmd+Alt+D'] })+ const r = commitCandidate('canvas.fitAll', 'Cmd+Alt+D', 'replace')+ expect(r.ok).toBe(false)+ if (!r.ok) expect(r.error).toContain('Dictate')+ expect(kb()['canvas.fitAll']).toBeUndefined()+ })++ it('refuses a keyed Dictate chord that another command already holds', () => {+ const r = commitCandidate('speech.dictation', 'Cmd+K', 'replace')+ expect(r.ok).toBe(false)+ if (!r.ok) expect(r.error).toContain('Command palette')+ expect(kb()['speech.dictation']).toBeUndefined()+ })++ // Both gates are keyed-only for free: a hold chord's identity ends in `:(hold)`, which no keyed+ // identity can equal — so neither direction needs an explicit hold guard.+ it('a HOLD dictation chord never trips the overlap gates', () => {+ const r = commitCandidate('speech.dictation', 'Cmd+Ctrl', 'replace')+ expect(r.ok).toBe(true)+ })++ it('the default hold chord does not block other commands (keyed-only gate)', () => {+ const r = commitCandidate('canvas.fitAll', 'Cmd+Alt+F9', 'replace')+ expect(r.ok).toBe(true)+ })})diff --git a/src/renderer/components/settings/sections/ShortcutsSection.tsx b/src/renderer/components/settings/sections/ShortcutsSection.tsxindex fae14991a..e0760b3ce 100644--- a/src/renderer/components/settings/sections/ShortcutsSection.tsx+++ b/src/renderer/components/settings/sections/ShortcutsSection.tsx@@ -6,11 +6,14 @@* Design D3 is "same detector, different surfacing": `sanitizeKeybindingOverrides` applies what* survives on LOAD, while this section refuses a bad candidate BEFORE anything is written, so the* user learns which chord was refused and why instead of watching a saved shortcut disappear on- * the next launch. Three checks, in this order, and the order is the whole dedupe:+ * the next launch. The checks run in this order, and the order is the whole dedupe:* 1. `normalizeBindingForCommand` — already inside `ShortcutRecorderButton`, so an invalid chord* never reaches `onCommit` (its own hint is shown in the recorder button itself).* 2. `findKeybindingConflicts` over the candidate map — a same-bucket collision.* 3. `findMainInterceptShadowing` — a CROSS-bucket hit the conflict check cannot see.+ * 4. REVERSE shadowing — the same collision seen from the non-intercepted side.+ * 5. The two DICTATION overlap gates — the one overlap `conflictBucket` deliberately does not+ * report, refused here in both directions (see the block itself for why).* (2) returns early, so a candidate that trips both detectors (a main-intercepted command taking* a chord another GLOBAL command already holds — `node.close` ← `Cmd+K`) produces exactly ONE* message. The shadow message is reserved for what only it can see: `node.close` ← `Cmd+F`, where@@ -58,7 +61,7 @@ const NOTES: Partial<Record<CommandId, string>> = {// Reused verbatim from the old SpeechSection row: the mode is derived from the chord's SHAPE,// which is not guessable from a chip.'speech.dictation':- 'With a key = toggle (press to start, press again to stop and insert); modifiers only = hold to talk (hold to record, release to stop and insert). The Dock mic uses the same shortcut.',+ 'With a key = toggle (press to start, press again to stop and insert); modifiers only = hold to talk (hold to record, release to stop and insert). The Dock mic uses the same shortcut. A keyed dictation chord is claimed before any other shortcut while the canvas has focus.','canvas.deleteSelection': 'Bare keys are allowed here; the typing guard keeps Backspace safe.','terminal.copySelection': 'Applies to a selection xterm owns — a tmux drag copies through OSC 52.'}@@ -169,6 +172,44 @@ export function commitCandidate(}}+ // DICTATION OVERLAP, both directions. `speech.dictation` is its own conflict bucket (see+ // `conflictBucket` in @shared/keybindings), so gate (2) above is silent about it BY DESIGN —+ // dictation never competes at dispatch, it PRE-EMPTS: the resolver skips it and its own keyed+ // listener claims the chord first while the canvas has focus. That is precedence, not ambiguity,+ // which is why the LOAD path permits an overlap (legacy files contain them, and dropping a user's+ // chord is the failure that bucket closes) while a chord a user picks HERE is refused instead:+ // an interactive pick deserves to be told about the precedence, not to discover it later.+ //+ // Both gates are keyed-only WITHOUT an explicit hold guard: `bindingIdentity` renders a+ // modifier-only chord as `…:(hold)`, which no keyed identity can ever equal — so the default+ // `Cmd+Alt` hold chord blocks nothing, and a hold candidate trips nothing.+ const dictationId: CommandId = 'speech.dictation'+ const dictationTitle = COMMANDS_BY_ID.get(dictationId)?.title ?? dictationId+ const identity = bindingIdentity(combo, isMac)+ if (id !== dictationId) {+ // "rarely", not "never": dictation's keyed listener only claims the chord where it listens.+ // In terminal or typing focus the gesture is not offered and this command CAN still fire —+ // the message must not overclaim a chord that is merely usually lost.+ const taken = effectiveBindings(dictationId).some((b) => bindingIdentity(b, isMac) === identity)+ if (taken) {+ const own = COMMANDS_BY_ID.get(id)?.title ?? id+ return {+ ok: false,+ error: `${chord} is used by ${dictationTitle}, which claims it first; it would rarely reach ${own}.`+ }+ }+ } else {+ for (const def of COMMAND_DEFINITIONS) {+ if (def.id === dictationId) continue+ const hit = effectiveBindings(def.id).some((b) => bindingIdentity(b, isMac) === identity)+ if (!hit) continue+ return {+ ok: false,+ error: `${chord} is already used by ${def.title}; ${dictationTitle} would claim it first and hide it.`+ }+ }+ }+setKeybindingOverride(id, nextList)return { ok: true }}diff --git a/src/shared/keybindings.test.ts b/src/shared/keybindings.test.tsindex b75c6c017..dd5185938 100644--- a/src/shared/keybindings.test.ts+++ b/src/shared/keybindings.test.ts@@ -500,6 +500,8 @@ describe('dictation conflict bucket', () => {})expect(r.warnings).toEqual([])})+ // Dictation is now OUTSIDE `includeDefaults`' reach: a future default colliding with its+ // `Cmd+Alt` would not be caught here.it('the shipped defaults stay conflict-free under full scrutiny (unchanged invariant)', () => {expect(findKeybindingConflicts({}, true, { includeDefaults: true })).toEqual([])expect(findKeybindingConflicts({}, false, { includeDefaults: true })).toEqual([])diff --git a/src/shared/keybindings.ts b/src/shared/keybindings.tsindex 15cd17ca2..3522a896a 100644--- a/src/shared/keybindings.ts+++ b/src/shared/keybindings.ts@@ -239,8 +239,13 @@ export function bindingIdentity(binding: string, isMac: boolean): string {** **Overlap policy is deliberately asymmetric.** The LOAD path PERMITS a shared chord — legacy* settings.json files already contain them and silently dropping a user's chord is the failure- * this closes. The Settings UI REFUSES to create one, because a user picking a chord interactively- * should be told about the precedence rather than discover it later. */+ * this closes. The Settings UI REFUSES to create one (`commitCandidate`'s two dictation gates),+ * because a user picking a chord interactively should be told about the precedence rather than+ * discover it later. One case the permissive load path cannot rescue: a keyed dictation override+ * on a MAIN-INTERCEPTED chord (⌘W / ⌘M) wins NOWHERE — main steals those in `before-input-event`+ * before the page exists, so such a hand-edit survives sanitization as a permanently dead chord.+ * The UI can never create it (`commitCandidate`'s reverse-shadow gate refuses it one step earlier+ * than the dictation gates). */export function conflictBucket(def: Pick<CommandDefinition, 'id' | 'scope'>): 'global' | 'terminal' | 'scm' | 'dictation' {