fix(tui): avoid disconnection error on terminal exit (#47272)

Co-authored-by: nexxeln <95541290+nexxeln@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot]
2026-09-05 14:35:40 +05:30
committed by GitHub
Unverified
parent 5045b3ce18
commit 7ad705225e
+7 -1
View File
@@ -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