diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index f0188af478c0..17bb20d58340 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -3115,7 +3115,7 @@ function ChatViewContent(props: ChatViewProps) { gitCwd, storeNewTerminal, ]); - const closeTerminal = useCallback( + const closeTerminalSession = useCallback( (terminalId: string) => { if (!activeThreadId || !activeThreadRef) return; const fallbackExitWrite = () => @@ -3137,7 +3137,6 @@ function ChatViewContent(props: ChatViewProps) { } })(); storeCloseTerminal(activeThreadRef, terminalId); - setTerminalFocusRequestId((value) => value + 1); }, [ activeThreadId, @@ -3148,6 +3147,13 @@ function ChatViewContent(props: ChatViewProps) { writeTerminal, ], ); + const closeTerminal = useCallback( + (terminalId: string) => { + closeTerminalSession(terminalId); + setTerminalFocusRequestId((value) => value + 1); + }, + [closeTerminalSession], + ); const runProjectScript = useCallback( async ( script: ProjectScript, @@ -3623,17 +3629,12 @@ function ChatViewContent(props: ChatViewProps) { const closePanelTerminal = useCallback( (terminalId: string) => { if (!activeThreadRef || activeRightPanelSurface?.kind !== "terminal") return; - void closeTerminalMutation({ - environmentId: activeThreadRef.environmentId, - input: { threadId: activeThreadRef.threadId, terminalId, deleteHistory: true }, - }); - storeCloseTerminal(activeThreadRef, terminalId); + closeTerminal(terminalId); useRightPanelStore .getState() .closeTerminal(activeThreadRef, activeRightPanelSurface.id, terminalId); - setTerminalFocusRequestId((value) => value + 1); }, - [activeRightPanelSurface, activeThreadRef, closeTerminalMutation, storeCloseTerminal], + [activeRightPanelSurface, activeThreadRef, closeTerminal], ); const requestCloseTerminal = useCallback( (terminalId: string) => { @@ -3697,22 +3698,12 @@ function ChatViewContent(props: ChatViewProps) { } if (surface.kind === "terminal") { for (const terminalId of surface.terminalIds) { - storeCloseTerminal(activeThreadRef, terminalId); - void closeTerminalMutation({ - environmentId: activeThreadRef.environmentId, - input: { threadId: activeThreadRef.threadId, terminalId, deleteHistory: true }, - }); + closeTerminalSession(terminalId); } } } }, - [ - activeThreadRef, - activePreviewState.sessions, - closePreview, - closeTerminalMutation, - storeCloseTerminal, - ], + [activeThreadRef, activePreviewState.sessions, closePreview, closeTerminalSession], ); const syncActivePreviewSurface = useCallback(() => { if (!activeThreadRef) return;