Skip to content

Commit 93d0ac4

Browse files
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 parent 383f61c commit 93d0ac4

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,21 @@ export default function ChatView() {
303303
(terminalId: string) => {
304304
if (!activeThreadId || !api) return;
305305
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-
});
306+
api.terminal
307+
.write({ threadId: activeThreadId, terminalId, data: "exit\n" })
308+
.catch(() => undefined);
309+
const fallbackClearAndExit = () =>
310+
api.terminal
311+
.clear({ threadId: activeThreadId, terminalId })
312+
.catch(() => undefined)
313+
.then(() => fallbackExitWrite())
314+
.catch(() => undefined);
309315
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());
311319
} else {
312-
void fallbackExitWrite();
320+
void fallbackClearAndExit();
313321
}
314322
dispatch({
315323
type: "CLOSE_THREAD_TERMINAL",
@@ -1500,7 +1508,7 @@ export default function ChatView() {
15001508
key={activeThread.id}
15011509
api={api}
15021510
threadId={activeThread.id}
1503-
cwd={activeProject.cwd}
1511+
cwd={gitCwd ?? activeProject.cwd}
15041512
height={activeThread.terminalHeight}
15051513
terminalIds={activeThread.terminalIds}
15061514
activeTerminalId={activeThread.activeTerminalId}

0 commit comments

Comments
 (0)