The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 19:45 UTC
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
Julius Marminge committed
Feb 12, 2026 at 21:18 UTC
e6d645072817752553b610a6f53bf3e4ae586498
1 file changed
+9
-3
apps/web/src/components/ChatView.tsx
+9
-3
@@ -302,9 +302,15 @@ export default function ChatView() {
302
const closeTerminal = useCallback(
303
(terminalId: string) => {
304
if (!activeThreadId || !api) return;
305
- void api.terminal.write({ threadId: activeThreadId, terminalId, data: "exit\n" }).catch(() => {
306
- // Ignore write errors so the UI can still close an uninitialized or already-exited terminal.
307
- });
305
+ const fallbackExitWrite = () =>
306
+ api.terminal.write({ threadId: activeThreadId, terminalId, data: "exit\n" }).catch(() => {
307
+ // Ignore write errors so the UI can still close an uninitialized or already-exited terminal.
308
+ });
309
+ if ("close" in api.terminal && typeof api.terminal.close === "function") {
310
+ void api.terminal.close({ threadId: activeThreadId, terminalId }).catch(() => fallbackExitWrite());
311
+ } else {
312
+ void fallbackExitWrite();
313
+ }
314
dispatch({
315
type: "CLOSE_THREAD_TERMINAL",
316
threadId: activeThreadId,