authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-15 00:11:56-08:00
committergravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-15 00:11:56-08:00
log0be98ea9d1dfbfda750e71d783df1cb2524ec92d
tree5d442055c0229520eb190ecb1302e5412094e122
parent2cd92ae6f510f5b9b44175fad3f96cb872eb41c1

Clear terminal viewport before final close

Co-authored-by: codex <codex@users.noreply.github.com>

1 files changed, 10 insertions(+), 4 deletions(-)

apps/web/src/components/ChatView.tsx+10-4
......@@ -314,14 +314,20 @@ export default function ChatView() {
314314 const closeTerminal = useCallback(
315315 (terminalId: string) => {
316316 if (!activeThreadId || !api) return;
317 const isFinalTerminal = (activeThread?.terminalIds.length ?? 0) <= 1;
317318 const fallbackExitWrite = () =>
318319 api.terminal
319320 .write({ threadId: activeThreadId, terminalId, data: "exit\n" })
320321 .catch(() => undefined);
321322 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());
325331 } else {
326332 void fallbackExitWrite();
327333 }
......@@ -332,7 +338,7 @@ export default function ChatView() {
332338 });
333339 setTerminalFocusRequestId((value) => value + 1);
334340 },
335 [activeThreadId, api, dispatch],
341 [activeThread?.terminalIds.length, activeThreadId, api, dispatch],
336342 );
337343
338344 const handleRuntimeModeChange = async (mode: "approval-required" | "full-access") => {