Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Clear terminal history on close and prefer git cwd

Julius Marmingeb26e2d192e69
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 4b910be0b..966d3eb4c 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}