diff --git a/packages/tui/src/component/terminal-pane.tsx b/packages/tui/src/component/terminal-pane.tsx index 74d79609446..51e4fe9fd11 100644 --- a/packages/tui/src/component/terminal-pane.tsx +++ b/packages/tui/src/component/terminal-pane.tsx @@ -46,6 +46,7 @@ export function TerminalPane(props: { let restored = false let wantsControl = false let disposed = false + let exited = false let size: TerminalSize | undefined let canonicalSize: TerminalSize | undefined let terminalSize: TerminalSize | undefined @@ -203,6 +204,10 @@ export function TerminalPane(props: { if (typeof event.data !== "string") return const message: unknown = JSON.parse(event.data) if (!message || typeof message !== "object" || !("type" in message)) return + if (message.type === "exited") { + exited = true + return + } if ( message.type === "resized" && "cols" in message && @@ -266,7 +271,8 @@ export function TerminalPane(props: { if (disposed) return const focused = terminal?.focused terminal = undefined - setFailure("Terminal disconnected") + // The removal event arrives separately; keep the terminal visible until then. + if (!exited) setFailure("Terminal disconnected") if (focused) props.onDisconnect?.() }) socket = next