mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
fix(tui): avoid disconnection error on terminal exit (#47272)
Co-authored-by: nexxeln <95541290+nexxeln@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
5045b3ce18
commit
7ad705225e
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user