| ... | @@ -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} |