Skip to content

The agent that grows with you

fix(desktop): reject bare modifier combos in the input gate

David Metcalfeca50ff332fd3
diff --git a/apps/desktop/src/lib/keybinds/combo.test.ts b/apps/desktop/src/lib/keybinds/combo.test.ts
index 35165651a6c..0d8fffd3957 100644
--- a/apps/desktop/src/lib/keybinds/combo.test.ts
+++ b/apps/desktop/src/lib/keybinds/combo.test.ts
@@ -163,6 +163,11 @@ describe('actionAllowedInInput', () => {
// would have to dodge shipped defaults (⌘K, ⌘W, ⌘D, ⌘F, ⌘B) or re-break them.
expect(actionAllowedInInput('session.new', 'ctrl+a')).toBe(true)
+ // Bare modifiers are not real chords — `comboFromEvent` never yields
+ // them, so a malformed stored binding must not pass the shape-only check.
+ expect(actionAllowedInInput('session.new', 'mod')).toBe(false)
+ expect(actionAllowedInInput('session.new', 'ctrl')).toBe(false)
+
// Bare/Shift-only combos must never hijack typing: a rebound ⌘N → 'n'
// (or the pre-#76185 'shift+n') must not fire while the user types N.
expect(actionAllowedInInput('session.new', 'n')).toBe(false)
diff --git a/apps/desktop/src/lib/keybinds/combo.ts b/apps/desktop/src/lib/keybinds/combo.ts
index 7f091f803b5..d5cedeeb90a 100644
--- a/apps/desktop/src/lib/keybinds/combo.ts
+++ b/apps/desktop/src/lib/keybinds/combo.ts
@@ -270,7 +270,10 @@ const TEXT_NAVIGATION_KEYS = new Set(['up', 'down', 'left', 'right', 'home', 'en
export function actionAllowedInInput(actionId: string, combo: string): boolean {
const base = combo.split('+').pop()
- if (base && TEXT_NAVIGATION_KEYS.has(base)) {
+ // A bare modifier (no key) is not a real chord — `comboFromEvent` never
+ // yields one, but reject it here so a malformed stored binding can't pass
+ // the shape-only mod/ctrl check below.
+ if (!base || base === 'mod' || base === 'ctrl' || TEXT_NAVIGATION_KEYS.has(base)) {
return false
}