From e6d645072817752553b610a6f53bf3e4ae586498 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 12 Feb 2026 21:18:54 -0800 Subject: [PATCH] Use terminal close API with exit fallback in ChatView - Call `api.terminal.close` when available when closing a terminal tab - Fall back to writing `exit\n` to preserve compatibility with older/uninitialized terminals --- apps/web/src/components/ChatView.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 7b1a85eaad97710ab48921ed1cd282705619909b..4b910be0b2787ea35707616d98ddb6f00d610f26 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -302,9 +302,15 @@ export default function ChatView() { const closeTerminal = useCallback( (terminalId: string) => { if (!activeThreadId || !api) return; - void api.terminal.write({ threadId: activeThreadId, terminalId, data: "exit\n" }).catch(() => { - // Ignore write errors so the UI can still close an uninitialized or already-exited terminal. - }); + const fallbackExitWrite = () => + api.terminal.write({ threadId: activeThreadId, terminalId, data: "exit\n" }).catch(() => { + // Ignore write errors so the UI can still close an uninitialized or already-exited terminal. + }); + if ("close" in api.terminal && typeof api.terminal.close === "function") { + void api.terminal.close({ threadId: activeThreadId, terminalId }).catch(() => fallbackExitWrite()); + } else { + void fallbackExitWrite(); + } dispatch({ type: "CLOSE_THREAD_TERMINAL", threadId: activeThreadId, -- 2.54.0