| ... | ... | @@ -262,24 +262,12 @@ export default function ChatView() { |
| 262 | 262 | }, []); |
| 263 | 263 | const toggleTerminalVisibility = useCallback(() => { |
| 264 | 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 | 265 | dispatch({ |
| 278 | 266 | type: "SET_THREAD_TERMINAL_OPEN", |
| 279 | 267 | threadId: activeThreadId, |
| 280 | | open: !isOpen, |
| 268 | open: !activeThread?.terminalOpen, |
| 281 | 269 | }); |
| 282 | | }, [activeThread?.terminalOpen, activeThreadId, api, dispatch]); |
| 270 | }, [activeThread?.terminalOpen, activeThreadId, dispatch]); |
| 283 | 271 | const splitTerminal = useCallback(() => { |
| 284 | 272 | if (!activeThreadId) return; |
| 285 | 273 | dispatch({ |