History

Fix sidebar terminal shortcut state subscription

Cursor Agent committed 5 months ago

Commit 41556cc1 parent a6edad11 file · +9 −14Browse files

Unified · Split

apps/web/src/components/Sidebar.tsx+9−14
@@ -2810,6 +2810,11 @@ export default function Sidebar() { · 2809 unmodified lines
2810 select: (params) => resolveThreadRouteRef(params),2810 select: (params) => resolveThreadRouteRef(params),
2811 });2811 });
2812 const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;2812 const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;
2813 const activeThreadTerminalOpen = useTerminalUiStateStore((state) =>
2814 routeThreadRef
2815 ? selectThreadTerminalUiState(state.terminalUiStateByThreadKey, routeThreadRef).terminalOpen
2816 : false,
2817 );
2813 const keybindings = useServerKeybindings();2818 const keybindings = useServerKeybindings();
2814 const openAddProjectCommandPalette = useCommandPaletteStore((store) => store.openAddProject);2819 const openAddProjectCommandPalette = useCommandPaletteStore((store) => store.openAddProject);
2815 const [expandedThreadListsByProject, setExpandedThreadListsByProject] = useState<2820 const [expandedThreadListsByProject, setExpandedThreadListsByProject] = useState<
@@ -2926,15 +2931,10 @@ export default function Sidebar() { · 110 unmodified lines
2926 const getCurrentSidebarShortcutContext = useCallback(2931 const getCurrentSidebarShortcutContext = useCallback(
2927 () => ({2932 () => ({
2928 terminalFocus: isTerminalFocused(),2933 terminalFocus: isTerminalFocused(),
2929 terminalOpen: routeThreadRef2934 terminalOpen: activeThreadTerminalOpen,
2930 ? selectThreadTerminalUiState(
2931 useTerminalUiStateStore.getState().terminalUiStateByThreadKey,
2932 routeThreadRef,
2933 ).terminalOpen
2934 : false,
2935 modelPickerOpen,2935 modelPickerOpen,
2936 }),2936 }),
2937 [modelPickerOpen, routeThreadRef],2937 [activeThreadTerminalOpen, modelPickerOpen],
2938 );2938 );
2939 const newThreadShortcutLabelOptions = useMemo(2939 const newThreadShortcutLabelOptions = useMemo(
2940 () => ({2940 () => ({
@@ -3134,15 +3134,10 @@ export default function Sidebar() { · 193 unmodified lines
3134 const sidebarShortcutContext = useMemo(3134 const sidebarShortcutContext = useMemo(
3135 () => ({3135 () => ({
3136 terminalFocus: false,3136 terminalFocus: false,
3137 terminalOpen: routeThreadRef3137 terminalOpen: activeThreadTerminalOpen,
3138 ? selectThreadTerminalUiState(
3139 useTerminalUiStateStore.getState().terminalUiStateByThreadKey,
3140 routeThreadRef,
3141 ).terminalOpen
3142 : false,
3143 modelPickerOpen,3138 modelPickerOpen,
3144 }),3139 }),
3145 [modelPickerOpen, routeThreadRef],3140 [activeThreadTerminalOpen, modelPickerOpen],
3146 );3141 );
3147 const threadJumpLabelByKey = useMemo(3142 const threadJumpLabelByKey = useMemo(
3148 () =>3143 () =>