| ... | @@ -262,24 +262,12 @@ export default function ChatView() { | ... | @@ -262,24 +262,12 @@ export default function ChatView() { |
| 262 | }, []); | 262 | }, []); |
| 263 | const toggleTerminalVisibility = useCallback(() => { | 263 | const toggleTerminalVisibility = useCallback(() => { |
| 264 | if (!activeThreadId) return; | 264 | if (!activeThreadId) return; |
| 265 | const isOpen = Boolean(activeThread?.terminalOpen); | | |
| 266 | | | |
| 267 | if (isOpen && api) { | | |
| 268 | if (typeof api.terminal.close === "function") { | | |
| 269 | void api.terminal.close({ threadId: activeThreadId }).catch(() => { | | |
| 270 | void api.terminal.write({ threadId: activeThreadId, data: "exit\n" }).catch(() => undefined); | | |
| 271 | }); | | |
| 272 | } else { | | |
| 273 | void api.terminal.write({ threadId: activeThreadId, data: "exit\n" }).catch(() => undefined); | | |
| 274 | } | | |
| 275 | } | | |
| 276 | | | |
| 277 | dispatch({ | 265 | dispatch({ |
| 278 | type: "SET_THREAD_TERMINAL_OPEN", | 266 | type: "SET_THREAD_TERMINAL_OPEN", |
| 279 | threadId: activeThreadId, | 267 | threadId: activeThreadId, |
| 280 | open: !isOpen, | 268 | open: !activeThread?.terminalOpen, |
| 281 | }); | 269 | }); |
| 282 | }, [activeThread?.terminalOpen, activeThreadId, api, dispatch]); | 270 | }, [activeThread?.terminalOpen, activeThreadId, dispatch]); |
| 283 | const splitTerminal = useCallback(() => { | 271 | const splitTerminal = useCallback(() => { |
| 284 | if (!activeThreadId) return; | 272 | if (!activeThreadId) return; |
| 285 | dispatch({ | 273 | dispatch({ |