Repository navigation
fix(remote-runtime): recover terminals after network loss - #9774
Conversation
📝 WalkthroughWalkthroughThe pull request adds remote PTY recovery state tracking, epoch-fenced reconnect behavior, recovery-aware IO gating, and reconnect UI banners. Terminal creation gains deterministic handles, concurrent request deduplication, inventory reconciliation, worktree identity validation, and capability-gated retries. Shared runtime connections add recoverable error classification, generation-safe socket handling, reconnect scheduling, and probe-based liveness monitoring. Provider process listings now expose worktree identities, and reliability-gate evidence is expanded with recovery and idempotency coverage. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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 (1)
src/main/runtime/rpc/methods/terminal.ts (1)
1362-1362: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the idempotency identity precedence.
pairedDeviceId ?? clientId ?? 'local'defines the mutation isolation boundary. Add a brief rationale so future cleanup does not change retry scoping.Suggested clarification
+ // Keep retries scoped to the authenticated paired device when available. pairedDeviceId ?? clientId ?? 'local',As per coding guidelines, “For non-obvious TypeScript code, add a concise comment explaining why the constraint exists, not how the code works.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a7d703af-81ef-4cdd-bb69-1e65d4dc2df8
📒 Files selected for processing (43)
config/reliability-gates.jsoncsrc/main/daemon/daemon-pty-adapter.test.tssrc/main/daemon/daemon-pty-adapter.tssrc/main/providers/local-pty-provider.test.tssrc/main/providers/local-pty-provider.tssrc/main/runtime/orca-runtime-terminal-create-idempotency.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/remote-runtime-terminal-create-idempotency.tssrc/main/runtime/remote-runtime-terminal-create-identity.tssrc/main/runtime/rpc/methods/terminal-create-idempotency.test.tssrc/main/runtime/rpc/methods/terminal.tssrc/main/runtime/rpc/remote-runtime-server-heartbeat.test.tssrc/main/runtime/rpc/remote-runtime-server-heartbeat.tssrc/main/runtime/rpc/ws-transport.tssrc/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/components/terminal-pane/TerminalRemoteRuntimeReconnectBanner.test.tsxsrc/renderer/src/components/terminal-pane/TerminalRemoteRuntimeReconnectBanner.tsxsrc/renderer/src/components/terminal-pane/pty-connection-types.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-state.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-state.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/terminal-remote-runtime-recovery-ui-state.test.tssrc/renderer/src/components/terminal-pane/terminal-remote-runtime-recovery-ui-state.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/remote-runtime-terminal-multiplexer.tssrc/shared/protocol-version.tssrc/shared/remote-runtime-client-error-classification.test.tssrc/shared/remote-runtime-client-error-classification.tssrc/shared/remote-runtime-shared-control-connection.test.tssrc/shared/remote-runtime-shared-control-connection.tssrc/shared/remote-runtime-shared-control-reconnect.tssrc/shared/remote-runtime-shared-control-socket-generation.test.tssrc/shared/remote-runtime-shared-control-socket-generation.tssrc/shared/remote-runtime-socket-liveness.test.tssrc/shared/remote-runtime-socket-liveness.ts
…e-network-recovery # Conflicts: # resources/skills/current-manifest.json # resources/skills/release-mapping.json # resources/skills/snapshot-registry.json
…e-network-recovery
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts (2)
1083-1085: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftFence terminal creation against lifecycle changes.
A
terminal.createRPC already in flight survivesdisconnect()/detach()/attach(). If it resolves later, Lines 1106-1119 restorehandle, emitonPtySpawn, and subscribe a pane that was closed or replaced. The new retry flow extends this race to 60 seconds. Track a lifecycle epoch through create/retry, invalidate it on attach/disconnect/detach, and close a stale returned terminal instead of applying it.
426-510: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftKeep exhausted recoverable creation failures retryable.
After the deadline, this throws the last recoverable connection error.
connect()then routes it toonError, producing the fatal-error path, while recovery state remainsofflineandretryRecovery()cannot run without a handle. Transition this case to the disconnected/reconnectable state and reserveonErrorfor non-recoverable failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 897c6368-3b61-4782-831c-70c542325499
📒 Files selected for processing (4)
config/reliability-gates.jsoncsrc/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-state.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts
- config/reliability-gates.jsonc
…ose tombstones Narrow stablyai#8254 onto current main after stablyai#9774: return ok-union start results across IPC, reconstruct cloneable {code,message} in preload (contextBridge), and tombstone early onClose so late handles are release-only.
…line Narrow stablyai#8255 onto current main after stablyai#9774: fire pending shared-control reconnect timers and pane recovery backoffs on system resume and browser online, without replacing the per-pane recovery state machine or reconnect banner UX.
* fix(remote): accelerate shared-control and pane recovery on resume/online Narrow #8255 onto current main after #9774: fire pending shared-control reconnect timers and pane recovery backoffs on system resume and browser online, without replacing the per-pane recovery state machine or reconnect banner UX. * test(remote): cover online and occluded-resume recovery triggers * fix(remote): centralize recovery acceleration --------- Co-authored-by: OrcaWin <[email protected]>
) Co-authored-by: Brennan Benson <[email protected]>
…8255) * fix(remote): accelerate shared-control and pane recovery on resume/online Narrow stablyai#8255 onto current main after stablyai#9774: fire pending shared-control reconnect timers and pane recovery backoffs on system resume and browser online, without replacing the per-pane recovery state machine or reconnect banner UX. * test(remote): cover online and occluded-resume recovery triggers * fix(remote): centralize recovery acceleration --------- Co-authored-by: OrcaWin <[email protected]>
Summary
terminal.createretries capability-gated and idempotent so an unknown response outcome adopts the original server PTY instead of creating a duplicate.Screenshots
Not attached. The disconnected state requires a controlled remote-runtime partition; renderer component tests cover the exact retrying and manual-reconnect UI states. A live patched Mac-to-Windows partition recording remains a follow-up validation gap.
Testing
pnpm lint— changed-file oxlint and React Doctor pass; the full command is blocked by unrelated pre-existing switch-exhaustiveness and localization-coverage findings.pnpm typecheckpnpm test— focused and broader registered reliability suites were run instead of the entire repository suite.pnpm build—pnpm exec electron-vite build --mode e2epassed; the full multi-target build was not run.Validation performed:
git diff --check.AI Review Report
Six adversarial review rounds across the initial and final review passes checked connection epochs, stale socket/RPC callbacks, subscription replay, PTY identity and reattachment ordering, create idempotency, timer/listener cleanup, per-environment isolation, fatal versus recoverable UX, compatibility with older runtimes, and macOS/Linux/Windows plus SSH/WSL/relay implications.
The initial rounds fixed disposed-pane recovery UI state and completed the reliability contract. The final review reproduced two major create-lifecycle bugs: cutoff surfaced a fatal error with no manual path, and a delayed create completion could replace a newer cross-runtime attachment. Both are now epoch-fenced and regression-tested. The next round found that a slow capability probe could leave a create RPC alive past cutoff; timeouts are now recomputed from the remaining budget and exact-cutoff callbacks cannot re-arm recovery. The final round was clean.
Cross-platform review confirmed there are no platform-specific shortcuts, path separators, or shell assumptions in the new lifecycle/UI code. Server and client heartbeat behavior is transport-generic, and older runtimes degrade safely because terminal-create replay is enabled only when the server advertises
terminal.create-idempotency.v2.Security Audit
Notes