Repository navigation
fix(app): keep live terminals through transient connect failures - #52232
Merged
Merged
Conversation
opencode-agent
Bot
requested review from
Brendonovich and
Hona
as code owners
September 30, 2026 05:51
opencode-agent
Bot
force-pushed
the
terminal-retention
branch
from
October 7, 2026 09:23
44187c0 to
3ea9ec7
Compare
3 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
A failed PTY connect-token request was treated as a dead terminal, so the panel's
onConnectErrorpath 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 toterminal-input.spec.tson the shared mock workspace. The mock PTY socket gains aclose(code, reason)helper so tests can drop a live connection.The e2e mock now answers an unknown PTY with the server's real
PtyNotFoundErrorinstead of a genericMockNotFound. 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
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-panelsandmobile-sessionspecs (29 pass),gui-extensionsterminal unit tests,appandgui-extensionstypechecks, oxlint and prettier on changed files.typecheck:e2ereports the same 4 pre-existing errors asv2in 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.Servicekills 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)