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, 18:30 UTC
Clear terminal viewport before final close
Co-authored-by: codex <codex@users.noreply.github.com>
Julius Marminge committed
Feb 15, 2026 at 00:11 UTC
0be98ea9d1dfbfda750e71d783df1cb2524ec92d
1 file changed
+10
-4
apps/web/src/components/ChatView.tsx
+10
-4
@@ -314,14 +314,20 @@ export default function ChatView() {
314
const closeTerminal = useCallback(
315
(terminalId: string) => {
316
if (!activeThreadId || !api) return;
317
+ const isFinalTerminal = (activeThread?.terminalIds.length ?? 0) <= 1;
318
const fallbackExitWrite = () =>
319
api.terminal
320
.write({ threadId: activeThreadId, terminalId, data: "exit\n" })
321
.catch(() => undefined);
322
if ("close" in api.terminal && typeof api.terminal.close === "function") {
322
- void api.terminal
323
- .close({ threadId: activeThreadId, terminalId, deleteHistory: true })
324
- .catch(() => fallbackExitWrite());
323
+ void (async () => {
324
+ if (isFinalTerminal) {
325
+ await api.terminal
326
+ .clear({ threadId: activeThreadId, terminalId })
327
+ .catch(() => undefined);
328
+ }
329
+ await api.terminal.close({ threadId: activeThreadId, terminalId, deleteHistory: true });
330
+ })().catch(() => fallbackExitWrite());
331
} else {
332
void fallbackExitWrite();
333
}
@@ -332,7 +338,7 @@ export default function ChatView() {
338
});
339
setTerminalFocusRequestId((value) => value + 1);
340
},
335
- [activeThreadId, api, dispatch],
341
+ [activeThread?.terminalIds.length, activeThreadId, api, dispatch],
342
);
343
344
const handleRuntimeModeChange = async (mode: "approval-required" | "full-access") => {