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:
@@ -437,7 +437,6 @@ function AppContainer({
|
|||||||
enabled: chromeEnabled,
|
enabled: chromeEnabled,
|
||||||
isMobile: isCompactLayout,
|
isMobile: isCompactLayout,
|
||||||
toggleAgentList,
|
toggleAgentList,
|
||||||
selectedAgentId,
|
|
||||||
toggleFileExplorer,
|
toggleFileExplorer,
|
||||||
toggleBothSidebars,
|
toggleBothSidebars,
|
||||||
toggleFocusMode,
|
toggleFocusMode,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
type MessageInputKeyboardActionKind,
|
type MessageInputKeyboardActionKind,
|
||||||
type KeyboardShortcutPayload,
|
type KeyboardShortcutPayload,
|
||||||
} from "@/keyboard/actions";
|
} from "@/keyboard/actions";
|
||||||
import { canToggleFileExplorerShortcut } from "@/keyboard/keyboard-shortcut-routing";
|
|
||||||
import { keyboardActionDispatcher } from "@/keyboard/keyboard-action-dispatcher";
|
import { keyboardActionDispatcher } from "@/keyboard/keyboard-action-dispatcher";
|
||||||
import {
|
import {
|
||||||
type ChordState,
|
type ChordState,
|
||||||
@@ -32,7 +31,6 @@ export function useKeyboardShortcuts({
|
|||||||
enabled,
|
enabled,
|
||||||
isMobile,
|
isMobile,
|
||||||
toggleAgentList,
|
toggleAgentList,
|
||||||
selectedAgentId,
|
|
||||||
toggleFileExplorer,
|
toggleFileExplorer,
|
||||||
toggleBothSidebars,
|
toggleBothSidebars,
|
||||||
toggleFocusMode,
|
toggleFocusMode,
|
||||||
@@ -41,7 +39,6 @@ export function useKeyboardShortcuts({
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
isMobile: boolean;
|
isMobile: boolean;
|
||||||
toggleAgentList: () => void;
|
toggleAgentList: () => void;
|
||||||
selectedAgentId?: string;
|
|
||||||
toggleFileExplorer?: () => void;
|
toggleFileExplorer?: () => void;
|
||||||
toggleBothSidebars?: () => void;
|
toggleBothSidebars?: () => void;
|
||||||
toggleFocusMode?: () => void;
|
toggleFocusMode?: () => void;
|
||||||
@@ -262,19 +259,9 @@ export function useKeyboardShortcuts({
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "sidebar.toggle.right":
|
case "sidebar.toggle.right":
|
||||||
if (!toggleFileExplorer) {
|
if (toggleFileExplorer) {
|
||||||
return false;
|
toggleFileExplorer();
|
||||||
}
|
}
|
||||||
if (
|
|
||||||
!canToggleFileExplorerShortcut({
|
|
||||||
selectedAgentId,
|
|
||||||
pathname,
|
|
||||||
toggleFileExplorer,
|
|
||||||
})
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
toggleFileExplorer();
|
|
||||||
return true;
|
return true;
|
||||||
case "view.toggle.focus":
|
case "view.toggle.focus":
|
||||||
if (toggleFocusMode) {
|
if (toggleFocusMode) {
|
||||||
@@ -353,11 +340,6 @@ export function useKeyboardShortcuts({
|
|||||||
isDesktop: isDesktopApp,
|
isDesktop: isDesktopApp,
|
||||||
focusScope,
|
focusScope,
|
||||||
commandCenterOpen: store.commandCenterOpen,
|
commandCenterOpen: store.commandCenterOpen,
|
||||||
hasSelectedAgent: canToggleFileExplorerShortcut({
|
|
||||||
selectedAgentId,
|
|
||||||
pathname,
|
|
||||||
toggleFileExplorer,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
chordState: chordStateRef.current,
|
chordState: chordStateRef.current,
|
||||||
onChordReset: () => {
|
onChordReset: () => {
|
||||||
@@ -438,7 +420,6 @@ export function useKeyboardShortcuts({
|
|||||||
openProjectPickerAction,
|
openProjectPickerAction,
|
||||||
pathname,
|
pathname,
|
||||||
resetModifiers,
|
resetModifiers,
|
||||||
selectedAgentId,
|
|
||||||
toggleAgentList,
|
toggleAgentList,
|
||||||
toggleFileExplorer,
|
toggleFileExplorer,
|
||||||
toggleFocusMode,
|
toggleFocusMode,
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ function shortcutContext(
|
|||||||
isDesktop: false,
|
isDesktop: false,
|
||||||
focusScope: "other",
|
focusScope: "other",
|
||||||
commandCenterOpen: false,
|
commandCenterOpen: false,
|
||||||
hasSelectedAgent: true,
|
|
||||||
...overrides,
|
...overrides,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export type KeyboardShortcutContext = {
|
|||||||
isDesktop: boolean;
|
isDesktop: boolean;
|
||||||
focusScope: KeyboardFocusScope;
|
focusScope: KeyboardFocusScope;
|
||||||
commandCenterOpen: boolean;
|
commandCenterOpen: boolean;
|
||||||
hasSelectedAgent: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type KeyboardShortcutMatch = {
|
export type KeyboardShortcutMatch = {
|
||||||
@@ -57,8 +56,6 @@ interface ShortcutWhen {
|
|||||||
terminal?: false;
|
terminal?: false;
|
||||||
/** false = disabled when command center is open */
|
/** false = disabled when command center is open */
|
||||||
commandCenter?: false;
|
commandCenter?: false;
|
||||||
/** true = requires a selected agent */
|
|
||||||
hasSelectedAgent?: true;
|
|
||||||
/** Exact focus scope match */
|
/** Exact focus scope match */
|
||||||
focusScope?: KeyboardFocusScope;
|
focusScope?: KeyboardFocusScope;
|
||||||
}
|
}
|
||||||
@@ -659,7 +656,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
|||||||
id: "sidebar-toggle-right-cmd-e-mac",
|
id: "sidebar-toggle-right-cmd-e-mac",
|
||||||
action: "sidebar.toggle.right",
|
action: "sidebar.toggle.right",
|
||||||
combo: "Cmd+E",
|
combo: "Cmd+E",
|
||||||
when: { mac: true, hasSelectedAgent: true, commandCenter: false },
|
when: { mac: true, commandCenter: false },
|
||||||
help: {
|
help: {
|
||||||
id: "toggle-right-sidebar",
|
id: "toggle-right-sidebar",
|
||||||
section: "panels",
|
section: "panels",
|
||||||
@@ -671,7 +668,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
|||||||
id: "sidebar-toggle-right-ctrl-e-non-mac",
|
id: "sidebar-toggle-right-ctrl-e-non-mac",
|
||||||
action: "sidebar.toggle.right",
|
action: "sidebar.toggle.right",
|
||||||
combo: "Ctrl+E",
|
combo: "Ctrl+E",
|
||||||
when: { mac: false, hasSelectedAgent: true, commandCenter: false, terminal: false },
|
when: { mac: false, commandCenter: false, terminal: false },
|
||||||
help: {
|
help: {
|
||||||
id: "toggle-right-sidebar",
|
id: "toggle-right-sidebar",
|
||||||
section: "panels",
|
section: "panels",
|
||||||
@@ -683,7 +680,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
|||||||
id: "sidebar-toggle-right-ctrl-backquote",
|
id: "sidebar-toggle-right-ctrl-backquote",
|
||||||
action: "sidebar.toggle.right",
|
action: "sidebar.toggle.right",
|
||||||
combo: "Ctrl+`",
|
combo: "Ctrl+`",
|
||||||
when: { hasSelectedAgent: true, commandCenter: false },
|
when: { commandCenter: false },
|
||||||
},
|
},
|
||||||
|
|
||||||
// --- Toggle both sidebars ---
|
// --- Toggle both sidebars ---
|
||||||
@@ -743,7 +740,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
|||||||
id: "view-toggle-focus-cmd-shift-f-mac",
|
id: "view-toggle-focus-cmd-shift-f-mac",
|
||||||
action: "view.toggle.focus",
|
action: "view.toggle.focus",
|
||||||
combo: "Cmd+Shift+F",
|
combo: "Cmd+Shift+F",
|
||||||
when: { mac: true, hasSelectedAgent: true, commandCenter: false },
|
when: { mac: true, commandCenter: false },
|
||||||
help: {
|
help: {
|
||||||
id: "toggle-focus",
|
id: "toggle-focus",
|
||||||
section: "panels",
|
section: "panels",
|
||||||
@@ -755,7 +752,7 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
|||||||
id: "view-toggle-focus-ctrl-shift-f-non-mac",
|
id: "view-toggle-focus-ctrl-shift-f-non-mac",
|
||||||
action: "view.toggle.focus",
|
action: "view.toggle.focus",
|
||||||
combo: "Ctrl+Shift+F",
|
combo: "Ctrl+Shift+F",
|
||||||
when: { mac: false, hasSelectedAgent: true, commandCenter: false, terminal: false },
|
when: { mac: false, commandCenter: false, terminal: false },
|
||||||
help: {
|
help: {
|
||||||
id: "toggle-focus",
|
id: "toggle-focus",
|
||||||
section: "panels",
|
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.desktop !== undefined && when.desktop !== context.isDesktop) return false;
|
||||||
if (when.terminal === false && context.focusScope === "terminal") return false;
|
if (when.terminal === false && context.focusScope === "terminal") return false;
|
||||||
if (when.commandCenter === false && context.commandCenterOpen) 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;
|
if (when.focusScope !== undefined && context.focusScope !== when.focusScope) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user