Skip to content

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.

fix(keybindings): make the commit chord registry-driven, not hardcoded

enesfac2a910ab1c
diff --git a/src/renderer/components/ShortcutsPanel.tsx b/src/renderer/components/ShortcutsPanel.tsx
index 2c6d3af17..3400a6e54 100644
--- a/src/renderer/components/ShortcutsPanel.tsx
+++ b/src/renderer/components/ShortcutsPanel.tsx
@@ -21,6 +21,9 @@ interface Row {
/** Registry rows derive their keys from the effective binding, so a remap in settings.json
* shows up here without touching this file — and a command the user unbound (or that ships
* unassigned) drops off the panel instead of advertising a chord that no longer fires.
+ * That promise only holds while every row's KEYBOARD path also reads the registry, which is
+ * what makes the panel and the key agree. One row does not yet: `terminal.find` still matches
+ * a hardcoded Cmd/Ctrl+F in TerminalNode — it becomes registry-backed in the next change.
* 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),
diff --git a/src/renderer/components/SourceControlPanel.tsx b/src/renderer/components/SourceControlPanel.tsx
index bdbde8721..a0d925c62 100644
--- a/src/renderer/components/SourceControlPanel.tsx
+++ b/src/renderer/components/SourceControlPanel.tsx
@@ -16,7 +16,9 @@ import { buildCommitMenuItems } from './git-history/git-history-menu'
import { ContextMenu, type MenuItem } from './ContextMenu'
import { PublishDialog } from './PublishDialog'
import { defaultScmScope, type ScmScope } from '@shared/scm-scope'
-import { chipFor } from '../lib/keybindingOverrides'
+import { chipFor, effectiveBindings } from '../lib/keybindingOverrides'
+import { matchesShortcut } from '@shared/shortcut'
+import { isMacPlatform } from '@shared/platform-utils'
export interface SourceControlPanelProps {
onClose: () => void
@@ -37,6 +39,9 @@ export interface SourceControlPanelProps {
const AUTO_FETCH_MS = 180_000
+/** Which physical modifier the registry's abstract `Cmd` resolves to for the commit chord. */
+const isMac = isMacPlatform()
+
const STATUS_COLOR: Record<string, string> = {
M: '#ffd60a',
A: '#32d74b',
@@ -404,8 +409,9 @@ export function SourceControlPanel({
)
}
- // Whatever Commit is bound to; '' when unbound, in which case the box is just "Message" —
- // the button below it still commits.
+ // Whatever Commit is bound to; '' when unbound — in which case the box is just "Message" AND
+ // the keyboard path below is disabled with it (no binding to match), so the placeholder never
+ // promises a chord the textarea would ignore. The Commit button is the fallback either way.
const commitChip = chipFor('scm.commit')
return createPortal(
@@ -511,7 +517,13 @@ export function SourceControlPanel({
value={message}
onChange={(e) => setMessage(e.target.value)}
onKeyDown={(e) => {
- if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') commitAndPush()
+ // Registry-driven (L2: a local listener reads its binding from the registry),
+ // so a remapped scm.commit changes the KEY as well as the placeholder above.
+ // Matching is exact on all four modifiers, unlike the old
+ // `metaKey || ctrlKey` — see the named losses in the keybindings notes.
+ if (effectiveBindings('scm.commit').some((s) => matchesShortcut(e, s, isMac))) {
+ commitAndPush()
+ }
}}
/>
<button
diff --git a/src/renderer/lib/keybindingOverrides.test.ts b/src/renderer/lib/keybindingOverrides.test.ts
index c66fdee5a..cf99bdf96 100644
--- a/src/renderer/lib/keybindingOverrides.test.ts
+++ b/src/renderer/lib/keybindingOverrides.test.ts
@@ -1,5 +1,6 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { DEFAULT_SETTINGS } from '@shared/types'
+import { matchesShortcut, type ShortcutKeyEvent } from '@shared/shortcut'
import { useSettings } from '../state/settings'
import {
activeKeybindingOverrides, effectiveBindings, commandKeys, commandTooltip, chipFor
@@ -54,6 +55,43 @@ describe('effectiveBindings / commandKeys / commandTooltip', () => {
})
})
+// The exact composition SourceControlPanel's commit textarea now runs on keydown. It replaced a
+// lax `(e.metaKey || e.ctrlKey) && e.key === 'Enter'`, so the D-strict losses below are pinned
+// here rather than asserted in prose: matching is EXACT on all four modifiers.
+describe('the commit textarea matcher (scm.commit)', () => {
+ const key = (over: Partial<ShortcutKeyEvent> = {}): ShortcutKeyEvent =>
+ ({ metaKey: false, ctrlKey: false, shiftKey: false, altKey: false, key: 'Enter', ...over })
+ const commits = (e: ShortcutKeyEvent, isMac: boolean) =>
+ effectiveBindings('scm.commit').some((s) => matchesShortcut(e, s, isMac))
+
+ it('commits on the platform chord', () => {
+ expect(commits(key({ metaKey: true }), true)).toBe(true)
+ expect(commits(key({ ctrlKey: true }), false)).toBe(true)
+ })
+ it('no longer commits on the OTHER platform primary (the named D-strict losses)', () => {
+ expect(commits(key({ ctrlKey: true }), true)).toBe(false) // mac Ctrl+Enter
+ expect(commits(key({ metaKey: true }), false)).toBe(false) // non-mac Meta+Enter
+ })
+ it('no longer commits with an extra modifier held on top', () => {
+ expect(commits(key({ metaKey: true, shiftKey: true }), true)).toBe(false)
+ expect(commits(key({ metaKey: true, altKey: true }), true)).toBe(false)
+ })
+ it('follows a remap, so the key agrees with the placeholder chip', () => {
+ setKb({ 'scm.commit': ['Cmd+Shift+Enter'] })
+ expect(commits(key({ metaKey: true }), true)).toBe(false)
+ expect(commits(key({ metaKey: true, shiftKey: true }), true)).toBe(true)
+ expect(chipFor('scm.commit', true)).toBe('⌘⇧Enter')
+ })
+ it('is inert when unbound — the placeholder drops its chord for the same reason', () => {
+ setKb({ 'scm.commit': [] })
+ expect(commits(key({ metaKey: true }), true)).toBe(false)
+ expect(chipFor('scm.commit', true)).toBe('')
+ })
+ it('plain Enter never commits (it types a newline)', () => {
+ expect(commits(key(), true)).toBe(false)
+ })
+})
+
describe('chipFor', () => {
it('renders the bare chord the way each platform spells it', () => {
expect(chipFor('app.commandPalette', true)).toBe('⌘K')