The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): let two-modifier navigation chords fire while typing
Konstantin Khlopkov1a3bbe6109b8
diff --git a/apps/desktop/src/lib/keybinds/combo.test.ts b/apps/desktop/src/lib/keybinds/combo.test.tsindex 82a20445366..773707a432d 100644--- a/apps/desktop/src/lib/keybinds/combo.test.ts+++ b/apps/desktop/src/lib/keybinds/combo.test.ts@@ -182,6 +182,31 @@ describe('actionAllowedInInput', () => {expect(actionAllowedInInput('nav.commandPalette', 'mod+pageup')).toBe(false)expect(actionAllowedInInput('view.findInPage', 'mod+end')).toBe(false)})++ it('lets an explicitly rebound two-modifier navigation chord fire while typing (#115980)', async () => {+ const { actionAllowedInInput, comboFromEvent } = await loadCombo('MacIntel')++ // ⌘⌥←/→ and Ctrl+Alt+←/→ carry Alt on top of a primary modifier — that+ // shape has no native text-editing meaning (it is not ⌥← word-jump or+ // ⌘← line-start), so a deliberate rebind of `session.next`/`session.prev`+ // keeps firing with focus in the composer, matching `mod+alt+t`.+ expect(actionAllowedInInput('session.next', 'mod+alt+right')).toBe(true)+ expect(actionAllowedInInput('session.prev', 'mod+alt+left')).toBe(true)+ expect(actionAllowedInInput('session.next', 'ctrl+alt+right')).toBe(true)+ expect(actionAllowedInInput('session.prev', 'ctrl+alt+left')).toBe(true)++ // The accidental-trap class stays input-local: single primary modifier+ // (± Shift) and bare Alt remain native editing gestures.+ expect(actionAllowedInInput('session.next', 'mod+right')).toBe(false)+ expect(actionAllowedInInput('session.next', 'mod+shift+right')).toBe(false)+ expect(actionAllowedInInput('session.next', 'ctrl+pageup')).toBe(false)+ expect(actionAllowedInInput('session.next', 'alt+right')).toBe(false)++ // The dispatcher consumes real keydowns: ⌘⌥→ canonicalizes to the combo+ // the gate now lets through.+ expect(comboFromEvent(keydown({ code: 'ArrowRight', metaKey: true, altKey: true }))).toBe('mod+alt+right')+ expect(comboFromEvent(keydown({ code: 'ArrowLeft', metaKey: true, altKey: true }))).toBe('mod+alt+left')+ })})describe('comboFromEvent — IME composition keydowns never resolve to combos (#84957)', () => {diff --git a/apps/desktop/src/lib/keybinds/combo.ts b/apps/desktop/src/lib/keybinds/combo.tsindex 4222816e420..b844de725f8 100644--- a/apps/desktop/src/lib/keybinds/combo.ts+++ b/apps/desktop/src/lib/keybinds/combo.ts@@ -275,12 +275,25 @@ const TEXT_NAVIGATION_KEYS = new Set(['up', 'down', 'left', 'right', 'home', 'en// a global navigation action, and bare/Shift-only combos (typed letters) are// gated by the allowlist so they never hijack normal typing.export function actionAllowedInInput(actionId: string, combo: string): boolean {- const base = combo.split('+').pop()+ const parts = combo.split('+')+ const base = parts.pop()// 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)) {+ if (!base || base === 'mod' || base === 'ctrl') {+ return false+ }++ // Navigation keys stay with the focused input only for chords that can BE+ // text navigation: a single primary modifier (⌘← line-start, Ctrl+PgUp,+ // ⌘⇧← selection) or bare Alt (⌥← word-jump). A chord that carries Alt on+ // top of a primary modifier (⌘⌥←, Ctrl+Alt+←) has no native text-editing+ // meaning, so an explicitly rebound global action keeps firing while+ // typing — the same shape as the shipped `mod+alt+t` tab-strip default.+ const hasPrimary = parts.includes('mod') || parts.includes('ctrl')++ if (TEXT_NAVIGATION_KEYS.has(base) && !(hasPrimary && parts.includes('alt'))) {return false}