Skip to content

Commit b3ad18f

Browse files
fix(web): the thread search shortcut sees terminal and preview state
A keybinding's `when` clause reads `terminalOpen` and `previewOpen` from the scope's context. The shortcut's registration passed no context, so both read false, and a rule with `when: "terminalOpen"` never fired, even with the terminal open. The registration now passes both, read when the key is pressed, as the app shell's own scopes do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e8793ec commit b3ad18f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import { useShortcutModifierState } from "../shortcutModifierState";
101101
import { isTerminalFocused } from "../lib/terminalFocus";
102102
import { isModelPickerOpen } from "../modelPickerVisibility";
103103
import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore";
104+
import { selectActiveRightPanel, useRightPanelStore } from "../rightPanelStore";
104105
import { isMacPlatform } from "~/lib/utils";
105106
import { readLocalApi } from "../localApi";
106107
import { useSidebarPendingFileDropStore } from "../sidebarPendingFileDropStore";
@@ -2899,10 +2900,20 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
28992900
threadSearchInputRef.current?.focus();
29002901
threadSearchInputRef.current?.select();
29012902
});
2903+
const readRoutePanelsOpen = useStableCallback(() => ({
2904+
terminalOpen: routeTerminalOpen,
2905+
previewOpen:
2906+
selectActiveRightPanel(useRightPanelStore.getState().byThreadKey, routeThreadRef) ===
2907+
"preview",
2908+
}));
29022909
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- registers the capture-phase thread search shortcut while the sidebar is mounted
29032910
useEffect(
2904-
() => registerCommands({ "sidebar.focusSearch": onFocusSearchShortcut }, { capture: true }),
2905-
[onFocusSearchShortcut],
2911+
() =>
2912+
registerCommands(
2913+
{ "sidebar.focusSearch": onFocusSearchShortcut },
2914+
{ capture: true, context: readRoutePanelsOpen },
2915+
),
2916+
[onFocusSearchShortcut, readRoutePanelsOpen],
29062917
);
29072918

29082919
const newThreadShortcutLabel =

0 commit comments

Comments
 (0)