Skip to content

fix(app): keep live terminals through transient connect failures - #52232

Merged
opencode-agent[bot] merged 2 commits into
v2from
terminal-retention
Oct 7, 2026
Merged

opencode-agent[bot] merged 2 commits into
v2from
terminal-retention

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What changed

A failed PTY connect-token request was treated as a dead terminal, so the panel's onConnectError path cloned it into a new PTY even when the server still owned the running one. Route connect failures through the existing bounded-backoff retry instead: it inspects the same PTY's status before deciding it is gone, then reconnects with its original ID. A PTY that is actually exited or missing still takes the existing failure path.

Rebased onto the built-in extensions refactor (#52369): the fix now lives in packages/gui-extensions/src/terminal/terminal.tsx, and the regression test moved to terminal-input.spec.ts on the shared mock workspace. The mock PTY socket gains a close(code, reason) helper so tests can drop a live connection.

The e2e mock now answers an unknown PTY with the server's real PtyNotFoundError instead of a generic MockNotFound. The WSL restart test depended on the old immediate clone-on-connect-failure; with this fix the status check must recognize the PTY as gone, which it only does for the real error tag.

Checks

  • New e2e regression: open a terminal, close its socket with 1011, return one 503 for the next connect ticket, then let the mock issue tickets again. Without the fix: the terminal is replaced by a new pty_2. With the fix: three ticket requests, a second socket to the same PTY ID, no rejected sockets, the original terminal DOM node, and only the one PTY create.
  • terminal-input, settings-wsl (including the WSL-restart terminal test), side-panels and mobile-session specs (29 pass), gui-extensions terminal unit tests, app and gui-extensions typechecks, oxlint and prettier on changed files. typecheck:e2e reports the same 4 pre-existing errors as v2 in unrelated files.

Persistence boundary

This protects a live backend PTY from a transient client connection failure. It does not keep the same process alive across a backend restart: Pty.Service kills its child PTYs and loses its in-memory map on shutdown, so that needs an independently owned PTY supervisor.

Requested by: @Brendonovich (Brendan via Slack)

@opencode-agent
opencode-agent Bot force-pushed the terminal-retention branch from 44187c0 to 3ea9ec7 Compare October 7, 2026 09:23
@opencode-agent
opencode-agent Bot merged commit 10b11ba into v2 Oct 7, 2026
11 checks passed
@opencode-agent
opencode-agent Bot deleted the terminal-retention branch October 7, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant