Skip to content

fix(remote): recover runtime streams after client wake - #9093

Closed
matheustimbo wants to merge 2 commits into
stablyai:mainfrom
matheustimbo:fix/remote-runtime-wake-reconnect
Closed

matheustimbo wants to merge 2 commits into
stablyai:mainfrom
matheustimbo:fix/remote-runtime-wake-reconnect

Conversation

@matheustimbo

@matheustimbo matheustimbo commented Jul 17, 2026 •

Copy link
Copy Markdown

Fixes #9092

Summary

  • Keep shared-control subscriptions reconnecting indefinitely, with the existing delay capped at 15 seconds, instead of permanently closing them after seven attempts.
  • Treat dedicated terminal stream availability failures as recoverable transport closes and retry resubscription while Tailscale or Wi-Fi restores the route.
  • Suppress only known transient transport errors from the PTY error surface.
  • Invalidate in-flight reconnect and attach work across detach, reattach, retire, disconnect, and destroy lifecycle changes.
  • Cover wake failure, restored-pane retry, pre-ready transport failure, repeated replacement closes, and same-handle stale async races.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation:

  • 90 focused Vitest tests passed.
  • Full Node, CLI, and web TypeScript checks passed on Node 24.
  • Oxlint, type-aware switch lint, oxfmt, max-lines ratchet, reliability gates, and git diff --check passed for the changed surface.
  • The full test suite reached 30,859 passing and 110 skipped tests; one unrelated environment-specific assertion failed in src/relay/git-handler.test.ts because this host Git returns Stopping at filesystem boundary where the test expects not a git repository.
  • Full lint reaches an unrelated existing switch-exhaustiveness error in src/renderer/src/components/skills/skill-freshness-group.tsx:101.
  • Build was not run.

AI Review Report

The review focused on reconnect timer ownership, terminal lifecycle transitions, stale async completions, duplicate subscriptions, and explicit-close cancellation. It initially found stale retry races across detach/reattach and replacement stream closes; the implementation added cycle/generation guards and regression coverage. CodeRabbit then identified that a recoverable error arriving before multiplex readiness could be converted into a generic close and stop the initial attach retry. Commit 28ded1af4 preserves the transport error message, prevents the original attach rejection from scheduling a duplicate retry, and adds a regression test for that ordering.

The review explicitly checked macOS, Linux, and Windows compatibility, including shortcuts, labels, paths, shell behavior, and Electron-specific differences. This change is transport-level: it adds no shortcuts, labels, paths, shell commands, or platform-specific Electron behavior, and uses existing cross-platform timer and IPC abstractions. The SSH use case was included alongside native and Tailscale-backed remote runtimes.

Security Audit

The change introduces no new user input, command execution, path handling, authentication, secrets, dependencies, or IPC surface. Review covered error-code/message classification, retry bounds, lifecycle cancellation, and whether transport errors or secrets could be newly exposed. Retry delay remains capped at 15 seconds, explicit close/terminal retirement cancels pending work, and no new logging or secret-bearing payloads were added. No security follow-up is currently needed.

Notes

Recovery applies to native, SSH, and Tailscale-backed remote runtimes. Explicit close and terminal retirement still stop retries. The unchecked global lint and test boxes are documented above; their observed failures are outside this PR's changed surface.

ELI5

After your laptop sleeps or Wi‑Fi drops, remote terminals and control streams could stop updating permanently. They now keep retrying reconnection so streams recover when the network comes back.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Runtime transport errors are classified as recoverable by code or message and handled without terminal failure. Remote PTY transport now uses capped resubscription retries with cycle guards and cancellation across lifecycle transitions. Shared-control connections continue reconnecting until explicitly closed while retaining subscriptions. Tests cover transient failures, eventual attachment, and stale retry prevention.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes align with #9092 by keeping retries alive, treating transient transport failures as recoverable, and guarding stale reconnect work.
Out of Scope Changes check ✅ Passed The changed files and tests all support remote-runtime recovery and retry behavior; no unrelated code appears introduced.
Title check ✅ Passed The title is concise and matches the main change: recovering remote runtime streams after client wake/offline recovery.
Description check ✅ Passed The description follows the template and includes summary, screenshots, testing, AI review, security audit, and notes.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9258d1f8-e819-4501-b0fe-7d50d66c3231

📥 Commits

Reviewing files that changed from the base of the PR and between 88068f5 and 62a25d1.

📒 Files selected for processing (7)
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/renderer/src/runtime/runtime-terminal-stream.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts

@nwparker

Copy link
Copy Markdown
Contributor

Thanks, @matheustimbo! This was rebuilt on current main and merged in #29444 (your approach was used). Closing as superseded.

@nwparker nwparker closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote runtime does not recover after macOS lock or sleep over Tailscale

5 participants