From c0aed107dcc525fefac127164ae7d151e15ea016 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 16 Apr 2026 00:47:58 +0000 Subject: [PATCH] Fix missing terminal focus bump after close and clarify toggleOpen predicate - Add setTerminalFocusRequestId bump in closeTerminal for non-final tabs, matching the pattern used by splitTerminal and createNewTerminal. - Refactor toggleOpen to use a named 'next' variable so the predicate reads identically to setOpen, reducing maintenance hazard. --- apps/web/src/commandPaletteStore.ts | 8 ++++---- apps/web/src/components/ChatView.tsx | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/web/src/commandPaletteStore.ts b/apps/web/src/commandPaletteStore.ts index 9066e12213..f09be1e2ac 100644 --- a/apps/web/src/commandPaletteStore.ts +++ b/apps/web/src/commandPaletteStore.ts @@ -18,10 +18,10 @@ export const useCommandPaletteStore = create((set) => ({ workspaceTarget: null, setOpen: (open) => set({ open, ...(open ? {} : { workspaceTarget: null }) }), toggleOpen: () => - set((state) => ({ - open: !state.open, - ...(!state.open ? {} : { workspaceTarget: null }), - })), + set((state) => { + const next = !state.open; + return { open: next, ...(next ? {} : { workspaceTarget: null }) }; + }), openWorkspaceTarget: (target) => set({ open: true, workspaceTarget: target }), clearWorkspaceTarget: () => set({ workspaceTarget: null }), })); diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index e597e76dcc..829f154468 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -1371,6 +1371,9 @@ export default function ChatView(props: ChatViewProps) { if (activeThreadRef) { storeCloseTerminal(activeThreadRef, terminalId); } + if (!isFinalTerminal) { + setTerminalFocusRequestId((current) => current + 1); + } }, [ activeThreadId,