fix: remove hasSelectedAgent gate from Cmd+E and focus mode shortcuts

The hasSelectedAgent condition was redundantly gating Cmd+E (toggle right
sidebar) and Cmd+Shift+F (toggle focus mode) behind a pathname check that
Cmd+B and Cmd+. didn't require. The action handler already guards against
invalid states, making the when-clause check unnecessary and broken on the
dev branch's navigation flow.
This commit is contained in:
Mohamed Boudra
2026-04-14 17:34:51 +07:00
parent c80d7a8165
commit 326dad93e4
4 changed files with 7 additions and 32 deletions
-1
View File
@@ -437,7 +437,6 @@ function AppContainer({
enabled: chromeEnabled,
isMobile: isCompactLayout,
toggleAgentList,
selectedAgentId,
toggleFileExplorer,
toggleBothSidebars,
toggleFocusMode,
@@ -15,7 +15,6 @@ import {
type MessageInputKeyboardActionKind,
type KeyboardShortcutPayload,
} from "@/keyboard/actions";
import { canToggleFileExplorerShortcut } from "@/keyboard/keyboard-shortcut-routing";
import { keyboardActionDispatcher } from "@/keyboard/keyboard-action-dispatcher";
import {
type ChordState,
@@ -32,7 +31,6 @@ export function useKeyboardShortcuts({
enabled,
isMobile,
toggleAgentList,
selectedAgentId,
toggleFileExplorer,
toggleBothSidebars,
toggleFocusMode,
@@ -41,7 +39,6 @@ export function useKeyboardShortcuts({
enabled: boolean;
isMobile: boolean;
toggleAgentList: () => void;
selectedAgentId?: string;
toggleFileExplorer?: () => void;
toggleBothSidebars?: () => void;
toggleFocusMode?: () => void;
@@ -262,19 +259,9 @@ export function useKeyboardShortcuts({
}
return true;
case "sidebar.toggle.right":
if (!toggleFileExplorer) {
return false;
if (toggleFileExplorer) {
toggleFileExplorer();
}
if (
!canToggleFileExplorerShortcut({
selectedAgentId,
pathname,
toggleFileExplorer,
})
) {
return false;
}
toggleFileExplorer();
return true;
case "view.toggle.focus":
if (toggleFocusMode) {
@@ -353,11 +340,6 @@ export function useKeyboardShortcuts({
isDesktop: isDesktopApp,
focusScope,
commandCenterOpen: store.commandCenterOpen,
hasSelectedAgent: canToggleFileExplorerShortcut({
selectedAgentId,
pathname,
toggleFileExplorer,
}),
},
chordState: chordStateRef.current,
onChordReset: () => {
@@ -438,7 +420,6 @@ export function useKeyboardShortcuts({
openProjectPickerAction,
pathname,
resetModifiers,
selectedAgentId,
toggleAgentList,
toggleFileExplorer,
toggleFocusMode,
@@ -29,7 +29,6 @@ function shortcutContext(
isDesktop: false,
focusScope: "other",
commandCenterOpen: false,
hasSelectedAgent: true,
...overrides,
};
}
@@ -16,7 +16,6 @@ export type KeyboardShortcutContext = {
isDesktop: boolean;
focusScope: KeyboardFocusScope;
commandCenterOpen: boolean;
hasSelectedAgent: boolean;
};
export type KeyboardShortcutMatch = {
@@ -57,8 +56,6 @@ interface ShortcutWhen {
terminal?: false;
/** false = disabled when command center is open */
commandCenter?: false;
/** true = requires a selected agent */
hasSelectedAgent?: true;
/** Exact focus scope match */
focusScope?: KeyboardFocusScope;
}
@@ -659,7 +656,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
id: "sidebar-toggle-right-cmd-e-mac",
action: "sidebar.toggle.right",
combo: "Cmd+E",
when: { mac: true, hasSelectedAgent: true, commandCenter: false },
when: { mac: true, commandCenter: false },
help: {
id: "toggle-right-sidebar",
section: "panels",
@@ -671,7 +668,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
id: "sidebar-toggle-right-ctrl-e-non-mac",
action: "sidebar.toggle.right",
combo: "Ctrl+E",
when: { mac: false, hasSelectedAgent: true, commandCenter: false, terminal: false },
when: { mac: false, commandCenter: false, terminal: false },
help: {
id: "toggle-right-sidebar",
section: "panels",
@@ -683,7 +680,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
id: "sidebar-toggle-right-ctrl-backquote",
action: "sidebar.toggle.right",
combo: "Ctrl+`",
when: { hasSelectedAgent: true, commandCenter: false },
when: { commandCenter: false },
},
// --- Toggle both sidebars ---
@@ -743,7 +740,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
id: "view-toggle-focus-cmd-shift-f-mac",
action: "view.toggle.focus",
combo: "Cmd+Shift+F",
when: { mac: true, hasSelectedAgent: true, commandCenter: false },
when: { mac: true, commandCenter: false },
help: {
id: "toggle-focus",
section: "panels",
@@ -755,7 +752,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
id: "view-toggle-focus-ctrl-shift-f-non-mac",
action: "view.toggle.focus",
combo: "Ctrl+Shift+F",
when: { mac: false, hasSelectedAgent: true, commandCenter: false, terminal: false },
when: { mac: false, commandCenter: false, terminal: false },
help: {
id: "toggle-focus",
section: "panels",
@@ -1015,7 +1012,6 @@ function matchesWhen(when: ShortcutWhen | undefined, context: KeyboardShortcutCo
if (when.desktop !== undefined && when.desktop !== context.isDesktop) return false;
if (when.terminal === false && context.focusScope === "terminal") return false;
if (when.commandCenter === false && context.commandCenterOpen) return false;
if (when.hasSelectedAgent === true && !context.hasSelectedAgent) return false;
if (when.focusScope !== undefined && context.focusScope !== when.focusScope) return false;
return true;
}