| ... | @@ -302,9 +302,15 @@ export default function ChatView() { | ... | @@ -302,9 +302,15 @@ export default function ChatView() { |
| 302 | const closeTerminal = useCallback( | 302 | const closeTerminal = useCallback( |
| 303 | (terminalId: string) => { | 303 | (terminalId: string) => { |
| 304 | if (!activeThreadId || !api) return; | 304 | if (!activeThreadId || !api) return; |
| 305 | void api.terminal.write({ threadId: activeThreadId, terminalId, data: "exit\n" }).catch(() => { | 305 | const fallbackExitWrite = () => |
| 306 | // Ignore write errors so the UI can still close an uninitialized or already-exited terminal. | 306 | api.terminal.write({ threadId: activeThreadId, terminalId, data: "exit\n" }).catch(() => { |
| 307 | }); | 307 | // Ignore write errors so the UI can still close an uninitialized or already-exited terminal. |
| | 308 | }); |
| | 309 | if ("close" in api.terminal && typeof api.terminal.close === "function") { |
| | 310 | void api.terminal.close({ threadId: activeThreadId, terminalId }).catch(() => fallbackExitWrite()); |
| | 311 | } else { |
| | 312 | void fallbackExitWrite(); |
| | 313 | } |
| 308 | dispatch({ | 314 | dispatch({ |
| 309 | type: "CLOSE_THREAD_TERMINAL", | 315 | type: "CLOSE_THREAD_TERMINAL", |
| 310 | threadId: activeThreadId, | 316 | threadId: activeThreadId, |