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(keybindings): dictation gets its own conflict bucket
enes72cf18429c68
diff --git a/src/core/settings-store.test.ts b/src/core/settings-store.test.tsindex 12de84691..1c3ad2f93 100644--- a/src/core/settings-store.test.ts+++ b/src/core/settings-store.test.ts@@ -3,6 +3,7 @@ import { mkdtempSync, promises as fs, rmSync, writeFileSync } from 'fs'import { tmpdir } from 'os'import path from 'path'import { IPC } from '../shared/ipc'+import { sanitizeKeybindingOverrides } from '../shared/keybindings'import { initPlatform, resetPlatformForTests } from './platform'import { fakePlatform } from './platform-fake'import { SettingsStore } from './settings-store'@@ -200,6 +201,16 @@ describe('SettingsStore nested-default merge', () => {const twice = loadWith({ ...once, keybindings: { 'speech.dictation': ['Cmd+Alt+K'] } })expect(twice.keybindings?.['speech.dictation']).toEqual(['Cmd+Alt+K'])})++ it('a legacy chord colliding with another command now survives load end-to-end', () => {+ // The PR3-era hole, measured then: Cmd+K was seeded and then stripped by the sanitizer.+ const s = loadWith({ speech: { engine: 'whisper', model: '', language: 'auto', shortcut: 'Cmd+K' } })+ expect(s.keybindings?.['speech.dictation']).toEqual(['Cmd+K'])+ // The read path is the renderer's sanitizer; assert its verdict here too so the+ // end-to-end claim is one test, not an inference across two files.+ expect(sanitizeKeybindingOverrides(s.keybindings, true).overrides['speech.dictation'])+ .toEqual(['Cmd+K'])+ })})})diff --git a/src/core/settings-store.ts b/src/core/settings-store.tsindex 86135243c..80baa62fc 100644--- a/src/core/settings-store.ts+++ b/src/core/settings-store.ts@@ -26,12 +26,15 @@ function mergeSettings(saved: Partial<Settings> | null | undefined): Settings {// write path keeps it in sync so an older build still finds the user's chord).// A shortcut EQUAL to the default seeds nothing: the override would only restate what the// registry already says, and would then pin that chord against any future default change.- // **Seeding here is not the same as surviving.** The value written below is a plain override,- // so the READ path's sanitizer (`sanitizeKeybindingOverrides`) can still STRIP it: if the- // legacy chord collides with another command's effective binding in the same conflict bucket,- // every OVERRIDDEN participant of that conflict is deleted — the seed goes, dictation silently- // falls back to the registry default chord, and the user's own colliding override is dropped- // with it. The only signal is a console warning; nothing surfaces in the UI.+ // **The seeded value survives the read path.** `speech.dictation` has its OWN conflict bucket+ // (`conflictBucket` in shared/keybindings.ts), so it can never be a participant in a+ // cross-command collision, and the READ path's sanitizer (`sanitizeKeybindingOverrides`) has+ // nothing to strip — neither the seed nor the user's own override on the same chord. (It used+ // not to: both were deleted on load, and dictation silently fell back to the registry default.)+ // What a shared chord costs is PRECEDENCE, not the binding: dictation's own keyed listener+ // claims it first in plain app focus, and the other command still gets it everywhere dictation+ // does not listen — terminal focus, say. That is exactly the pre-migration behavior of a legacy+ // `speech.shortcut` that happened to match an app chord, which is what this seed must preserve.if (merged.speech.shortcut !== DEFAULT_SETTINGS.speech.shortcut &&!(merged.keybindings && "speech.dictation" in merged.keybindings)diff --git a/src/shared/keybindings.test.ts b/src/shared/keybindings.test.tsindex 72bb5605f..b75c6c017 100644--- a/src/shared/keybindings.test.ts+++ b/src/shared/keybindings.test.ts@@ -480,3 +480,28 @@ describe('resolver under terminal-first', () => {.toBe('app.commandPalette')})})++describe('dictation conflict bucket', () => {+ it("a dictation override sharing another command's chord is NOT a conflict", () => {+ expect(findKeybindingConflicts({ 'speech.dictation': ['Cmd+K'] }, true)).toEqual([])+ })+ it('sanitize keeps a colliding dictation override — the migration survival case', () => {+ const r = sanitizeKeybindingOverrides({ 'speech.dictation': ['Cmd+K'] }, true)+ expect(r).toEqual({ overrides: { 'speech.dictation': ['Cmd+K'] }, warnings: [] })+ })+ it("sanitize keeps BOTH sides when a user override shares dictation's chord", () => {+ const r = sanitizeKeybindingOverrides(+ { 'speech.dictation': ['Cmd+J'], 'app.commandPalette': ['Cmd+J'] },+ true+ )+ expect(r.overrides).toEqual({+ 'speech.dictation': ['Cmd+J'],+ 'app.commandPalette': ['Cmd+J']+ })+ expect(r.warnings).toEqual([])+ })+ 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 d7da363bd..15cd17ca2 100644--- a/src/shared/keybindings.ts+++ b/src/shared/keybindings.ts@@ -220,9 +220,32 @@ export function bindingIdentity(binding: string, isMac: boolean): string {/** Commands sharing a bucket compete for the same keys. 'app' and 'canvas' share one global* keyspace (both dispatch from the window listener; canvas commands are merely inert while- * the board is open); terminal and scm are their own focused surfaces. */-export function conflictBucket(scope: CommandScope): 'global' | 'terminal' | 'scm' {- return scope === 'app' || scope === 'canvas' ? 'global' : scope+ * the board is open); terminal and scm are their own focused surfaces.+ *+ * **`speech.dictation` is its own fourth bucket, and the reason is dispatch, not scope.** It+ * never competes for a chord: the resolver SKIPS it outright (see the `def.id ===+ * 'speech.dictation'` guard in `resolveCommandForKeyEvent`), and its keyed gesture runs from a+ * dedicated listener that claims the chord FIRST in plain app focus. So a chord shared with+ * another command is a matter of PRECEDENCE — dictation wins where it listens, the other command+ * wins everywhere else (terminal focus, say) — never ambiguity, which is the only thing the+ * conflict detector exists to find. Folding it into 'global' therefore reported a collision that+ * dispatch cannot produce.+ *+ * What the bucket BUYS is survival on the read path: `sanitizeKeybindingOverrides` deletes every+ * overridden participant of a reported conflict, so a migrated legacy chord that happened to match+ * another command's binding (the `speech.shortcut` → `speech.dictation` seed in+ * `core/settings-store.ts`) was seeded on load and stripped moments later, taking the user's own+ * colliding override with it. With its own bucket the seed survives.+ *+ * **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. */+export function conflictBucket(+ def: Pick<CommandDefinition, 'id' | 'scope'>+): 'global' | 'terminal' | 'scm' | 'dictation' {+ if (def.id === 'speech.dictation') return 'dictation'+ return def.scope === 'app' || def.scope === 'canvas' ? 'global' : def.scope}export interface KeybindingConflict {@@ -244,7 +267,7 @@ export function findKeybindingConflicts(const byBucketAndIdentity = new Map<string, { binding: string; ids: Set<CommandId> }>()for (const def of COMMAND_DEFINITIONS) {for (const binding of getEffectiveBindings(def.id, overrides, isMac)) {- const key = `${conflictBucket(def.scope)} ${bindingIdentity(binding, isMac)}`+ const key = `${conflictBucket(def)} ${bindingIdentity(binding, isMac)}`const entry = byBucketAndIdentity.get(key) ?? {// Canonicalized, so a hand-edited `cmd+k` override is reported as `Cmd+K`.binding: serializeShortcut(parseShortcut(binding)),