Repository navigation
fix(remote-runtime): keep a remote outage from flooding the error surface and dead-ending the pane - #12650
Conversation
…face and dead-ending the pane A remote-runtime outage (laptop sleep, Tailscale drop) piled dozens of repeated timeout errors into one ever-growing red surface, and the affected terminal then took no input once connectivity returned — the only escape was closing the session and resuming it in a new one. Four causes: - Errors accumulated with no de-duplication or cap, so one outage produced one toast per failed call. The transport now suppresses a repeat of the message it last surfaced, and clears that memory on reconnect, on connect/attach, and when the user dismisses the surface (notifyErrorSurfaceDismissed) — an identical fatal error recurring later is new information, not noise. - Queue-overload rejections lose their structured code crossing Electron IPC, so they were never classified as recoverable and were surfaced raw. Classification now matches the queue-overload code and its message fragment, and the transport routes them to the capacity-pressure retry. - A transient failure misclassified as fatal called recovery.cancel(), which puts the pane in an idle phase: the Reconnect banner unmounts and manual retry, online and resume triggers all become no-ops. Those paths now use markDisconnected() so the pane stays revivable. - Dedup compared single lines against a newline-joined surface, so a multi-line message never matched itself and stacked without bound. appendTerminalErrorMessage compares whole line runs instead. Fatal resubscribe failures stay routed through handleRemoteTerminalError, which owns stale-handle re-resolution, terminal-gone retirement, SSH-expired recovery and oversized-snapshot suppression — bypassing it to surface the message directly would drop all four. The ordinary reconnect loop was already fixed in v1.4.150/160; this is what remained after it.
📝 WalkthroughWalkthroughThe change adds recoverable classification for remote runtime RPC queue overloads. Remote PTY transports now deduplicate fatal errors, preserve recovery states, handle resubscription failures, and reset error suppression after recovery or dismissal. Terminal panes accumulate distinct error lines and notify transports when the error surface closes. New tests cover error accumulation, dismissal, outage handling, reconnects, resubscription routing, and terminal creation recovery. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts (1)
778-787: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMerge the two host-handle failure branches.
Line 778 already returns for
hostHandle === null. The!hostHandletest on Line 782 therefore only adds thefalsecase, and both branches emit the same message. Collapse them so the reachable cases stay obvious.♻️ Proposed simplification
- if (hostHandle === null) { - surfaceErrorMessage('Remote terminal was closed.') - return undefined - } - if (!hostHandle || !isCurrent()) { + if (!hostHandle || !isCurrent()) { if (isCurrent()) { surfaceErrorMessage('Remote terminal was closed.') } return undefined }src/renderer/src/components/terminal-pane/TerminalPane.tsx (1)
477-477: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winConsider routing the other error writers through the same accumulator.
PTY errors now append to
terminalError. The paste paths still replace it (setTerminalError(formatTerminalPasteExecutionError(...))and the'Paste failed.'writers). A paste failure therefore discards every accumulated PTY error line that the user has not dismissed. Route those writers throughappendTerminalErrorMessageso one surface has one accumulation rule.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1f2defe4-2c29-40ba-a3a4-3ba1d264633b
📒 Files selected for processing (11)
src/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/remote-runtime-error-surface-dismissal.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-outage-toast-flood-and-stuck-reconnect.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.tssrc/renderer/src/components/terminal-pane/remote-runtime-resubscribe-failure-recovery-routing.test.tssrc/renderer/src/components/terminal-pane/terminal-error-accumulation.test.tssrc/renderer/src/components/terminal-pane/terminal-error-accumulation.tssrc/shared/remote-runtime-client-error-classification.test.tssrc/shared/remote-runtime-client-error-classification.ts
…ent (#12676) Since #12667, a present error code short-circuits classification: a code that is genuinely transient but missing from `RECOVERABLE_CODES` classifies as FATAL. That is the shape that dead-ends terminal panes — #12650 fixed exactly that for a different error, where a transient failure misclassified as fatal unmounted the Reconnect banner and left recreating the session as the only escape. Today the code and fragment sets agree. Nothing prevented a future code from being added without a matching entry, and the failure would have been silent. This pins that agreement: for every reachable transport error, a code that classifies fatal must not carry a message that would have classified recoverable. 57 coded pairs plus 8 code-less ones, derived by invoking the producers where possible so a reworded message updates the corpus instead of leaving a stale copy silently passing. The failure message names the offending fragment and says what to do about it. Enumeration turned up producers beyond the obvious ones — notably the Tailscale-hinted variants, where `runtime-environment-transport-routing.ts` mutates the message on an already-coded error before it crosses IPC, making those distinct corpus members. Also documented (not asserted, because it is unreachable today): `runtime_rpc_queue_overloaded` is absent from both host passthrough allowlists, so if it ever crossed `mapRuntimeError` it would flatten to `runtime_error` while keeping its "queue is full" message — precisely the dangerous shape. The queue pool is never instantiated on the server dispatcher, so it cannot happen now. The known exception is pinned rather than silently exempted: a dedicated test records WHY the guard cannot see `remote_runtime_busy` (fatal by code, matching no fragment, so the two sides have nothing to disagree about). If someone rewords a busy message into connection wording, that test fails and points at STA-3479. Proven non-vacuous by four separate injections. The only production change is two `const` to `export const`.
After stablyai#12650, thinner connect paths (e.g. HUB-native resolve timeouts) latched disconnected without scheduling a retry, and retryRecovery only re-entered create for a narrow flag set. Schedule bounded connect recovery for recoverable connect failures, re-enter create from Reconnect whenever lastConnectOptions is present, and stop pre-idempotency create by returning null instead of rethrowing a recoverable timeout that would restart connect. Closes stablyai#12684
The connect bound's new wording dropped out of the two gates that classify remote-transport failures by message text, and those gates are the only ones that run on the path the bound made reachable. `subscribeRemoteRuntimeTransport` reports a connect failure by *rejecting* the subscribe promise, and that rejection crosses `ipcMain.handle`, which keeps only the message. The renderer then classifies it with `RECOVERABLE_MESSAGE_FRAGMENTS`. `Could not reach the remote Orca runtime at …` matched no fragment, so it read as fatal: `recovery.cancel()` and a red banner instead of a retry. Before the bound existed this case reached the 15s subscription-start timer, whose message did match a fragment, so introducing a 12s bound turned an auto-recovering pane into a dead-ended one — the #12650 shape. The same wording also fell outside `REMOTE_RUNTIME_UNREACHABLE_RE`, so the Tailscale remedy was dropped for precisely the unreachable-host failure it exists for. Keep the canonical phrase both gates already recognise rather than teaching each gate a second synonym for one condition, and pin it: the phrase is now a named constant, the corpus in `remote-runtime-transport-error-agreement.test.ts` grows the coded, hinted and code-stripped producers derived from the real helper, and a new subscribe-path test proves the connect bound (not the start timer) is what fires and that its message still classifies as recoverable once the code is gone. Verdict wording is unchanged: `unverifiable`, never a synonym for exited. Also states the bound in seconds, corrects the module comment (`handshakeTimeout` is a socket inactivity timer, so a slow-but-answering host is not cut off), and splits the subscription contract types out to stay under `max-lines`.
… the transport (#20053) * fix(runtime): bound the remote-runtime connect against an unreachable host A host that is powered off or firewalled black-holes the TCP SYN, so the remote-runtime WebSocket neither opens nor errors. The Node-side transports set no connect bound, leaving the caller's whole-request timeout as the only one: every `orca <cmd> --environment <unreachable>` sat silent for 60s before failing with a generic `runtime_timeout`. Measured on an unreachable paired host (win-lowspec, SYNs dropped): terminal list / worktree list / repo list / status each took 60.19-60.26s; the same command against a reachable host answered in 0.24s. So this was the shared transport, not one command. Pass `handshakeTimeout` at the three shared remote-runtime WebSocket construction sites, which `ws` applies across TCP connect and the HTTP upgrade. The value matches the bound the browser transport already used. The failure keeps code `remote_runtime_unavailable` so the existing transport-loss classification in terminal-process-inspection still applies, and the message names the endpoint and stops at "unverifiable" — per docs/reference/ssh-execution-boundary.md, loss of contact is never evidence that the host's work stopped. * fix(relay): bound the control socket's connect phase at the transport The relay control socket was constructed with no `handshakeTimeout`, the same gap fixed for the remote-runtime transports. It was not a live defect: the class-level `connectDeadlineMs` (15s) also covers a stalled connect, and that deadline does fire — its `unref()` is safe because the pending TCP connect is itself a ref'd libuv handle that holds the event loop open. Measured in a bare Node process: unref'd timer with an empty loop never fires (exit at 0ms), but the same timer alongside a black-holed connect fired at 2003ms. It was a defect waiting on a refactor. The two bounds cover different phases, and the class deadline covers the connect phase only incidentally. DO NOT REMOVE EITHER BOUND AS REDUNDANT. They are not. Proven by mutation: - Remove the transport bound -> a stalled *connect* falls through to the class deadline, rejecting with `relay_control_connect_timeout` after the full deadline instead of the transport error. - Remove the class deadline -> a stall during the *proving* phase (socket open, host proof never answered) is unbounded; the incumbent test hangs 30s. `handshakeTimeout` cannot see that phase at all. Reuses `remoteRuntimeConnectOptions` rather than forking a second helper, and moves the construction into `relay-control-socket-factory.ts` so a caller that needs a relay control socket gets the bound instead of re-deriving an unbounded one. `handshakeTimeoutMs` is settable apart from `connectDeadlineMs` so a test can stall the connect alone and assert which bound produced the rejection — error identity, not elapsed time. The connect-bound ratchet now covers the relay site and asserts the site still resolves, so an allowlist that silently stopped matching cannot pass vacuously. * fix(lint): carry SAFETY rationales for the connect-bound casts main tightened typescript/consistent-type-assertions to assertionStyle: never, which the rebase brings onto these added lines. Dropping the generic default is not typeable, so each cast keeps its own rationale. * fix(runtime): keep the bounded connect failure inside both message gates The connect bound's new wording dropped out of the two gates that classify remote-transport failures by message text, and those gates are the only ones that run on the path the bound made reachable. `subscribeRemoteRuntimeTransport` reports a connect failure by *rejecting* the subscribe promise, and that rejection crosses `ipcMain.handle`, which keeps only the message. The renderer then classifies it with `RECOVERABLE_MESSAGE_FRAGMENTS`. `Could not reach the remote Orca runtime at …` matched no fragment, so it read as fatal: `recovery.cancel()` and a red banner instead of a retry. Before the bound existed this case reached the 15s subscription-start timer, whose message did match a fragment, so introducing a 12s bound turned an auto-recovering pane into a dead-ended one — the #12650 shape. The same wording also fell outside `REMOTE_RUNTIME_UNREACHABLE_RE`, so the Tailscale remedy was dropped for precisely the unreachable-host failure it exists for. Keep the canonical phrase both gates already recognise rather than teaching each gate a second synonym for one condition, and pin it: the phrase is now a named constant, the corpus in `remote-runtime-transport-error-agreement.test.ts` grows the coded, hinted and code-stripped producers derived from the real helper, and a new subscribe-path test proves the connect bound (not the start timer) is what fires and that its message still classifies as recoverable once the code is gone. Verdict wording is unchanged: `unverifiable`, never a synonym for exited. Also states the bound in seconds, corrects the module comment (`handshakeTimeout` is a socket inactivity timer, so a slow-but-answering host is not cut off), and splits the subscription contract types out to stay under `max-lines`. * fix(relay): drop the duplicate connect bound on the control socket The claim that `connectDeadlineMs` cannot see a black-holed connect is false. `RelayControlClient.connect()` constructs the socket and arms `connectTimer` in the same synchronous call — `new WebSocket()` never blocks — and `expireConnect` fires from `opening` as well as `proving`. The class deadline was already a strict superset of a transport `handshakeTimeout` on that socket. It was also inert. Production passes neither option, so the transport bound was derived from `connectDeadlineMs` and both timers were 15_000, armed in the same tick; the ws timer is an inactivity timer armed on the later `socket` event, so it could not win. Its only reachable effect was changing which string a stalled relay connect rejects with, and it narrowed an existing test's 20ms deadline into a handshake bound it could race. So this removes the factory, the test-only `handshakeTimeoutMs` option and the source-grep test whose premise was wrong, and replaces them with a test that holds the real ground: a connect whose upgrade is never answered expires on the class deadline. Moving the timer arm after `open`, or narrowing `expireConnect` to `proving`, both turn it red — which is what a future reader needs before concluding the phase is uncovered and adding a second bound again. No behaviour change for a reachable relay, and none for the verdict: a stalled connect still rejects and still reaches `unverifiable`, never `exited`. * fix(runtime): stop the endpoint in the failure message from undoing the fix Putting the endpoint into the message created three problems the message itself caused. The Tailscale hint is idempotent by testing whether "tailscale" already appears anywhere in the message. That held while the message was fixed copy. Now a host called `tailscale-box` puts the word there itself, and the hint — the only actionable remedy on an unreachable host — is suppressed for it. Key the guard on the two hints instead of the word. The endpoint comes from a pasted pairing code, which is only length-capped; `normalizePairingUrl` rejects userinfo but nothing re-validates a stored offer. Render scheme, host and port only, so a pasted `wss://user:secret@host` cannot reach a surface the user reads. And drop the elapsed time from the wording. `handshakeTimeout` is a socket inactivity timer, so a `wss://` host that completes TCP and then goes silent re-arms it once and fails at about twice the bound; measured at 2008ms against a 1000ms bound. "within 12s" would have been wrong there, and the endpoint is the actionable part regardless. Also refuse a non-positive or non-finite bound: `ws` and `net` both gate on a truthy timeout, so `0` left the connect completely unbounded while still satisfying the connect-bound ratchet. * fix(runtime): keep the endpoint from smuggling a verdict into the message `isRemoteTerminalGoneMessage` in the pty transport substring-matches `terminal_gone` / `terminal_exited` / `no_connected_pty`, and it runs before the recoverable-connection gate: a match retires the pane's terminal id and cancels recovery. WHATWG URL accepts `_` in a special-scheme host, so once the failure message carried the endpoint, `ws://terminal_gone.example:6768` turned loss of contact into a terminal-gone verdict — the one conclusion `docs/reference/ssh-execution-boundary.md` forbids. Render the host only when it matches a hostname or IP-literal grammar that cannot carry such a token, and fall back to naming no endpoint at all. A well-formed host, including a bracketed IPv6 literal, is still shown. * docs(runtime): say why this connect bound is not the relay's removed duplicate
… the transport (stablyai#20053) * fix(runtime): bound the remote-runtime connect against an unreachable host A host that is powered off or firewalled black-holes the TCP SYN, so the remote-runtime WebSocket neither opens nor errors. The Node-side transports set no connect bound, leaving the caller's whole-request timeout as the only one: every `orca <cmd> --environment <unreachable>` sat silent for 60s before failing with a generic `runtime_timeout`. Measured on an unreachable paired host (win-lowspec, SYNs dropped): terminal list / worktree list / repo list / status each took 60.19-60.26s; the same command against a reachable host answered in 0.24s. So this was the shared transport, not one command. Pass `handshakeTimeout` at the three shared remote-runtime WebSocket construction sites, which `ws` applies across TCP connect and the HTTP upgrade. The value matches the bound the browser transport already used. The failure keeps code `remote_runtime_unavailable` so the existing transport-loss classification in terminal-process-inspection still applies, and the message names the endpoint and stops at "unverifiable" — per docs/reference/ssh-execution-boundary.md, loss of contact is never evidence that the host's work stopped. * fix(relay): bound the control socket's connect phase at the transport The relay control socket was constructed with no `handshakeTimeout`, the same gap fixed for the remote-runtime transports. It was not a live defect: the class-level `connectDeadlineMs` (15s) also covers a stalled connect, and that deadline does fire — its `unref()` is safe because the pending TCP connect is itself a ref'd libuv handle that holds the event loop open. Measured in a bare Node process: unref'd timer with an empty loop never fires (exit at 0ms), but the same timer alongside a black-holed connect fired at 2003ms. It was a defect waiting on a refactor. The two bounds cover different phases, and the class deadline covers the connect phase only incidentally. DO NOT REMOVE EITHER BOUND AS REDUNDANT. They are not. Proven by mutation: - Remove the transport bound -> a stalled *connect* falls through to the class deadline, rejecting with `relay_control_connect_timeout` after the full deadline instead of the transport error. - Remove the class deadline -> a stall during the *proving* phase (socket open, host proof never answered) is unbounded; the incumbent test hangs 30s. `handshakeTimeout` cannot see that phase at all. Reuses `remoteRuntimeConnectOptions` rather than forking a second helper, and moves the construction into `relay-control-socket-factory.ts` so a caller that needs a relay control socket gets the bound instead of re-deriving an unbounded one. `handshakeTimeoutMs` is settable apart from `connectDeadlineMs` so a test can stall the connect alone and assert which bound produced the rejection — error identity, not elapsed time. The connect-bound ratchet now covers the relay site and asserts the site still resolves, so an allowlist that silently stopped matching cannot pass vacuously. * fix(lint): carry SAFETY rationales for the connect-bound casts main tightened typescript/consistent-type-assertions to assertionStyle: never, which the rebase brings onto these added lines. Dropping the generic default is not typeable, so each cast keeps its own rationale. * fix(runtime): keep the bounded connect failure inside both message gates The connect bound's new wording dropped out of the two gates that classify remote-transport failures by message text, and those gates are the only ones that run on the path the bound made reachable. `subscribeRemoteRuntimeTransport` reports a connect failure by *rejecting* the subscribe promise, and that rejection crosses `ipcMain.handle`, which keeps only the message. The renderer then classifies it with `RECOVERABLE_MESSAGE_FRAGMENTS`. `Could not reach the remote Orca runtime at …` matched no fragment, so it read as fatal: `recovery.cancel()` and a red banner instead of a retry. Before the bound existed this case reached the 15s subscription-start timer, whose message did match a fragment, so introducing a 12s bound turned an auto-recovering pane into a dead-ended one — the stablyai#12650 shape. The same wording also fell outside `REMOTE_RUNTIME_UNREACHABLE_RE`, so the Tailscale remedy was dropped for precisely the unreachable-host failure it exists for. Keep the canonical phrase both gates already recognise rather than teaching each gate a second synonym for one condition, and pin it: the phrase is now a named constant, the corpus in `remote-runtime-transport-error-agreement.test.ts` grows the coded, hinted and code-stripped producers derived from the real helper, and a new subscribe-path test proves the connect bound (not the start timer) is what fires and that its message still classifies as recoverable once the code is gone. Verdict wording is unchanged: `unverifiable`, never a synonym for exited. Also states the bound in seconds, corrects the module comment (`handshakeTimeout` is a socket inactivity timer, so a slow-but-answering host is not cut off), and splits the subscription contract types out to stay under `max-lines`. * fix(relay): drop the duplicate connect bound on the control socket The claim that `connectDeadlineMs` cannot see a black-holed connect is false. `RelayControlClient.connect()` constructs the socket and arms `connectTimer` in the same synchronous call — `new WebSocket()` never blocks — and `expireConnect` fires from `opening` as well as `proving`. The class deadline was already a strict superset of a transport `handshakeTimeout` on that socket. It was also inert. Production passes neither option, so the transport bound was derived from `connectDeadlineMs` and both timers were 15_000, armed in the same tick; the ws timer is an inactivity timer armed on the later `socket` event, so it could not win. Its only reachable effect was changing which string a stalled relay connect rejects with, and it narrowed an existing test's 20ms deadline into a handshake bound it could race. So this removes the factory, the test-only `handshakeTimeoutMs` option and the source-grep test whose premise was wrong, and replaces them with a test that holds the real ground: a connect whose upgrade is never answered expires on the class deadline. Moving the timer arm after `open`, or narrowing `expireConnect` to `proving`, both turn it red — which is what a future reader needs before concluding the phase is uncovered and adding a second bound again. No behaviour change for a reachable relay, and none for the verdict: a stalled connect still rejects and still reaches `unverifiable`, never `exited`. * fix(runtime): stop the endpoint in the failure message from undoing the fix Putting the endpoint into the message created three problems the message itself caused. The Tailscale hint is idempotent by testing whether "tailscale" already appears anywhere in the message. That held while the message was fixed copy. Now a host called `tailscale-box` puts the word there itself, and the hint — the only actionable remedy on an unreachable host — is suppressed for it. Key the guard on the two hints instead of the word. The endpoint comes from a pasted pairing code, which is only length-capped; `normalizePairingUrl` rejects userinfo but nothing re-validates a stored offer. Render scheme, host and port only, so a pasted `wss://user:secret@host` cannot reach a surface the user reads. And drop the elapsed time from the wording. `handshakeTimeout` is a socket inactivity timer, so a `wss://` host that completes TCP and then goes silent re-arms it once and fails at about twice the bound; measured at 2008ms against a 1000ms bound. "within 12s" would have been wrong there, and the endpoint is the actionable part regardless. Also refuse a non-positive or non-finite bound: `ws` and `net` both gate on a truthy timeout, so `0` left the connect completely unbounded while still satisfying the connect-bound ratchet. * fix(runtime): keep the endpoint from smuggling a verdict into the message `isRemoteTerminalGoneMessage` in the pty transport substring-matches `terminal_gone` / `terminal_exited` / `no_connected_pty`, and it runs before the recoverable-connection gate: a match retires the pane's terminal id and cancels recovery. WHATWG URL accepts `_` in a special-scheme host, so once the failure message carried the endpoint, `ws://terminal_gone.example:6768` turned loss of contact into a terminal-gone verdict — the one conclusion `docs/reference/ssh-execution-boundary.md` forbids. Render the host only when it matches a hostname or IP-literal grammar that cannot carry such a token, and fall back to naming no endpoint at all. A well-formed host, including a bracketed IPv6 literal, is still shown. * docs(runtime): say why this connect bound is not the relay's removed duplicate
…face and dead-ending the pane (stablyai#12650) When a remote runtime went unreachable (laptop sleep, Tailscale drop), the UI filled with dozens of repeated timeout errors until it was nearly unusable, and the affected terminal then accepted no input after connectivity returned — leaving "close the session and resume it in a new one" as the only escape. Four causes, three of which were still live: - Errors accumulated into one ever-growing surface with no de-duplication or cap. - Queue-overload rejections lose their structured error code crossing the IPC boundary, so they were never classified as recoverable and surfaced raw. - A transient failure misclassified as fatal called `recovery.cancel()`, setting the pane to an idle phase — which unmounts the Reconnect banner and makes manual retry, online and resume triggers all no-ops. A true dead end, and the reason recreating the session was the only way out. - Dismissing an error cleared the surface but not the dedup memory, so an identical fatal error recurring in the same outage was suppressed forever while the pane looked healthy; dedup also compared single lines, so multi-line errors never matched and stacked without bound. The ordinary reconnect loop was already fixed in v1.4.150/160 — bounded backoff, a Reconnect banner and auto-recovery already ship. This fixes what remained. Note the fix routes fatal resubscribe failures back through the shared terminal error handler: bypassing it had silently dropped stale-handle re-resolution, terminal-gone retirement, SSH-expired recovery and oversized-snapshot suppression — a stuck-pane regression inside the stuck-pane fix, caught in review and covered by 6 dedicated tests. Verified: reproductions red on main before the fix; after rebasing onto stablyai#11542, reverting the dead-end fix still turns its test red. Follow-up STA-3456 tracks preserving typed error codes across the IPC boundary so classification stops matching message text.
…ent (stablyai#12676) Since stablyai#12667, a present error code short-circuits classification: a code that is genuinely transient but missing from `RECOVERABLE_CODES` classifies as FATAL. That is the shape that dead-ends terminal panes — stablyai#12650 fixed exactly that for a different error, where a transient failure misclassified as fatal unmounted the Reconnect banner and left recreating the session as the only escape. Today the code and fragment sets agree. Nothing prevented a future code from being added without a matching entry, and the failure would have been silent. This pins that agreement: for every reachable transport error, a code that classifies fatal must not carry a message that would have classified recoverable. 57 coded pairs plus 8 code-less ones, derived by invoking the producers where possible so a reworded message updates the corpus instead of leaving a stale copy silently passing. The failure message names the offending fragment and says what to do about it. Enumeration turned up producers beyond the obvious ones — notably the Tailscale-hinted variants, where `runtime-environment-transport-routing.ts` mutates the message on an already-coded error before it crosses IPC, making those distinct corpus members. Also documented (not asserted, because it is unreachable today): `runtime_rpc_queue_overloaded` is absent from both host passthrough allowlists, so if it ever crossed `mapRuntimeError` it would flatten to `runtime_error` while keeping its "queue is full" message — precisely the dangerous shape. The queue pool is never instantiated on the server dispatcher, so it cannot happen now. The known exception is pinned rather than silently exempted: a dedicated test records WHY the guard cannot see `remote_runtime_busy` (fatal by code, matching no fragment, so the two sides have nothing to disagree about). If someone rewords a busy message into connection wording, that test fails and points at STA-3479. Proven non-vacuous by four separate injections. The only production change is two `const` to `export const`.
Symptom
When the remote runtime goes away — laptop sleep, a Tailscale drop, a host restart — the UI fills with dozens of repeated timeout errors in one ever-growing red block until it is nearly unusable. Worse, once connectivity comes back the affected terminal accepts no input at all. There is no working Reconnect button, and neither coming back online nor resuming from sleep revives it. The only escape reported by users is to close the session and resume it in a new one.
Not the ordinary reconnect loop. That was already fixed in v1.4.150/160: a Reconnect banner, bounded backoff and automatic recovery all ship today. This PR fixes what was left over once those landed.
The four causes
1. No de-duplication or cap on the error surface. Every pane error is appended to a single newline-joined string. During an outage the same call fails over and over, so the same message was appended over and over, and the red surface grew until it swallowed the pane.
2. Queue-overload rejections were misclassified as fatal. When the remote call queue fills up, the runtime rejects with a structured
runtime_rpc_queue_overloadedcode. That code does not survive the Electron IPC boundary — structured clone keeps onlyname/message/stack— so the renderer saw a bareErrorwith nocode, failed to recognise it as recoverable, and surfaced the raw text instead of retrying.3. The dead end: a transient failure treated as fatal called
recovery.cancel().cancel()puts the pane into an idle recovery phase, which is the state a healthy pane sits in. That unmounts the Reconnect banner and makes manual retry, theonlinetrigger and the system-resume trigger all no-ops. This is the actual reason recreating the session was the only way out: the pane looked settled while being permanently unreachable.4. Dismissing an error cleared the surface but not the dedup memory. Once an error had been surfaced and dismissed, an identical fatal error recurring in the same outage was suppressed forever, so the pane looked healthy while being dead. Separately, dedup compared single lines against the joined surface, so a multi-line message could never match itself and stacked without bound — which defeated cause 1 for exactly the errors that are longest.
What changed
remote-runtime-client-error-classification.ts— recognises the queue-overload code and its message fragment (remote runtime call queue is full) as recoverable, exported asisRuntimeRpcQueueOverloadError. Matching on message text is a workaround for the IPC boundary dropping the code; see the follow-up below.remote-runtime-pty-transport.ts—surfaceErrorMessage()replaces directstoredCallbacks.onError?.()calls; it drops a message identical to the one it last surfaced.markRecoveryHealthy()clears that memory on successful (re)connect, andconnect/attachclear it too, so a later outage starts fresh.recovery.markDisconnected()instead ofrecovery.cancel()for non-fatal failures, so the pane stays revivable and the Reconnect banner stays mounted.handleRemoteTerminalError, which owns stale-handle re-resolution, terminal-gone retirement, SSH-expired recovery and oversized-snapshot suppression. Surfacing the message directly from that branch would silently drop all four — a stuck-pane regression hiding inside the stuck-pane fix.remote-runtime-resubscribe-failure-recovery-routing.test.tslocks this down with 6 cases.notifyErrorSurfaceDismissed()releases the repeat-suppression memory.terminal-error-accumulation.ts(new) —appendTerminalErrorMessagecompares whole line runs rather than single lines, so a multi-line message matches itself. The surface stays one newline-joined string becauseTerminalErrorToast's per-line filters depend on that shape.TerminalPane.tsx— usesappendTerminalErrorMessage, and dismissal now notifies every pane transport so the next occurrence of the same error surfaces again.Verification
All tests run against this branch on top of current
main.remote-runtime-outage-toast-flood-and-stuck-reconnect.test.tsremote-runtime-resubscribe-failure-recovery-routing.test.tsremote-runtime-error-surface-dismissal.test.tsterminal-error-accumulation.test.tsremote-runtime-pty-transport.test.tsremote-runtime-pty-recovery-state.test.tsremote-runtime-client-error-classification.test.tspty-connection.test.ts)pnpm run typecheckclean; repo-wideoxlintclean;oxfmt --checkclean on all changed files.The tests are real oracles, not tautologies. Each fix was reverted in place and the corresponding suite confirmed to fail, then restored:
recovery.markDisconnected()back torecovery.cancel()in the resubscribe catch: the dead-end case fails with "pane must remain revivable after a fatal resubscribe error" (1 failed / 3 passed). Restored: 4 passed.handleRemoteTerminalError): all 6 routing cases fail. Restored: 6 passed.The repro test injects faults at
window.api.runtimeEnvironments.call— the exact Electron IPC boundary the remote PTY transport uses — with rejections shaped the way the renderer really sees them (anError invoking remote method ...message prefix and nocodeproperty), so it exercises the message-fragment classification path rather than a friendlier synthetic error.For the reviewer
STA-3002case in the repro test was previously markedit.failspending fix(remote-runtime): materialize the host surface when reconnecting a terminal pane #11542. That fix has since merged, so this PR un-marks it — it must now pass as a normal test. The same test also had an intermediatelistCallsAfterOutage > 1checkpoint that encoded the old polling-only cadence; fix(remote-runtime): materialize the host surface when reconnecting a terminal pane #11542 activates immediately, so that assertion is obsolete and was removed. The real oracle (activation happened, handle rebound, input flows) is untouched and passes.remote-runtime-pty-transport.tswas resolved by keeping both sides: fix(remote-runtime): materialize the host surface when reconnecting a terminal pane #11542 owns the reconnect inventory loop (waitForResubscribeHostSessionHandle), this PR owns error surfacing and the recovery-phase choice in the catch blocks. Worth a look at the resubscribe catch to confirm the merge reads correctly.