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
refactor(dictation): single-source the chord through the keybinding registry
enes37e539959750
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex ec74ddabf..8dc946316 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -179,7 +179,12 @@ import {type GlobalKeydownDeps} from '../lib/globalKeybindings'import type { ContextElement } from '../lib/keyContext'-import { activeKeybindingOverrides, chipFor, commandTooltip } from '../lib/keybindingOverrides'+import {+ activeKeybindingOverrides,+ chipFor,+ commandTooltip,+ dictationBinding+} from '../lib/keybindingOverrides'import { UsageIndicator } from '../components/UsageIndicator'import { SystemResourcePill } from '../components/SystemResourcePill'import { PresenceLayer } from '../components/PresenceLayer'@@ -3615,6 +3620,10 @@ export function Canvas() {setRemotePicker(screenPos)}, [])+ // The selector re-runs on every settings change and returns a STRING, so zustand's default+ // equality keeps this from re-rendering the canvas unless the chord itself moved.+ const dictationChord = useSettings(() => dictationBinding())+// v3 hold-to-talk: active only while the configured dictation shortcut is a modifier-only// chord (isHoldChord — the new default, "Cmd+Alt"). Walkie-talkie semantics: the chord held// down starts recording immediately (armed on the keydown that completes the exact modifier@@ -3631,8 +3640,15 @@ export function Canvas() {// already-armed chord are inert by construction: once armed, a repeat keydown of the same// modifier still satisfies chordHeld, so the "misfire" branch's condition is false and it's a// no-op. Window blur (app switch) cancels outright.+ //+ // The chord comes from the keybinding registry (`dictationBinding()` — the first effective+ // `speech.dictation` binding), not from settings.speech.shortcut, so a remap in+ // settings.json's `keybindings` block reaches hold mode too. The `=== ''` test in front of+ // every isHoldChord call is LOAD-BEARING: `''` means the user DISABLED dictation, and+ // `isHoldChord('')` is TRUE (an all-false parse has a null key), so without it a disabled+ // binding would arm a modifier-less hold chord that fires on any keydown.useEffect(() => {- if (!isHoldChord(settings.speech.shortcut)) return+ if (dictationChord === '' || !isHoldChord(dictationChord)) returnlet armed = falselet heldSince = 0@@ -3651,8 +3667,8 @@ export function Canvas() {const onKeyDown = (e: KeyboardEvent): void => {if (isKanbanOpen(useProjects.getState().activeProjectId)) return- const combo = useSettings.getState().settings.speech.shortcut- if (!isHoldChord(combo)) return+ const combo = dictationBinding()+ if (combo === '' || !isHoldChord(combo)) returnif (!armed) {// Arm only on the keydown that completes the exact chord — not on every keydown while@@ -3686,7 +3702,16 @@ export function Canvas() {const onKeyUp = (e: KeyboardEvent): void => {if (!armed) return- const combo = useSettings.getState().settings.speech.shortcut+ const combo = dictationBinding()+ // The binding moved mid-hold (disabled, or remapped to a keyed chord): this gesture has+ // no owner any more, so cancel — the same thing the cleanup below does once the change+ // reaches React a tick later. Without this the `''` case would READ AS STILL HELD+ // (`chordHeld(e, '', isMac)` is true exactly when no modifier is down) and the recording+ // would never stop.+ if (combo === '' || !isHoldChord(combo)) {+ cancel()+ return+ }// Still fully down (an unrelated key was released) — keep recording.if (chordHeld(e, combo, isMac)) returnconst heldMs = Date.now() - heldSince@@ -3714,7 +3739,7 @@ export function Canvas() {setDictationOpen(false)}}- }, [settings.speech.shortcut])+ }, [dictationChord])// "Connect to a host" from the Settings section / tab-menu dialog: they collect the pairing offer// and dispatch it here (a window event, so they need no Canvas reference), and this runs the SAME@@ -5230,13 +5255,16 @@ export function Canvas() {// terminal.* / scm.commit / speech.dictation: owned by their local listeners.},gestures: {- // A KEYED dictation shortcut (e.g. "Cmd+Alt+D") toggles dictation. A modifier-only- // shortcut (the new default, "Cmd+Alt") is hold-to-talk instead — matchesShortcut always- // returns false for that shape (its `key` is null), so this gesture is naturally a no-op- // for it; see the dedicated hold-mode effect above, which is what fires in that case.+ // A KEYED dictation shortcut (e.g. "Cmd+Alt+D") toggles dictation. The chord is the+ // registry's first effective `speech.dictation` binding (`dictationBinding()`), so a+ // remap lands here without touching this file. A modifier-only shortcut (the default,+ // "Cmd+Alt") is hold-to-talk instead — matchesShortcut always returns false for that+ // shape (its `key` is null), so this gesture is naturally a no-op for it; see the+ // dedicated hold-mode effect above, which is what fires in that case. The DISABLED case+ // (`''`) needs no guard for the same reason: an empty parse also has a null key.// The dispatcher only offers it in plain app focus (not typing / terminal / kanban).keyedDictation: (e) => {- if (!matchesShortcut(e, useSettings.getState().settings.speech.shortcut, isMac)) return false+ if (!matchesShortcut(e, dictationBinding(), isMac)) return falsee.preventDefault()toggleDictation()return truediff --git a/src/renderer/components/Dock.tsx b/src/renderer/components/Dock.tsxindex 9d4f87d01..2cc0afbcc 100644--- a/src/renderer/components/Dock.tsx+++ b/src/renderer/components/Dock.tsx@@ -3,7 +3,7 @@ import { AGENT_CONFIG, BUILTIN_AGENT_IDS, type AgentId, type BuiltinAgentId } frimport type { CustomAgent } from '@shared/types'import { formatShortcut, isHoldChord } from '@shared/shortcut'import { hasSpeechModel } from '@shared/speech'-import { commandTooltip } from '../lib/keybindingOverrides'+import { commandTooltip, dictationBinding } from '../lib/keybindingOverrides'import { AgentIcon } from '../lib/agentIcons'import { useSettings } from '../state/settings'import { useProjects } from '../state/projects'@@ -77,7 +77,10 @@ export function Dock({// ≥1 inheriting custom agent (one with a `baseAgent` matching it); otherwise it stays a flat// button, byte-identical to before this nesting existed.const [openSub, setOpenSub] = useState<BuiltinAgentId | null>(null)- const dictationShortcut = useSettings((s) => s.settings.speech.shortcut)+ // The registry's first effective `speech.dictation` binding, `''` when the user unbound it.+ // The selector returns a STRING, so zustand's default equality keeps an unrelated settings+ // write from re-rendering the dock.+ const dictationShortcut = useSettings(() => dictationBinding())const speechEngine = useSettings((s) => s.settings.speech.engine)const speechModel = useSettings((s) => s.settings.speech.model)// Whisper with the explicit None selection = dictation off (issue #143). The mic stays visible@@ -302,9 +305,13 @@ export function Dock({title={dictationOff? 'Dictation off — choose a model in Settings → Speech'- : isHoldChord(dictationShortcut)- ? `Dictate (hold ${formatShortcut(dictationShortcut, isMac)})`- : `Dictate (${formatShortcut(dictationShortcut, isMac)})`+ : // The user unbound the shortcut: the mic button still dictates, so the tooltip+ // keeps the label and drops the chord rather than promising a key that is gone.+ dictationShortcut === ''+ ? 'Dictate'+ : isHoldChord(dictationShortcut)+ ? `Dictate (hold ${formatShortcut(dictationShortcut, isMac)})`+ : `Dictate (${formatShortcut(dictationShortcut, isMac)})`}onClick={onDictate}>diff --git a/src/renderer/components/ShortcutsPanel.tsx b/src/renderer/components/ShortcutsPanel.tsxindex 77b838e81..859bab8a3 100644--- a/src/renderer/components/ShortcutsPanel.tsx+++ b/src/renderer/components/ShortcutsPanel.tsx@@ -3,7 +3,7 @@ import { createPortal } from 'react-dom'import { isHoldChord, shortcutKeyParts } from '@shared/shortcut'import type { CommandId } from '@shared/keybindings'import { isBrowserRuntime } from '../bridge/runtime'-import { commandKeys } from '../lib/keybindingOverrides'+import { commandKeys, dictationBinding } from '../lib/keybindingOverrides'import { useSettings } from '../state/settings'const isMac = /Mac/i.test(navigator.platform || navigator.userAgent)@@ -25,14 +25,26 @@ interface Row {* what makes the panel and the key agree — `terminal.find` included, whose match in* TerminalNode now reads `effectiveBindings('terminal.find')` instead of a hardcoded* Cmd/Ctrl+F. Gesture/mouse rows stay literal: they are not commands and the registry knows- * nothing about them. "Dictate" also stays literal — its chord still lives in- * `settings.speech.shortcut` (the registry's `speech.dictation` row is display-only for now),- * and a modifier-only chord is hold-to-talk, which the label spells out. */-function buildSections(dictationKeys: string[], dictationLabel: string): { title: string; rows: Row[] }[] {+ * nothing about them. "Dictate" is a registry row too now — its chord comes from+ * `dictationBinding()` (the first effective `speech.dictation` binding), with the legacy+ * `settings.speech.shortcut` field kept only as a downgrade mirror — so it follows a remap and+ * DROPS off the panel when the user unbinds it, exactly like every `cmd()` row above. It keeps+ * its own builder because it is the one row whose LABEL depends on the chord's shape: a+ * modifier-only chord is hold-to-talk, which "Dictate (hold)" spells out. */+function buildSections(dictationChord: string): { title: string; rows: Row[] }[] {const cmd = (id: CommandId, label: string): Row[] => {const keys = commandKeys(id)return keys.length ? [{ keys, label }] : []}+ const dictate = (): Row[] =>+ dictationChord === ''+ ? []+ : [+ {+ keys: shortcutKeyParts(dictationChord, isMac),+ label: isHoldChord(dictationChord) ? 'Dictate (hold)' : 'Dictate'+ }+ ]return [{title: 'General',@@ -47,7 +59,7 @@ function buildSections(dictationKeys: string[], dictationLabel: string): { title// Desktop only: browsers own Cmd/Ctrl+1-9 for tab switching and a page cannot take it// back, so listing it in the Server Edition would promise a shortcut that never fires....(isBrowserRuntime() ? [] : [{ keys: ['⌘', '1-9'], label: 'Jump to project' }]),- { keys: dictationKeys, label: dictationLabel },+ ...dictate(),...cmd('canvas.undo', 'Undo'),...cmd('canvas.redo', 'Redo')]@@ -96,11 +108,9 @@ function buildSections(dictationKeys: string[], dictationLabel: string): { title/** Keyboard shortcuts reference; shown on first launch and via ⌘/ or the ? button. */export function ShortcutsPanel({ onClose }: ShortcutsPanelProps) {- const speechShortcut = useSettings((s) => s.settings.speech.shortcut)- const SECTIONS = buildSections(- shortcutKeyParts(speechShortcut, isMac),- isHoldChord(speechShortcut) ? 'Dictate (hold)' : 'Dictate'- )+ // A string selector, so an unrelated settings write cannot re-render the panel.+ const dictationChord = useSettings(() => dictationBinding())+ const SECTIONS = buildSections(dictationChord)useEffect(() => {const onKey = (e: KeyboardEvent) => {diff --git a/src/renderer/components/onboarding/OnboardingFlow.tsx b/src/renderer/components/onboarding/OnboardingFlow.tsxindex 5941cf21c..831b80461 100644--- a/src/renderer/components/onboarding/OnboardingFlow.tsx+++ b/src/renderer/components/onboarding/OnboardingFlow.tsx@@ -1,10 +1,11 @@import { useCallback, useEffect, useState } from 'react'import { createPortal } from 'react-dom'-import type { SpeechModelInfo } from '@shared/types'+import { DEFAULT_SETTINGS, type SpeechModelInfo } from '@shared/types'import { AGENT_CONFIG, BUILTIN_AGENT_IDS, type BuiltinAgentId } from '@shared/agents/config'import { isHoldChord, shortcutKeyParts } from '@shared/shortcut'import { hasSpeechModel, SPEECH_MODEL_NONE } from '@shared/speech'import { keyLabel } from '@shared/platform-utils'+import { dictationBinding } from '../../lib/keybindingOverrides'import { IOS_APP_STORE_URL } from '../../lib/links'import { useSettings } from '../../state/settings'import { useEntitlement } from '../../state/entitlement'@@ -159,8 +160,14 @@ export function OnboardingFlow({ onClose }: { onClose: () => void }) {? (settings.defaultAgent as BuiltinAgentId): 'claude'const agent = AGENT_CONFIG[agentId]- const dictKeys = shortcutKeyParts(settings.speech.shortcut, isMac)- const dictHold = isHoldChord(settings.speech.shortcut)+ // The registry's dictation chord. `''` (the user unbound it) falls back to the DEFAULT chord+ // with the copy unchanged: the tour TEACHES the feature, and a fresh install — the only place+ // this flow runs on its own — cannot have it disabled. Telling a first-run user "dictation is+ // off" on a screen whose whole job is to introduce dictation would be a worse lie than the+ // chord being stale for the one user who re-opened the tour after unbinding it.+ const dictationChord = useSettings(() => dictationBinding()) || DEFAULT_SETTINGS.speech.shortcut+ const dictKeys = shortcutKeyParts(dictationChord, isMac)+ const dictHold = isHoldChord(dictationChord)const stepId: StepId = STEPS[step] ?? 'cover'const next = () => setStep((s) => Math.min(s + 1, STEP_COUNT - 1))