From 6fb2fe2283db42519e9f2223724c73b4249e493f Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Thu, 7 May 2026 13:28:42 +0700 Subject: [PATCH] Fix pane shortcuts in editable fields --- .../app/src/keyboard/keyboard-shortcuts.test.ts | 10 ++++++++++ packages/app/src/keyboard/keyboard-shortcuts.ts | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/app/src/keyboard/keyboard-shortcuts.test.ts b/packages/app/src/keyboard/keyboard-shortcuts.test.ts index 18cdcc9b7..b1b5d2b5f 100644 --- a/packages/app/src/keyboard/keyboard-shortcuts.test.ts +++ b/packages/app/src/keyboard/keyboard-shortcuts.test.ts @@ -363,6 +363,16 @@ describe("keyboard-shortcuts", () => { event: { key: "\\", code: "Backslash", ctrlKey: true }, context: { isMac: false }, }, + { + name: "keeps Cmd+Shift+ArrowRight available for message input selection", + event: { key: "ArrowRight", code: "ArrowRight", metaKey: true, shiftKey: true }, + context: { isMac: true, focusScope: "message-input" }, + }, + { + name: "keeps Cmd+Shift+ArrowLeft available for generic editable selection", + event: { key: "ArrowLeft", code: "ArrowLeft", metaKey: true, shiftKey: true }, + context: { isMac: true, focusScope: "editable" }, + }, { name: "keeps space typing available in message input", event: { key: " ", code: "Space" }, diff --git a/packages/app/src/keyboard/keyboard-shortcuts.ts b/packages/app/src/keyboard/keyboard-shortcuts.ts index 8141128cd..f64db03af 100644 --- a/packages/app/src/keyboard/keyboard-shortcuts.ts +++ b/packages/app/src/keyboard/keyboard-shortcuts.ts @@ -52,6 +52,8 @@ interface ShortcutWhen { mac?: boolean; /** true = desktop only, false = web only */ desktop?: boolean; + /** false = disabled when a text-editing surface is focused */ + editable?: false; /** false = disabled when terminal is focused */ terminal?: false; /** false = disabled when command center is open */ @@ -454,7 +456,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [ id: "workspace-pane-focus-left-cmd-shift-left", action: "workspace.pane.focus.left", combo: "Cmd+Shift+ArrowLeft", - when: { mac: true, commandCenter: false }, + when: { mac: true, commandCenter: false, editable: false }, help: { id: "workspace-pane-focus-left", section: "tabs-panes", @@ -466,7 +468,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [ id: "workspace-pane-focus-right-cmd-shift-right", action: "workspace.pane.focus.right", combo: "Cmd+Shift+ArrowRight", - when: { mac: true, commandCenter: false }, + when: { mac: true, commandCenter: false, editable: false }, help: { id: "workspace-pane-focus-right", section: "tabs-panes", @@ -478,7 +480,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [ id: "workspace-pane-focus-up-cmd-shift-up", action: "workspace.pane.focus.up", combo: "Cmd+Shift+ArrowUp", - when: { mac: true, commandCenter: false }, + when: { mac: true, commandCenter: false, editable: false }, help: { id: "workspace-pane-focus-up", section: "tabs-panes", @@ -490,7 +492,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [ id: "workspace-pane-focus-down-cmd-shift-down", action: "workspace.pane.focus.down", combo: "Cmd+Shift+ArrowDown", - when: { mac: true, commandCenter: false }, + when: { mac: true, commandCenter: false, editable: false }, help: { id: "workspace-pane-focus-down", section: "tabs-panes", @@ -1035,6 +1037,12 @@ function matchesWhen(when: ShortcutWhen | undefined, context: KeyboardShortcutCo if (!when) return true; if (when.mac !== undefined && when.mac !== context.isMac) return false; if (when.desktop !== undefined && when.desktop !== context.isDesktop) return false; + if ( + when.editable === false && + (context.focusScope === "message-input" || context.focusScope === "editable") + ) { + return false; + } if (when.terminal === false && context.focusScope === "terminal") return false; if (when.commandCenter === false && context.commandCenterOpen) return false; if (when.focusScope !== undefined && context.focusScope !== when.focusScope) return false;