fix(remote-runtime): keep a remote outage from flooding the error surface and dead-ending the pane (#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 #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.
This commit is contained in:
Jinwoo Hong
2026-08-04 23:21:31 -07:00
committed by GitHub
parent 1f86f980c5
commit 1667b77f0b
11 changed files with 1046 additions and 23 deletions
@@ -5,14 +5,17 @@ import {
} from './remote-runtime-client-error-classification'
describe('remote runtime client error classification', () => {
it.each(['remote_runtime_unavailable', 'runtime_timeout', 'runtime_unavailable', 'reconnecting'])(
'treats %s as recoverable',
(code) => {
expect(isRecoverableRemoteRuntimeConnectionError({ code, message: 'transport failed' })).toBe(
true
)
}
)
it.each([
'remote_runtime_unavailable',
'runtime_rpc_queue_overloaded',
'runtime_timeout',
'runtime_unavailable',
'reconnecting'
])('treats %s as recoverable', (code) => {
expect(isRecoverableRemoteRuntimeConnectionError({ code, message: 'transport failed' })).toBe(
true
)
})
it('does not retry authentication or protocol failures', () => {
expect(
@@ -31,6 +34,7 @@ describe('remote runtime client error classification', () => {
'Remote Orca runtime closed the connection.',
'Remote Orca runtime connection closed.',
'Remote Orca runtime is not connected.',
"Error invoking remote method 'runtimeEnvironments:call': RuntimeRpcCallQueueOverloadError: Remote runtime call queue is full; retry after current calls finish.",
'Remote runtime subscription closed before it started.'
])('normalizes unstructured connection failure: %s', (message) => {
const error = toRemoteRuntimeClientErrorLike(new Error(message))