Skip to content

Commit de963b1

Browse files
refactor(web): terminal reuses Sidebar's thread shortcut context
The terminal copied only terminalOpen and previewOpen, so a thread binding gated on isDesktop, isWeb or modelPickerOpen could be judged differently by the terminal and by Sidebar. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2f10728 commit de963b1

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ import { openTerminalLinkInPreview } from "./preview/openTerminalLinkInPreview";
9292
import { useAtomCommand } from "../state/use-atom-command";
9393
import { preventTerminalCloseShortcut } from "../lib/terminalCloseShortcut";
9494
import { observeResize } from "../lib/observeResize";
95-
import { selectActiveRightPanel, useRightPanelStore } from "../rightPanelStore";
96-
import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore";
95+
import { threadShortcutContext } from "./Sidebar.logic";
9796
import {
9897
consumePendingTerminalFocus,
9998
focusTerminal,
@@ -578,14 +577,7 @@ function TerminalSessionViewport({
578577
const hasHandledExitRef = useRef(false);
579578
const selectionActionRequestIdRef = useRef(0);
580579
const readKeybindings = useEffectEvent(() => keybindings);
581-
const readThreadNavigationContext = useEffectEvent(() => ({
582-
terminalOpen: selectThreadTerminalUiState(
583-
useTerminalUiStateStore.getState().terminalUiStateByThreadKey,
584-
threadRef,
585-
).terminalOpen,
586-
previewOpen:
587-
selectActiveRightPanel(useRightPanelStore.getState().byThreadKey, threadRef) === "preview",
588-
}));
580+
const readThreadShortcutContext = useEffectEvent(() => threadShortcutContext(threadRef));
589581
const handleSessionExited = useEffectEvent(() => {
590582
if (hasTerminalWriteAccess()) onSessionExited();
591583
});
@@ -952,7 +944,7 @@ function TerminalSessionViewport({
952944
isDiffToggleShortcut(event, currentKeybindings, options) ||
953945
// Match Sidebar's context, or a key it will reject skips the shell.
954946
isThreadNavigationShortcut(event, currentKeybindings, {
955-
context: { ...options.context, ...readThreadNavigationContext() },
947+
context: { ...readThreadShortcutContext(), terminalFocus: true },
956948
})
957949
) {
958950
return false;

0 commit comments

Comments
 (0)