diff --git a/packages/web/server/mux-websocket.ts b/packages/web/server/mux-websocket.ts index 217d95a55..a07034f88 100644 --- a/packages/web/server/mux-websocket.ts +++ b/packages/web/server/mux-websocket.ts @@ -367,8 +367,12 @@ class TerminalManager { // Return unsubscribe function return () => { terminal.subscribers.delete(callback); - // If no subscribers left and PTY is not attached, remove terminal from map - if (terminal.subscribers.size === 0 && !terminal.pty) { + // Kill PTY and clean up when the last subscriber leaves + if (terminal.subscribers.size === 0) { + if (terminal.pty) { + terminal.pty.kill(); + terminal.pty = null; + } this.terminals.delete(id); } }; diff --git a/packages/web/src/components/DirectTerminal.tsx b/packages/web/src/components/DirectTerminal.tsx index 1fdae977f..ccb5e5fb0 100644 --- a/packages/web/src/components/DirectTerminal.tsx +++ b/packages/web/src/components/DirectTerminal.tsx @@ -344,9 +344,6 @@ export function DirectTerminal({ } }); - // Update mux status - setStatus(muxStatus === "connected" ? "connected" : "connecting"); - // Handle window resize const handleResize = () => { if (fit) { @@ -533,7 +530,7 @@ export function DirectTerminal({ {isOpenCodeSession ? (