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
@@ -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;
}