From b26e2d192e6923cd2e46e863360fe3d1e78e5c34 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 12 Feb 2026 21:22:25 -0800 Subject: [PATCH] Clear terminal history on close and prefer git cwd - Pass `deleteHistory: true` when closing a terminal - Fallback path now clears terminal before sending `exit` - Use `gitCwd` as terminal cwd when available --- apps/web/src/components/ChatView.tsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 4b910be0b2787ea35707616d98ddb6f00d610f26..966d3eb4c28df0929eca606013f99566a8adc004 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -303,13 +303,21 @@ export default function ChatView() { (terminalId: string) => { if (!activeThreadId || !api) return; 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. - }); + api.terminal + .write({ threadId: activeThreadId, terminalId, data: "exit\n" }) + .catch(() => undefined); + const fallbackClearAndExit = () => + api.terminal + .clear({ threadId: activeThreadId, terminalId }) + .catch(() => undefined) + .then(() => fallbackExitWrite()) + .catch(() => undefined); if ("close" in api.terminal && typeof api.terminal.close === "function") { - void api.terminal.close({ threadId: activeThreadId, terminalId }).catch(() => fallbackExitWrite()); + void api.terminal + .close({ threadId: activeThreadId, terminalId, deleteHistory: true }) + .catch(() => fallbackClearAndExit()); } else { - void fallbackExitWrite(); + void fallbackClearAndExit(); } dispatch({ type: "CLOSE_THREAD_TERMINAL", @@ -1500,7 +1508,7 @@ export default function ChatView() { key={activeThread.id} api={api} threadId={activeThread.id} - cwd={activeProject.cwd} + cwd={gitCwd ?? activeProject.cwd} height={activeThread.terminalHeight} terminalIds={activeThread.terminalIds} activeTerminalId={activeThread.activeTerminalId} -- 2.54.0