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(settings): guard raw overrides + a distinct Add glyph in the shortcuts section
enes6b07891dffd3
diff --git a/src/renderer/components/settings/ShortcutRecorderButton.tsx b/src/renderer/components/settings/ShortcutRecorderButton.tsxindex 260058eed..1324e47ae 100644--- a/src/renderer/components/settings/ShortcutRecorderButton.tsx+++ b/src/renderer/components/settings/ShortcutRecorderButton.tsx@@ -49,13 +49,20 @@ export function ShortcutRecorderButton({idleLabel,onCommit,appearance = 'button',- label+ label,+ idleIcon}: {commandId: CommandIdidleLabel: stringonCommit: (combo: string) => voidappearance?: 'button' | 'icon'label?: string+ /** The glyph the IDLE `appearance="icon"` button shows — presentational only, and it changes+ * nothing else about the recorder. It exists because a row can carry two recorders (Record and+ * Add) side by side in one label-less cluster, where the icon IS the label and two identical+ * keycaps would leave the pair unreadable. Omitted ⇒ the keycap, so every existing call site+ * renders exactly what it did before. */+ idleIcon?: React.ReactNode}): React.JSX.Element {const [capturing, setCapturing] = useState(false)const [hint, setHint] = useState('')@@ -153,7 +160,7 @@ export function ShortcutRecorderButton({{hint || 'Press keys…'}</>) : appearance === 'icon' ? (- <IconRecordKey />+ (idleIcon ?? <IconRecordKey />)) : (idleLabel)}diff --git a/src/renderer/components/settings/sections/ShortcutsSection.test.tsx b/src/renderer/components/settings/sections/ShortcutsSection.test.tsxindex 5db5c4137..de16bf84d 100644--- a/src/renderer/components/settings/sections/ShortcutsSection.test.tsx+++ b/src/renderer/components/settings/sections/ShortcutsSection.test.tsx@@ -179,6 +179,44 @@ describe('ShortcutsSection rows', () => {expect(body().children).toHaveLength(2 + 6)})+ // `settings.keybindings` is hand-editable JSON and `mergeSettings` passes it through with NO+ // per-value validation, so `{"canvas.undo": null}` reaches this component verbatim. Anything+ // that reads `.length` off the raw value throws — inside a memo that runs on every render, with+ // no error boundary above Settings, i.e. it blanks the whole renderer and takes away the very+ // page the user would have opened to repair the value.+ it('survives malformed override values and shows those commands as unmodified defaults', () => {+ setKb({ 'canvas.undo': null, 'canvas.redo': 'Cmd+Y' })+ expect(() => render()).not.toThrow()+ // The sanitized read path already discarded both, so the rows show their defaults…+ expect([...row('canvas.undo').querySelectorAll('kbd')].map((k) => k.textContent)).toEqual([+ '⌘',+ 'Z'+ ])+ // …and nothing claims they are overridden: no Modified badge, no Reset, and they are not+ // counted in the rail's Modified bucket.+ expect(row('canvas.undo').querySelectorAll('[data-badge]')).toHaveLength(0)+ expect(button('canvas.undo', 'Reset Undo')).toBeNull()+ expect(button('canvas.redo', 'Reset Redo')).toBeNull()+ expect(statusLabels()).toEqual([+ `All ${COMMAND_DEFINITIONS.length}`,+ 'Modified 0',+ 'Unassigned 2',+ 'Disabled 0'+ ])+ })++ // Record and Add sit side by side in the same hover-revealed cluster with no text, so two+ // identical keycaps would leave the pair unreadable — the icon is the whole label.+ it('gives Add a different glyph than Record', () => {+ render()+ const record = button('app.commandPalette', 'Record Command palette')!+ const add = button('app.commandPalette', 'Add a shortcut to Command palette')!+ expect(record.querySelector('rect')).toBeTruthy()+ expect(add.querySelector('rect')).toBeNull()+ expect(add.querySelector('path')?.getAttribute('d')).toBe('M8 3.5v9M3.5 8h9')+ expect(add.innerHTML).not.toEqual(record.innerHTML)+ })+// The dictation row must not promise a second chord: every consumer reads// `dictationBinding()` = the FIRST effective binding, so an added one could never fire.it('offers Add for an ordinary command but never for Dictate', () => {diff --git a/src/renderer/components/settings/sections/ShortcutsSection.tsx b/src/renderer/components/settings/sections/ShortcutsSection.tsxindex 41539d9fa..041e0d62a 100644--- a/src/renderer/components/settings/sections/ShortcutsSection.tsx+++ b/src/renderer/components/settings/sections/ShortcutsSection.tsx@@ -45,6 +45,7 @@ import {type CommandDefinition,type CommandGroup,type CommandId,+ type KeybindingOverrides,type TerminalShortcutPolicy} from '@shared/keybindings'import { formatShortcut } from '@shared/shortcut'@@ -60,7 +61,7 @@ import { SettingsSection } from '../SettingsSection'import { SearchableRow } from '../SearchableRow'import { FieldRow } from '../FieldRow'import { ShortcutRecorderButton } from '../ShortcutRecorderButton'-import { IconDisableSlash, IconResetArrow } from '../ShortcutRowIcons'+import { IconDisableSlash, IconPlusSmall, IconResetArrow } from '../ShortcutRowIcons'import { Input } from '@renderer/ui/Input'import { SegmentedPill } from '@renderer/ui/SegmentedPill'import { useSettingsSearch } from '../context'@@ -373,6 +374,33 @@ export function ShortcutsSection({ isActive }: { isActive: boolean }): React.JSX[groups])+ /**+ * The RAW `settings.keybindings`, narrowed to the entries whose value is actually a list.+ *+ * **`shortcutRowStatus` reads `override.length`, and the raw map is not typed at runtime.**+ * `settings.keybindings` is hand-editable JSON and `mergeSettings` passes it through with no+ * per-value validation, so `{"canvas.undo": null}` arrives here verbatim — inside a memo that+ * runs on every render, with no error boundary above Settings, which means a `TypeError` here+ * blanks the whole renderer and takes away the page the user would have opened to repair the+ * value. The pre-redesign row carried this guard inline+ * (`Array.isArray(override) && override.length === 0`); this is that guard, at the one call+ * site that still needs it. `shortcutFilter.ts` is pure and stays as shipped: a malformed+ * value is this section's to keep out, not that module's to tolerate.+ *+ * A non-array entry reads as **absent** — the row shows its default, offers no Reset and is+ * not counted as Modified. That is the truth rather than a degrade: the sanitized read path+ * (`sanitizeKeybindingOverrides`, which already ignores it) is what the chips and every gate+ * are showing, so there is no override for a Reset to undo.+ */+ const listOverrides = useMemo<KeybindingOverrides>(() => {+ const out: KeybindingOverrides = {}+ for (const def of COMMAND_DEFINITIONS) {+ const value = overrides?.[def.id]+ if (Array.isArray(value)) out[def.id] = value+ }+ return out+ }, [overrides])+// One read of the override map per render pass, shared by the counts and by the rendered rows.// Two reads would be two chances to disagree — the pill saying `Modified 2` over one row.const models = useMemo<RowModel[]>(@@ -385,10 +413,10 @@ export function ShortcutsSection({ isActive }: { isActive: boolean }): React.JSXentry,keywords: rowKeywords(entry),chords,- status: shortcutRowStatus(def.id, overrides, chords.length)+ status: shortcutRowStatus(def.id, listOverrides, chords.length)}}),- [overrides]+ [listOverrides])const modelById = useMemo(() => new Map(models.map((m) => [m.def.id, m])), [models])@@ -510,6 +538,9 @@ export function ShortcutsSection({ isActive }: { isActive: boolean }): React.JSXappearance="icon"idleLabel="Add"label={`Add a shortcut to ${def.title}`}+ // Record sits immediately to its left in the same label-less cluster; the+ // glyph is the only thing telling the two apart.+ idleIcon={<IconPlusSmall />}onCommit={(combo) => apply(def.id, combo, 'add')}/>) : null}