Skip to content

fix(remote): accelerate terminal recovery on resume/online - #8255

Merged
OrcaWin merged 3 commits into
stablyai:mainfrom
bbingz:bbingz/fix-remote-runtime-recovery
Jul 27, 2026
Merged

fix(remote): accelerate terminal recovery on resume/online#8255
OrcaWin merged 3 commits into
stablyai:mainfrom
bbingz:bbingz/fix-remote-runtime-recovery

Conversation

@bbingz

@bbingz bbingz commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

fix(remote): accelerate terminal recovery on resume/online

Status (2026-07-23 restack note)

Residual follow-up only. The original QueryReplay / recovery-coordinator / staged-rebind stack has largely landed on main (see transport recovery work including the #9774-era paths, plus host authority work in #9804 / #9687).

This PR no longer claims full “recover terminals after transport interruption.” Review only the residual:

  • retryConnectionsNow / force-retry recovery schedulers when the OS resumes or the network comes online
  • advance independent control + pane backoffs so recovery does not wait the full offline timer after sleep/blips

Problem

After OS resume or a network blip, remote PTY recovery timers can sit on long backoffs even though the daemon/session is already live again. Transport recovery on main reconnects, but resume/online does not always kick pending recovery immediately.

Solution

  • Wire system resume + online events to retry outstanding remote runtime PTY recoveries now
  • Keep main’s existing recoverable transport-close / rebind paths; do not reintroduce a parallel coordinator

Non-goals

Test plan

  • Sleep/wake machine with a remote runtime terminal open — recovery starts without multi-tens-of-seconds idle
  • Toggle network offline→online — pending recoveries advance
  • Existing recoverable transport-close still rebinds without double-subscribe

Part of the remote terminal reliability set; orthogonal to closeLifecycle (#9804).

ELI5

After a remote connection blip or resume, terminals could take too long to come back. Residual recovery scheduling forces retries sooner on resume/online so panes rebind faster without claiming a full rewrite of transport recovery.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change adds pause-aware socket and WebSocket liveness probing, structured runtime subscription results, shared-control reconnect and timeout handling, query-replay framing, and coordinated remote terminal recovery. Renderer PTY transports now use staged generation-fenced rebinding with input, viewport, replay, and stale-callback protection. New session-tab resolution and recovery coordination modules support retries and snapshot-based handle repair. Tests cover IPC errors, liveness, reconnects, recovery ordering, PTY lifecycle behavior, wake retries, and replay completion.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning It covers the change, but misses required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Rewrite the description to follow the repository template and add the missing required sections, including screenshots, testing, AI review report, security audit, and notes.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement coordinated terminal recovery, replay/barrier negotiation, retry/backoff, and generation fencing aligned with #8180.
Out of Scope Changes check ✅ Passed The diff stays focused on remote-runtime recovery, shared-control, and related tests/docs without obvious unrelated feature work.
Title check ✅ Passed The title matches the PR’s main user-visible change: accelerating remote terminal recovery on resume/online.

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.

🧹 Nitpick comments (2)
src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts (1)

107-118: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider restoring the visibility spy in a finally block.

If an assertion on lines 115-116 throws, visibilityStateSpy.mockRestore() on line 117 won't execute, potentially leaking the stubbed visibilityState into subsequent tests. Wrapping in try/finally or relying on a global restoreMocks config would be safer.

♻️ Proposed fix
   it('retries remote terminal recovery on system resume while the document is hidden', () => {
     const visibilityStateSpy = vi
       .spyOn(document, 'visibilityState', 'get')
       .mockReturnValue('hidden')
-    renderWakeRecoveryHook()
-
-    systemResumedCallback?.()
-
-    expect(retryRemoteRuntimeTerminalRecoveriesNowMock).toHaveBeenCalledTimes(1)
-    expect(recoverVisibleTerminalWindowWakeMock).not.toHaveBeenCalled()
-    visibilityStateSpy.mockRestore()
+    try {
+      renderWakeRecoveryHook()
+
+      systemResumedCallback?.()
+
+      expect(retryRemoteRuntimeTerminalRecoveriesNowMock).toHaveBeenCalledTimes(1)
+      expect(recoverVisibleTerminalWindowWakeMock).not.toHaveBeenCalled()
+    } finally {
+      visibilityStateSpy.mockRestore()
+    }
   })
src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts (1)

140-146: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider logging swallowed errors in invokeSafely for debuggability.

The silent catch is justified by the comment, but provides zero observability if onIdle ever throws. A console.error would help diagnose coordinator lifecycle issues without blocking cleanup.

♻️ Optional: add debug logging
 function invokeSafely(callback: () => void): void {
   try {
     callback()
  } catch (error) {
-    // External callbacks cannot block cleanup or singleton release.
+    // External callbacks cannot block cleanup or singleton release.
+    console.error('[remote-runtime-terminal-recovery] onIdle callback threw', error)
   }
 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7f0f5ed3-a467-4c69-a55b-a46b4ecacf0f

📥 Commits

Reviewing files that changed from the base of the PR and between 20ebe85 and 9af0a2e.

📒 Files selected for processing (46)
  • config/localization-coverage-allowlist.json
  • docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md
  • src/main/ipc/runtime-environments.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-input.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-ordering.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • 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/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
  • src/shared/remote-runtime-client-error-classification.test.ts
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/remote-runtime-client.test.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/shared/remote-runtime-socket-liveness.ts

@bbingz

bbingz commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

CodeRabbit nitpick dispositions

  • Restore the visibility spy in finally: deferred. The successful path already restores the local spy, and the suggested change only reduces secondary test contamination after an assertion has already failed. It does not change the recovery contract or production behavior. If this test demonstrates cross-test leakage, or the suite adopts a consistent global restoreMocks policy, the cleanup should be handled there.
  • Log errors swallowed by invokeSafely: no change. Silent callback isolation is intentional and matches the sibling recovery helpers in the registry, staged rebind, and PTY transport. Logging at only this callback boundary would be inconsistent, add renderer-console noise, and could print arbitrary external error details. If lifecycle observability is needed, it should be added as structured diagnostics across all recovery callback boundaries rather than as a one-off console.error.

@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from 9af0a2e to 11364b8 Compare July 11, 2026 13:58

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 10e9e7ea-db3d-41f0-b93f-bbc0efcb8811

📥 Commits

Reviewing files that changed from the base of the PR and between 9af0a2e and 11364b8.

📒 Files selected for processing (58)
  • config/localization-coverage-allowlist.json
  • docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md
  • src/main/ipc/runtime-environments.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-input.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-ordering.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • 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/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/runtime/remote-runtime-terminal-frame-drop-resync.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-lifecycle.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.test.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/remote-runtime-client-error-classification.test.ts
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/remote-runtime-client.test.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/shared/remote-runtime-socket-liveness.ts
  • src/shared/terminal-stream-protocol.test.ts
  • src/shared/terminal-stream-protocol.ts
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
🚧 Files skipped from review as they are similar to previous changes (40)
  • src/shared/remote-runtime-shared-control-types.ts
  • config/localization-coverage-allowlist.json
  • src/shared/remote-runtime-client-error-classification.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/shared/remote-runtime-client-error-classification.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/shared/remote-runtime-client.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/shared/remote-runtime-socket-liveness.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • src/main/ipc/runtime-environments.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts
  • src/main/ipc/runtime-environments.test.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts

Comment thread docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md Outdated
Comment thread docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md Outdated
@AmethystLiang AmethystLiang self-assigned this Jul 11, 2026
@AmethystLiang
AmethystLiang self-requested a review July 11, 2026 16:47
@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from 11364b8 to e19b65e Compare July 12, 2026 00:37

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a682d890-0a56-44cd-af89-702000423884

📥 Commits

Reviewing files that changed from the base of the PR and between 11364b8 and e19b65e.

📒 Files selected for processing (64)
  • config/localization-coverage-allowlist.json
  • docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environments.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/main/system-resume-broadcast.test.ts
  • src/main/system-resume-broadcast.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-input.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-ordering.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-binding-state.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • 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/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/runtime/remote-runtime-terminal-frame-drop-resync.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-lifecycle.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.test.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/remote-runtime-client-error-classification.test.ts
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/remote-runtime-client.test.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/shared/remote-runtime-shared-control-resume.test.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/shared/remote-runtime-socket-liveness.ts
  • src/shared/terminal-stream-protocol.test.ts
  • src/shared/terminal-stream-protocol.ts
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
🚧 Files skipped from review as they are similar to previous changes (54)
  • config/localization-coverage-allowlist.json
  • src/shared/remote-runtime-client-error-classification.test.ts
  • src/shared/terminal-stream-protocol.test.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/shared/remote-runtime-client.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/shared/terminal-stream-protocol.ts
  • src/shared/remote-runtime-socket-liveness.ts
  • src/renderer/src/runtime/remote-runtime-terminal-frame-drop-resync.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/main/ipc/runtime-environments.test.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-input.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/main/ipc/runtime-environments.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-ordering.test.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/main/runtime/rpc/methods/terminal.ts

Comment thread docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md Outdated
Comment thread docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md Outdated
@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from e19b65e to 7360f6f Compare July 12, 2026 01:37

@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.

🧹 Nitpick comments (1)
docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md (1)

149-168: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add direct-handle terminal outcome coverage to the release gate.

The design defines distinct retirement and no-retry behavior for direct handles, but the test plan only exercises host-mirror recovery and generic transport failures. Add deterministic cases for each known terminal-gone result and for an unknown runtime_error, asserting exactly-once retirement, no terminal.create/terminal.close, and no retry loop.

Also applies to: 267-293


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e1a36a61-f943-48a3-9d0e-5617eaa61406

📥 Commits

Reviewing files that changed from the base of the PR and between e19b65e and 7360f6f.

📒 Files selected for processing (66)
  • config/localization-coverage-allowlist.json
  • docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environments.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/main/system-resume-broadcast.test.ts
  • src/main/system-resume-broadcast.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-input.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-ordering.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-binding-state.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • 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/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/runtime/remote-runtime-terminal-frame-drop-resync.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-lifecycle.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.test.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/remote-runtime-client-error-classification.test.ts
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/remote-runtime-client.test.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/shared/remote-runtime-shared-control-resume.test.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/shared/remote-runtime-socket-liveness.ts
  • src/shared/terminal-stream-protocol.test.ts
  • src/shared/terminal-stream-protocol.ts
✅ Files skipped from review due to trivial changes (1)
  • config/localization-coverage-allowlist.json
🚧 Files skipped from review as they are similar to previous changes (60)
  • src/shared/terminal-stream-protocol.test.ts
  • src/shared/remote-runtime-client-error-classification.test.ts
  • src/shared/remote-runtime-shared-control-resume.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.ts
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.test.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/main/system-resume-broadcast.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-binding-state.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/main/system-resume-broadcast.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-lifecycle.test.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/shared/remote-runtime-client.test.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-input.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/shared/terminal-stream-protocol.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/renderer/src/runtime/remote-runtime-terminal-frame-drop-resync.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/shared/remote-runtime-socket-liveness.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-ordering.test.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/main/ipc/runtime-environments.test.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/main/runtime/rpc/methods/terminal.ts

@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from 7360f6f to 0c52cac Compare July 12, 2026 01:46

@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: 2

🧹 Nitpick comments (1)
src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx (1)

562-566: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a "why" comment for the disconnectedByFocusSwitch optimization.

The conditional skip of disconnectSavedRuntimeEnvironment in non-local mode is a non-obvious constraint — it depends on switchRuntimeEnvironment(null) already closing transport state. Per coding guidelines, add a brief comment explaining why the disconnect is skipped here.

As per coding guidelines: "When code is driven by a design document or non-obvious constraint, add a brief one- or two-line comment explaining why it behaves that way, without restating the implementation."

💬 Suggested comment
       if (!allowLocalRuntime) {
+        // Why: in non-local mode switching away from the active server already
+        // closes its transport and subscriptions, so skip the redundant disconnect.
         disconnectedByFocusSwitch = true
       }

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 324a31f9-697b-40cf-a2c3-30c0df0e6946

📥 Commits

Reviewing files that changed from the base of the PR and between 7360f6f and 0c52cac.

📒 Files selected for processing (66)
  • config/localization-coverage-allowlist.json
  • docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environments.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/main/system-resume-broadcast.test.ts
  • src/main/system-resume-broadcast.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-input.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-ordering.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-binding-state.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • 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/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/runtime/remote-runtime-terminal-frame-drop-resync.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-lifecycle.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.test.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/remote-runtime-client-error-classification.test.ts
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/remote-runtime-client.test.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/shared/remote-runtime-shared-control-resume.test.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/shared/remote-runtime-socket-liveness.ts
  • src/shared/terminal-stream-protocol.test.ts
  • src/shared/terminal-stream-protocol.ts
🚧 Files skipped from review as they are similar to previous changes (64)
  • src/shared/remote-runtime-client-error-classification.test.ts
  • config/localization-coverage-allowlist.json
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/terminal-stream-protocol.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.ts
  • src/preload/index.ts
  • src/shared/remote-runtime-shared-control-reconnect-delay.test.ts
  • src/shared/remote-runtime-shared-control-resume.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.test.ts
  • src/renderer/src/runtime/remote-runtime-host-terminal-resolution.test.ts
  • src/shared/terminal-stream-protocol.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.ts
  • src/main/system-resume-broadcast.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-terminal-gone-error.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/shared/remote-runtime-shared-control-frame-handler.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-input.test.ts
  • src/main/system-resume-broadcast.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-types.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-rebind.ts
  • src/renderer/src/runtime/runtime-environment-connection-lifecycle.test.ts
  • src/shared/remote-runtime-client.test.ts
  • src/preload/api-types.ts
  • src/shared/remote-runtime-shared-control-subscription-start.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-test-fixture.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/preload/runtime-environment-subscriptions.ts
  • src/shared/remote-runtime-socket-liveness.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-staged-binding-state.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-ordering.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-frame-drop-resync.test.ts
  • src/shared/remote-runtime-shared-control-requests.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/renderer/src/runtime/remote-runtime-session-tabs-recovery-subscription.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-registry.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.ts
  • src/renderer/src/runtime/remote-runtime-terminal-recovery-coordinator.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-lifecycle.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-window-wake-recovery.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/shared/remote-runtime-socket-liveness.ts
  • src/preload/runtime-environment-subscriptions.test.ts
  • src/main/ipc/runtime-environments.test.ts
  • src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
  • src/shared/remote-runtime-shared-control-reconnect.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts
  • src/main/runtime/rpc/methods/terminal.ts

Comment thread docs/reference/2026-07-11-remote-runtime-terminal-recovery-design.md Outdated
Comment thread src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx Outdated
@bbingz

bbingz commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest direct-handle release-gate nitpick in bbc6cc9b8.

The coordinator suite already parameterizes all four known terminal-gone codes and separately proves an unknown runtime_error is fatal exactly once and remains a no-op under retryNow(). The final delta makes the transport-level contract explicit as well: after each known terminal-gone outcome it sends an explicit retry signal, asserts no extra multiplexer attempt, asserts exactly-once PTY retirement, and verifies neither terminal.create nor terminal.close is issued. The written release plan now lists these direct-handle outcome gates explicitly.

Focused outcome tests: 11/11; targeted lint/format, max-lines, and diff check pass. No production recovery behavior changed.

@bbingz

bbingz commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the remaining current-code why-comment suggestion from review 4679177855 in 73598ff04. The new two-line comment records that switching away from the active remote already closes its transport/subscriptions, so the follow-up disconnect is intentionally skipped. This is documentation-only; focused lifecycle tests remain 4/4 and targeted lint/format/max-lines/diff checks pass.

@bbingz

bbingz commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@bbingz

bbingz commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review current head 5b5a48b after the CI-discovered test contract fix.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@bbingz Got it — I'll review the current head (5b5a48b) now, including the CI-discovered test contract fix.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

bbingz added a commit to bbingz/orca that referenced this pull request Jul 19, 2026
…#8180)

Rebased recovery layer onto latest main + transport foundations + stream-close.
Preserves the recovery coordinator, staged rebind, QueryReplay/barrier path,
and wake/online retry behavior from stablyai#8255 while dropping obsolete merge commits.
@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from 582ad32 to d46bb57 Compare July 19, 2026 13:39
@bbingz

bbingz commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Rebased recovery layer onto rebased #8253/#8254 + latest main.

The 8255-only delta is now a single commit on top of the foundations/stream-close layers (old multi-merge history dropped). For the heavily rewritten remote-runtime-pty-transport.ts, took the recovery-coordinator architecture from this PR tip so binding-generation / staged rebind / QueryReplay stay coherent.

bbingz added a commit to bbingz/orca that referenced this pull request Jul 21, 2026
…#8180)

Rebased recovery layer onto latest main + transport foundations + stream-close.
Preserves the recovery coordinator, staged rebind, QueryReplay/barrier path,
and wake/online retry behavior from stablyai#8255 while dropping obsolete merge commits.
@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from d46bb57 to 018e975 Compare July 21, 2026 04:03
@bbingz

bbingz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Stack status vs merged #9774

#9774 landed a different recovery design for the same outage class (#8180): per-pane recovery state, 60s auto then manual Reconnect banner, create idempotency/adopt.

This branch’s env-level coordinator + indefinite auto-retry + “no banner” path should not land as-is (would fight the #9774 UX contract).

Still complementary (candidate narrow follow-ups only):

  1. Resume / browser-online acceleration of shared-control + recovery backoff
  2. Optional multi-pane inventory coalescing that calls into existing per-pane recovery
  3. QueryReplay barrier — only with a post-fix(remote-runtime): recover terminals after network loss #9774 repro

Next step: shrink rather than rebase the full 10-commit stack. #8253 is being evaluated for close-as-superseded.

@bbingz

bbingz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Narrow rewrite complete (post-#9774)

Force-pushed a complementary-only branch onto current main. Dropped the env recovery coordinator, staged rebind, QueryReplay barrier, and indefinite auto-retry (would fight #9774’s 60s + Reconnect banner).

Kept only:

  1. SharedControlReconnectScheduler.retryNow() + runtimeEnvironments:retryConnectionsNow IPC/preload
  2. RemoteRuntimePtyRecoveryState.retryNow() + active-registry retryAllRemoteRuntimePtyRecoveriesNow()
  3. Wire system resume + browser online in useTerminalWindowWakeRecovery to advance both backoff timers

Focused tests: recovery-state + shared-control connection + wake-recovery (36 passed).

Ready for re-review as a small follow-up to #9774.

bbingz added a commit to bbingz/orca that referenced this pull request Jul 22, 2026
…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.
@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from 018e975 to ce321f9 Compare July 22, 2026 02:15
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
@bbingz

bbingz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current origin/main (0326594d52).

Kept main's per-environment reconnectNow path and this PR's bulk retryNow / resume-online acceleration side by side.

Focused tests: remote-runtime-pty-recovery-state 7/7 green. ahead=1 behind=0.

bbingz added a commit to bbingz/orca that referenced this pull request Jul 23, 2026
…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.
@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from ce321f9 to 604974a Compare July 23, 2026 02:03
@bbingz bbingz changed the title fix(remote): recover terminals after transport interruption fix(remote): accelerate terminal recovery on resume/online Jul 23, 2026
bbingz added a commit to bbingz/orca that referenced this pull request Jul 23, 2026
…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.
@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from 604974a to 19107c6 Compare July 23, 2026 03:29
@bbingz

bbingz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Restack + review guide (community, awaiting maintainer)

Rebased onto latest main (force-with-lease). 1 commit, behind=0.

Title/body already rewritten to residual scope:
fix(remote): accelerate terminal recovery on resume/online

What this PR still uniquely does

Main already reconnects recoverable remote PTYs. This PR only kicks pending recovery when:

  • OS resume / window wake
  • browser / network online

via retryConnectionsNow / retryAllRemoteRuntimePtyRecoveriesNow style force-retry — so recovery does not sit on full backoff after sleep.

Not claiming

  • QueryReplay negotiation, staged rebind coordinator, snapshot coalesce (on main)

Depends on

Tests (local)

  • remote-runtime-pty-recovery-state.test.ts7 passed

Ready for upstream review; community author cannot merge.

@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from 19107c6 to 0576815 Compare July 23, 2026 07:06
bbingz added a commit to bbingz/orca that referenced this pull request Jul 23, 2026
…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.
@bbingz

bbingz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Re-restack note

Rebased onto latest main after it advanced (~20 commits) and this PR went DIRTY.

  • Conflict in runtime-environments.ts imports: kept main’s surface + retryRemoteRuntimeSharedControlConnectionsNow (did not reintroduce removed clearActiveRuntimeEnvironmentFocusIfMatches)
  • Residual scope unchanged: resume/online acceleration only

Ready for upstream review; community author cannot merge.

bbingz added 2 commits July 26, 2026 22:16
…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.
@bbingz
bbingz force-pushed the bbingz/fix-remote-runtime-recovery branch from 0576815 to 4c61d37 Compare July 26, 2026 14:25
@nwparker nwparker added the bug Something isn't working label Jul 27, 2026

@OrcaWin OrcaWin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for narrowing this to the residual resume/online backoff gap. I applied the review fixes:

  • moved resume/online recovery triggers to one App-level owner so hidden panes recover without duplicate per-pane listeners
  • narrowed the pane registry to scheduled backoffs and hardened timer cleanup/reentrancy
  • kept the retry IPC desktop-scoped and extracted its handler to satisfy max-lines
  • added listener, IPC, scheduler, and recovery cleanup regression coverage

Validated focused recovery/IPC tests, both node and tc.web typechecks, max-lines, Electron build/runtime behavior, and the terminal reattach reliability gates. The known headless activation failure reproduced on pristine main.

@OrcaWin
OrcaWin merged commit b96c2f0 into stablyai:main Jul 27, 2026
4 checks passed
@bbingz
bbingz deleted the bbingz/fix-remote-runtime-recovery branch August 1, 2026 00:47
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.

4 participants