authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-12 21:22:25-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-02-12 21:24:49-08:00
logb26e2d192e6923cd2e46e863360fe3d1e78e5c34
tree883a910e96007ed9e29d14f2a4a0813b86ae6a96
parente6d645072817752553b610a6f53bf3e4ae586498

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

1 files changed, 14 insertions(+), 6 deletions(-)

apps/web/src/components/ChatView.tsx+14-6
...@@ -303,13 +303,21 @@ export default function ChatView() {...@@ -303,13 +303,21 @@ export default function ChatView() {
303 (terminalId: string) => {303 (terminalId: string) => {
304 if (!activeThreadId || !api) return;304 if (!activeThreadId || !api) return;
305 const fallbackExitWrite = () =>305 const fallbackExitWrite = () =>
306 api.terminal.write({ threadId: activeThreadId, terminalId, data: "exit\n" }).catch(() => {306 api.terminal
307 // Ignore write errors so the UI can still close an uninitialized or already-exited terminal.307 .write({ threadId: activeThreadId, terminalId, data: "exit\n" })
308 });308 .catch(() => undefined);
309 const fallbackClearAndExit = () =>
310 api.terminal
311 .clear({ threadId: activeThreadId, terminalId })
312 .catch(() => undefined)
313 .then(() => fallbackExitWrite())
314 .catch(() => undefined);
309 if ("close" in api.terminal && typeof api.terminal.close === "function") {315 if ("close" in api.terminal && typeof api.terminal.close === "function") {
310 void api.terminal.close({ threadId: activeThreadId, terminalId }).catch(() => fallbackExitWrite());316 void api.terminal
317 .close({ threadId: activeThreadId, terminalId, deleteHistory: true })
318 .catch(() => fallbackClearAndExit());
311 } else {319 } else {
312 void fallbackExitWrite();320 void fallbackClearAndExit();
313 }321 }
314 dispatch({322 dispatch({
315 type: "CLOSE_THREAD_TERMINAL",323 type: "CLOSE_THREAD_TERMINAL",
...@@ -1500,7 +1508,7 @@ export default function ChatView() {...@@ -1500,7 +1508,7 @@ export default function ChatView() {
1500 key={activeThread.id}1508 key={activeThread.id}
1501 api={api}1509 api={api}
1502 threadId={activeThread.id}1510 threadId={activeThread.id}
1503 cwd={activeProject.cwd}1511 cwd={gitCwd ?? activeProject.cwd}
1504 height={activeThread.terminalHeight}1512 height={activeThread.terminalHeight}
1505 terminalIds={activeThread.terminalIds}1513 terminalIds={activeThread.terminalIds}
1506 activeTerminalId={activeThread.activeTerminalId}1514 activeTerminalId={activeThread.activeTerminalId}