Skip to content

fix(runtime): let connections own host status recovery - #20003

Merged
Jinwoo-H merged 7 commits into
mainfrom
connection-owned-host-status
Sep 11, 2026
Merged

Jinwoo-H merged 7 commits into
mainfrom
connection-owned-host-status

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1178 $\color{#cf222e}{\Huge{\mathbf{−}}}$​780 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​398
Prod 44 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1125 $\color{#cf222e}{\Huge{\mathbf{−}}}$​820 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​305

ELI5

A remote host can stay marked unreachable after its first status check fails. The connection now owns recovery: when it becomes authenticated and ready, it checks the host again and updates every viewer's snapshot.

What Changed

  • Add one status owner per desktop host and per browser primary session. Readers share verification while retaining individual deadlines and cancellation.
  • Publish ordered snapshots to renderer windows; retain last-known metadata separately from current verification and transport state.
  • Remove the renderer retry scheduler, diagnostics merge publisher/generation map, duplicate capability-discovery promise cache, and direct UI status publications.
  • Reuse existing socket reconnect behavior. Keep one failed-operation retry slot for unresolved bootstrap, legacy hosts, and status failures on a healthy socket. Healthy hosts have no new status polling.
  • Preserve manual disconnect, stale-result fencing, capability fallback, and shared sidebar/status-bar host-state derivation. No remote wire format changes.

Why

A renderer-owned snapshot can become stale independently of the connection. Giving verification to the connection makes authenticated recovery the normal refresh trigger and gives viewers one ordered source of status.

Linked Issue

Addresses the recovery problem reported in #19163. The sidebar derivation and related coverage adapt Omar Shahine's original work; commit 354922fec8a credits him with Co-authored-by.

Visual Proof

After automatic recovery, the desktop shows both remote workspace groups and two connected hosts:

Desktop after recovery

Browser after reconnecting to the headless host:

Browser after recovery

No baseline screenshot was captured. The first-failed-status regression failed on main 58ff95becb40 with one request instead of the expected automatic second request, and passes here.

Testing

  • Automated tests added/updated: 249 passed across 31 targeted suites.
  • Hidden Electron desktop-host and headless-host journeys passed with independent desktop and browser viewers; full screenshots inspected.
  • pnpm tc, changed-code quality including type-aware checks and React Doctor, reliability manifest validation, and git diff --check passed.
  • Electron, CLI, and browser E2E builds passed.

The app journeys interrupt real TCP connections, prove automatic recovery of a non-active host after its first failed check, keep the direct viewer healthy, and verify manual disconnect. The new experimental reliability gate records commands and coverage limits.

Live checks ran on macOS over loopback. Windows/Linux, SSH, mixed-version pairs, literal cold-start profile relaunch, and full host-process restart were not exercised. Runtime identity replacement is covered by the real authenticated socket test. Full repository lint/test coverage remains for CI.

Review

Self-reviewed ownership, cancellation, stale publication, passive intent, and authentication-stop behavior. Original PR remains open.

Agent skill upstream boundary

  • Not applicable; no skill-installer sources or artifacts are copied.

Verify runtime status after authenticated connection recovery and publish
ordered snapshots to desktop and browser viewers. Consolidate failed-status
retries in the connection owner and remove renderer retry/diagnostics merging.

Adapt sidebar host-state derivation and regression coverage from Omar
Shahine's original fix in #19163.

Co-authored-by: Omar Shahine <[email protected]>

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

Important

The "not-probed-yet ≠ disconnected" fix is only applied to one of two host-status derivations, so a host still renders "Disconnected" in several prominent surfaces before its first probe answers.

Reviewed changes

  • Connection-owned status owner — new RuntimeHostStatusOwner state machine (one shared request, per-reader deadlines/abort, recovery driven by ready transport transitions, sequence-ordered snapshots) replaces the renderer retry scheduler.
  • Desktop + browser wiring — per-host owner in main (runtime-environment-request-connections.ts) and per-primary-session owner in WebRuntimeClient, publishing over runtimeEnvironments:statusChanged.
  • Renderer snapshot consumption — applyRuntimeHostStatusSnapshot with pairingRevision + sequence fencing, readRuntimeHostStatusSnapshots, and the new runtimeHostConnectionStateForEntry derivation.
  • Removed renderer machinery — the recheck ladder, diagnostics merge/generation, shared-control-support cache, and the probe/retry scheduler in the IPC bridge.
  • Registry + sidebar derivation — execution-host-registry now reads the snapshot; NoticeHostGlyph/WorktreeCard/SshStatusSegment use the shared runtimeHostConnectionStateForEntry.

The owner state machine itself is solid: I traced request/waiter/deadline/cancel/retry/dispose against its ten unit tests and found the shared-request, abort, and stale-result fencing correct.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment thread src/shared/execution-host-registry.ts Resolved
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 90d35c83-d9d5-45ab-8679-a8424b319945

📥 Commits

Reviewing files that changed from the base of the PR and between 07686a2 and 081895f.

📒 Files selected for processing (1)
  • tests/e2e/runtime-host-status-recovery.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The change introduces shared runtime host status snapshots and a RuntimeHostStatusOwner in shared code. Main-process IPC now routes status requests through status owners and exposes snapshot reads and status-change events. The web runtime client, transport, and request registry add status-owner support and abort handling. The renderer replaces direct status writes and polling with snapshot reads, snapshot application, and new connection-state derivation. Tests and e2e coverage were updated for reconnect, snapshot ordering, and host appearance.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 08189

Host recovery can leave the UI with stale or incomplete connection details, and the lifecycle test may fail because it does not account for snapshot hydration. Resolve these issues before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 53 functions across 63 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: connection-owned host status recovery.
Description check ✅ Passed The description covers the change, rationale, issue reference, testing, review notes, and agent-skill boundary. It is mostly complete, but it does not provide a baseline visual proof and omits several…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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: 9

🧹 Nitpick comments (2)
src/renderer/src/web/web-runtime-client-export-parity.test.ts (1)

9-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the options parameter assertion non-self-referential.

Line 11 derives the expected second parameter from ConstructorParameters<typeof WebClient.WebRuntimeClient>[1], which is the value being asserted. That element of the tuple always matches, so the test no longer pins the options contract. A change to reconnect or to the status block (for example removing publish or changing its signature) will not fail this parity test. Spell the expected shape out to restore the guard.

♻️ Proposed fix to pin the options shape
   expectTypeOf<ConstructorParameters<typeof WebClient.WebRuntimeClient>>().toEqualTypeOf<
     [
       pairing: WebPairingOffer,
-      options?: ConstructorParameters<typeof WebClient.WebRuntimeClient>[1]
+      options?: {
+        reconnect?: boolean
+        status?: {
+          environmentId: string
+          pairingRevision: number
+          publish: (snapshot: RuntimeHostStatusSnapshot) => void
+          verified: (response: RuntimeHostStatusResponse) => void
+        }
+      }
     ]
   >()

Add the supporting import:

+import type {
+  RuntimeHostStatusSnapshot,
+  RuntimeHostStatusResponse
+} from '../../../shared/runtime-host-status'
src/renderer/src/components/settings/use-runtime-environment-catalog.ts (1)

93-93: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Read the snapshots once instead of once per environment.

Lines 93 and 111 run inside the Promise.allSettled map over every visible environment. readRuntimeHostStatusSnapshots() fetches the full snapshot list for all hosts, not one host. With N environments the hook issues N identical IPC round trips that each apply the same list.

Move a single read to after Promise.allSettled resolves.

♻️ Proposed refactor
                 const runtimeStatus = unwrapRuntimeRpcResult<RuntimeStatus>(response)
-                // Why: feed the live status into the store so sidebar host pickers
-                // reflect manual refreshes, not just the settings pane.
-                await useAppStore.getState().readRuntimeHostStatusSnapshots()
                 if (!mountedRef.current) {
                 const remoteControl = extractRuntimeTransportDiagnostics(error)
-                await useAppStore.getState().readRuntimeHostStatusSnapshots()
                 if (!mountedRef.current) {

Then read once after the loop:

             })
         )
+        // Why: feed the live status into the store so sidebar host pickers
+        // reflect manual refreshes, not just the settings pane.
+        await useAppStore.getState().readRuntimeHostStatusSnapshots()
       } catch (error) {

Also applies to: 111-111


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: bf9d5676-5737-4312-a3c6-91bfe25caebf

📥 Commits

Reviewing files that changed from the base of the PR and between ecd7b19 and 354922f.

📒 Files selected for processing (64)
  • config/reliability-gates.jsonc
  • src/main/ipc/runtime-environment-connectivity-handlers.ts
  • src/main/ipc/runtime-environment-federated-read-routing.test.ts
  • src/main/ipc/runtime-environment-handler-channels.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environment-shared-control-support.ts
  • src/main/ipc/runtime-environment-status-connection.test.ts
  • src/main/ipc/runtime-environment-status-owner.ts
  • src/main/ipc/runtime-environment-status-recovery.test.ts
  • src/main/ipc/runtime-environment-support-routing.test.ts
  • src/main/ipc/runtime-environment-support-routing.ts
  • src/main/ipc/runtime-environment-transport-routing.ts
  • src/main/ipc/runtime-environments-call-routing.test.ts
  • src/main/ipc/runtime-environments-capability-cache.test.ts
  • src/main/ipc/runtime-environments-ipc-test-harness.ts
  • src/main/ipc/runtime-environments-pairing.test.ts
  • src/main/ipc/runtime-environments-status-diagnostics.test.ts
  • src/main/ipc/runtime-environments-subscription-lifecycle.test.ts
  • src/main/ipc/runtime-environments-subscription-routing.test.ts
  • src/main/ipc/runtime-environments-subscription-teardown.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/preload/api/runtime-api.ts
  • src/preload/api/runtime-environments-bridge.ts
  • src/renderer/src/components/NewWorkspaceComposerCard.tsx
  • src/renderer/src/components/settings/RepositoryHostSetupsSection.tsx
  • src/renderer/src/components/settings/use-runtime-environment-catalog.ts
  • src/renderer/src/components/settings/use-runtime-environment-connection-actions.ts
  • src/renderer/src/components/sidebar/AddRemoteHostDialog.tsx
  • src/renderer/src/components/sidebar/HostSectionHeaderMenu.tsx
  • src/renderer/src/components/sidebar/NoticeHostGlyph.test.tsx
  • src/renderer/src/components/sidebar/NoticeHostGlyph.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.ssh-reconnect-prompt.test.tsx
  • src/renderer/src/components/sidebar/use-worktree-card-foundation.ts
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/runtime-client-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/runtime-reconnect-host-status.test.ts
  • src/renderer/src/runtime/runtime-host-connection-state.test.ts
  • src/renderer/src/runtime/runtime-host-connection-state.ts
  • src/renderer/src/store/slices/runtime-status-diagnostics-generation.ts
  • src/renderer/src/store/slices/runtime-status-diagnostics-publish.ts
  • src/renderer/src/store/slices/runtime-status-diagnostics.test.ts
  • src/renderer/src/store/slices/runtime-status-recheck.test.ts
  • src/renderer/src/store/slices/runtime-status-recheck.ts
  • src/renderer/src/store/slices/runtime-status-refresh.ts
  • src/renderer/src/store/slices/runtime-status-snapshot.test.ts
  • src/renderer/src/store/slices/runtime-status-snapshot.ts
  • src/renderer/src/store/slices/runtime-status-types.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/renderer/src/web/preload-api/web-runtime-environments-api.ts
  • src/renderer/src/web/preload-api/web-runtime-session.ts
  • src/renderer/src/web/web-runtime-client-export-parity.test.ts
  • src/renderer/src/web/web-runtime-client-timeout-budget.test.ts
  • src/renderer/src/web/web-runtime-client.ts
  • src/renderer/src/web/web-runtime-connection-transport.ts
  • src/renderer/src/web/web-runtime-connection-waiters.ts
  • src/renderer/src/web/web-runtime-request-registry.ts
  • src/renderer/src/web/web-runtime-status-owner.test.ts
  • src/shared/execution-host-registry.ts
  • src/shared/remote-runtime-shared-control-test-server.ts
  • src/shared/runtime-host-status-owner.test.ts
  • src/shared/runtime-host-status-owner.ts
  • src/shared/runtime-host-status.ts
  • tests/e2e/runtime-host-status-recovery.spec.ts
💤 Files with no reviewable changes (6)
  • src/renderer/src/store/slices/runtime-status-recheck.test.ts
  • src/main/ipc/runtime-environment-support-routing.test.ts
  • src/renderer/src/store/slices/runtime-status-diagnostics-generation.ts
  • src/renderer/src/store/slices/runtime-status-diagnostics.test.ts
  • src/renderer/src/store/slices/runtime-status-recheck.ts
  • src/renderer/src/store/slices/runtime-status-diagnostics-publish.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

Comment on lines +145 to +148
return getRuntimeEnvironmentStatusOwner(getUserDataPath(), environment.id).refresh({
timeoutMs: args.timeoutMs,
reconnect: true
})

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Description: Find renderer/preload consumers of runtimeEnvironments:connect and check for remoteControl or Tailscale hint usage.
rg -n -C 6 "runtimeEnvironments:connect|\bconnect\s*\(" --type=ts -g '!**/*.test.ts' src/preload src/renderer | rg -n -C 6 "connect" | head -n 120
rg -n -C 4 "remoteControl" --type=ts -g '!**/*.test.ts' src/renderer src/preload | head -n 80

Repository: stablyai/orca

Length of output: 19419


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings

Length of output: 38275


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- changed handler ---'
sed -n '110,175p' src/main/ipc/runtime-environment-connectivity-handlers.ts
printf '%s\n' '--- transport routing ---'
rg -n -C 12 "getRuntimeEnvironmentStatus|withTailscaleHintForResponse|attachRemoteControlDiagnostics" src/main/ipc/runtime-environment-transport-routing.ts
printf '%s\n' '--- bridge and relevant types ---'
sed -n '35,70p' src/preload/api/runtime-environments-bridge.ts
rg -n -C 8 "type RuntimeRpcResponse|interface RuntimeRpcResponse|remoteControl|withTailscaleHintForResponse|attachRemoteControlDiagnostics" src/main src/preload src/renderer/src --glob '*.ts' --glob '*.tsx' | head -n 240
printf '%s\n' '--- explicit connect helper and status consumers ---'
sed -n '1,120p' src/renderer/src/components/status-bar/runtime-environment-explicit-connect.ts
sed -n '1,150p' src/renderer/src/components/status-bar/SshStatusSegment.tsx
sed -n '1,115p' src/renderer/src/components/status-bar/remote-host-connection-status.ts

Repository: stablyai/orca

Length of output: 41458


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- all runtime connect call sites ---'
rg -n -C 10 "runtimeEnvironments\.connect|ipcRenderer\.invoke\(['\"]runtimeEnvironments:connect|runtimeEnvironments:connect" src --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- hint and diagnostics definitions/callers ---'
rg -n -C 14 "function withTailscaleHintForResponse|const withTailscaleHintForResponse|function attachRemoteControlDiagnostics|const attachRemoteControlDiagnostics|withTailscaleHintForResponse\(|attachRemoteControlDiagnostics\(" src/main src --glob '*.ts' --glob '*.tsx'

Repository: stablyai/orca

Length of output: 38612


🏁 Script executed:

#!/bin/bash
set -eu
sed -n '120,165p' src/main/ipc/runtime-environment-connectivity-handlers.ts
sed -n '1,220p' src/main/ipc/runtime-environment-transport-routing.ts
sed -n '1,90p' src/renderer/src/components/status-bar/runtime-environment-explicit-connect.ts
rg -n -C 8 "runtimeEnvironments\.connect|remoteControl|withTailscaleHintForResponse|attachRemoteControlDiagnostics" src/main src/preload src/renderer/src --glob '*.ts' --glob '*.tsx' | head -n 260

Repository: stablyai/orca

Length of output: 36382


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- status owner refresh contract ---'
rg -n -C 16 "class .*Status|refresh\s*\(|getRuntimeEnvironmentStatusOwner" src/main/ipc/runtime-environment-request-connections.ts
printf '%s\n' '--- connect-related error handling ---'
rg -n -C 12 "unwrapRuntimeRpcResult|extractRuntimeTransportDiagnostics|runtimeEnvironments\.connect|Remote host is not reachable|withRemoteRuntimeTailscaleHint" src/renderer/src src/main --glob '*.ts' --glob '*.tsx' | head -n 260

Repository: stablyai/orca

Length of output: 25871


🏁 Script executed:

#!/bin/bash
set -eu
rg -n -C 12 "createRuntimeEnvironmentStatusOwner|export class RuntimeHostStatusOwner|class RuntimeHostStatusOwner|refresh\(\):" src/main src/shared --glob '*.ts'

Repository: stablyai/orca

Length of output: 23435


🏁 Script executed:

#!/bin/bash
set -eu
sed -n '1,260p' src/shared/runtime-host-status-owner.ts

Repository: stablyai/orca

Length of output: 7650


Preserve response diagnostics on runtimeEnvironments:connect. RuntimeHostStatusOwner.refresh resolves transport failures as responses. The connect handler returns that response before applying withTailscaleHintForResponse and attachRemoteControlDiagnostics. The renderer stores the returned status, and SshStatusSegment reads status.remoteControl, so connect can lose the Tailscale hint and remote-control diagnostics. Apply the same decorators to the connect path.

Comment on lines +54 to +56
} catch (error) {
console.error('Failed to read runtime host status:', error)
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Report snapshot read failures to callers.

readRuntimeHostStatusSnapshots logs the error and resolves normally. Callers then continue as if renderer state was synchronized. A failed read can leave a stale host status after a completed probe.

Return a result that identifies failure, or rethrow the error so callers can handle the synchronization failure.

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

Important

The new commit introduces no new issues, but the two findings from the prior review remain unaddressed, so this stays unapproved.

Reviewed changes

  • Dropped the onCapable/onAbsent verdict callbacks — applyRuntimeEnvironmentCapabilityVerdict now returns only its acceptance boolean; the single production caller (runtime-environment-status-owner.ts) already gated its establish/pause on that return value, so the callbacks were dead API.
  • Rendered terminally-blocked hosts honestly — runtimeHostConnectionStateForEntry now maps verification: 'blocked' to disconnected instead of reconnecting, so a host that answered with an unauthorized/protocol error no longer implies automatic recovery. Backed by a new failing-capable test.
  • Removed the publishUnreachable refresh option — no production caller passed it and the snapshot path already bypassed it; the slice signature and its test matrix were simplified accordingly.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

Important

This commit is clean, but the two findings from the prior review remain unaddressed, so this stays unapproved.

Reviewed changes

  • Preserved timeout guidance — RuntimeHostStatusOwner.refresh now distinguishes its timeout message: a ready transport reports Status request timed out. (socket up, runtime slow) while an unready transport reports Timed out waiting for the remote Orca runtime. (unreachable). Covered by a new it.each test over both transports.
  • Updated IPC test fixtures — useIpcEvents-lifecycle.test.ts now expects runtimeEnvironments.onStatusChanged in place of onSharedControlDiagnostics; ipc-events-test-harness.ts stubs getStatusSnapshots; the Tailscale-hint test mocks electron and resets shared-control support between cases.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
tests/e2e/runtime-host-status-recovery.spec.ts (2)

99-99: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Move resource setup inside the cleanup boundary. If headless.client.call, interruptibleHost, or launchPairedElectronClient rejects before try, the finally block does not run. The headless host or proxy can remain active and affect later tests.


129-131: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the browser viewer is disconnected before reconnection.

The offline assertion currently checks only client.page. If the browser viewer keeps transport: 'ready', its later transport: 'ready' assertion still passes after reconnection. Poll statusEvidence(browser!.page) for transport: 'disconnected' before calling proxy.setOnline(true).

src/renderer/src/store/slices/runtime-status.ts (1)

46-56: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Propagate snapshot-read failures to callers.

readRuntimeHostStatusSnapshots catches IPC failures and resolves successfully. AddRemoteHostDialog then reports success and closes while runtimeStatusByEnvironmentId can still contain stale entries. Propagate the failure and handle it before callers report synchronization success; no later onStatusChanged event is guaranteed.

src/renderer/src/store/slices/runtime-status-refresh.ts (1)

19-19: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep snapshot synchronization failures separate from status-probe failures. refreshRuntimeEnvironmentStatus wraps getStatus and getStatusSnapshots in one try. If getStatus succeeds but snapshot retrieval or application throws, the catch publishes status: null and returns false. When the entry has no prior snapshot, setRuntimeEnvironmentStatus records that null and shows the disconnected-host toast, so a snapshot failure can appear as a host outage. Handle snapshot errors separately and preserve or report the successful probe result.

src/main/ipc/runtime-environment-connectivity-handlers.ts (1)

145-148: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Apply the status-response decorators to runtimeEnvironments:connect.

The status route wraps refresh() with withTailscaleHintForResponse and attachRemoteControlDiagnostics, but connect returns refresh() directly. The status-bar caller stores the unwrapped result as RuntimeStatus, so a compatible reconnect can omit remoteControl diagnostics and the standard Tailscale guidance. Return the response through both decorators.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d7c98632-2950-4d11-8267-22beb6678c66

📥 Commits

Reviewing files that changed from the base of the PR and between 354922f and e283501.

📒 Files selected for processing (9)
  • src/main/ipc/runtime-environment-capability-evidence.test.ts
  • src/main/ipc/runtime-environment-capability-evidence.ts
  • src/main/ipc/runtime-environment-request-connections.test.ts
  • src/renderer/src/runtime/runtime-host-connection-state.test.ts
  • src/renderer/src/runtime/runtime-host-connection-state.ts
  • src/renderer/src/store/slices/runtime-status-restored-browser-host-attach.test.ts
  • src/renderer/src/store/slices/runtime-status-types.ts
  • src/renderer/src/store/slices/runtime-status.test.ts
  • src/renderer/src/store/slices/runtime-status.ts
💤 Files with no reviewable changes (1)
  • src/main/ipc/runtime-environment-capability-evidence.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

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

Run ID: 69a378e7-5710-4434-a45e-8b9b34b43911

📥 Commits

Reviewing files that changed from the base of the PR and between e283501 and 7933283.

📒 Files selected for processing (6)
  • src/main/ipc/runtime-environment-shared-control-support.ts
  • src/main/ipc/runtime-environment-transport-routing-tailscale-hint.test.ts
  • src/renderer/src/hooks/ipc-events-test-harness.ts
  • src/renderer/src/hooks/useIpcEvents-lifecycle.test.ts
  • src/shared/runtime-host-status-owner.test.ts
  • src/shared/runtime-host-status-owner.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/shared/runtime-host-status-owner.ts
  • src/main/ipc/runtime-environment-shared-control-support.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

'ui.onMobileMarkdownRequest',
'automations.onChanged',
'runtimeEnvironments.onSharedControlDiagnostics',
'runtimeEnvironments.onStatusChanged',

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add runtimeEnvironments.getStatusSnapshots to the expected sequence.

installAppLifetimeIpcEvents calls getStatusSnapshots() immediately after onStatusChanged registration. The proxy records this call in registrationOrder. The expected sequence omits it, so the registration-order assertion will fail.

Proposed fix
   'automations.onChanged',
   'runtimeEnvironments.onStatusChanged',
+  'runtimeEnvironments.getStatusSnapshots',
   'repos.onChanged',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'runtimeEnvironments.onStatusChanged',
'runtimeEnvironments.onStatusChanged',
'runtimeEnvironments.getStatusSnapshots',

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

✅ No new issues found.

Reviewed changes

  • Restored status-response decorators on connect — the connect handler now routes through getRuntimeEnvironmentStatus(..., { reconnect: true }), which re-applies withTailscaleHintForResponse and attachRemoteControlDiagnostics that were dropped when it called the owner's refresh directly.
  • Aligned registry-fed surfaces with the renderer derivation — execution-host-registry controlHealth maps absent/checking/unknown-transport snapshots to connecting (no longer disconnected), and retains last-known status metadata via metadata = status ?? snapshot?.status, closing the "not-probed-yet ≠ disconnected" gap.
  • Kept snapshot-read failures from faking a host outage — refreshRuntimeEnvironmentStatus now logs and swallows a failed snapshot IPC read instead of publishing status: null and returning false.
  • Tightened the test suite — per-test resetRuntimeEnvironmentStatusOwners() teardown across the IPC suite, explicit vi.waitFor/.poll timeouts, it.each diagnostics coverage, and the e2e spec scopes resource setup to try/finally and asserts the browser viewer goes offline before reconnection.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

✅ No new issues found.

Reviewed changes

  • Added a workspace-host appearance assertion helper — expectWorkspaceHostAppearance pins the worktree card's dimmed opacity (0.6), ServerOff/Server glyph with text-destructive/text-muted-foreground, and the "disconnected" vs "Project on …" hover tooltip. The assertions match worktree-card-surface.tsx (opacity-60) and worktree-card-header.tsx / NoticeHostGlyph.tsx.
  • Extended the e2e journey — after the manual-disconnect block it now drives an explicit runtimeEnvironments.connect and re-asserts restored appearance for both the desktop and browser viewers, plus recovery/restored screenshots.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

✅ No new issues found.

Reviewed changes

  • Tightened the Cmd+J palette host-badge gate — hasActiveRemoteHost now requires a verified available non-local host (health === 'available') instead of merely !== 'disconnected', so a connecting/blocked/error host no longer implies a live remote to disambiguate from. A new it.each test pins the gate for every non-available health while the explicit filter-label path (alwaysShowHostLabel) still returns the badge.
  • Corrected the sidebar host-options fixture — an unprobed runtime host now reads health: 'connecting' in the test, matching the registry's absent-entry mapping added earlier, replacing the stale disconnected expectation.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

✅ No new issues found.

Reviewed changes

  • Retained disconnected host snapshots for late renderers — the disconnect handler now recreates the status owner after invalidateTransport tears the old one down, and the owner's manual-disconnect guard immediately retires it, so a renderer that opens after the disconnect and only reads runtimeEnvironments:getStatusSnapshots sees a retired snapshot instead of nothing.
  • Pinned the behavior in the pairing suite — the "disconnects a saved runtime without removing it" test now asserts the retained { retired: true, transport: 'disconnected' } snapshot, and that a subsequent connect restores a verified, non-retired snapshot.

Traced the mechanism end to end: invalidateRuntimeEnvironmentTransport synchronously runs closeRemoteRuntimeRequestConnection(environment.id) (dispose + delete) before the bare getRuntimeEnvironmentStatusOwner(...) call, so the getter always recreates a fresh owner whose isRuntimeEnvironmentManuallyDisconnected guard marks it retired. Correct as written.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 3b82d8d into main Sep 11, 2026
34 checks passed
nwparker added a commit that referenced this pull request Sep 11, 2026
#20003 moved failed-status retries into the connection's status owner and split
the vocabulary this PR's guard was written against: the store entry's `status`
now means "verified on the current socket", while the owner's
`snapshot.status` keeps the last verdict across an unverifiable probe. The
guard itself is unchanged and still correct — it is the only writer for a
`status.get` that threw, where there is no snapshot and no retry ladder — but
its comment described a recheck ladder that no longer exists.

The e2e flap arm's `sawNullStatus` gate does not survive that split. Under
#20003 a dropped socket publishes `verification: 'unavailable'` and the
renderer derives `entry.status = null` from it by design, and that null is
what drives the session-tabs mirror's own rebuild once the socket returns.
Asserting it stays non-null would contradict the recovery the same arm
measures, so it is logged rather than gated. The connection-generation and
pane-mounted assertions, which are the actual #19647 contract, are unchanged.
nwparker added a commit that referenced this pull request Sep 11, 2026
#20003 moved failed-status retries into the connection's status owner and split
the vocabulary this PR's guard was written against: the store entry's `status`
now means "verified on the current socket", while the owner's
`snapshot.status` keeps the last verdict across an unverifiable probe. The
guard itself is unchanged and still correct — it is the only writer for a
`status.get` that threw, where there is no snapshot and no retry ladder — but
its comment described a recheck ladder that no longer exists.

The e2e flap arm's `sawNullStatus` gate does not survive that split. Under
#20003 a dropped socket publishes `verification: 'unavailable'` and the
renderer derives `entry.status = null` from it by design, and that null is
what drives the session-tabs mirror's own rebuild once the socket returns.
Asserting it stays non-null would contradict the recovery the same arm
measures, so it is logged rather than gated. The connection-generation and
pane-mounted assertions, which are the actual #19647 contract, are unchanged.
brennanb2025 added a commit that referenced this pull request Sep 15, 2026
…s it (#20762)

* fix(e2e): seed the runtime host with a snapshot the host cannot overwrite

Since #20003 the published snapshot owns runtime-host health, so a bare status
seed no longer survives: main's status owner publishes `checking` for this
unreachable synthetic host as soon as any runtime RPC touches it, the host
reads `connecting`, and the Add Project dialog falls back to Local — so the
host-scoped copy the test asserts never renders.

Seed a snapshot pinned at the top sequence instead. applyRuntimeHostStatusSnapshot
drops any later publication whose sequence is not higher, and setRuntimeEnvironmentStatus
no-ops a snapshot-less write once a snapshot exists, so the bare seed could not
have worked either way.

Ablated: passes with the pinned snapshot, fails without it.

* fix(e2e): fabricate paired-web host health through the snapshot that owns it

Companion to the onboarding seed fix. Since #20003 the published snapshot owns
runtime-host health, so writing `status: null` alone leaves the paired-web
client's verified/ready snapshot in place: addRuntimeHost reads
snapshot.transport 'ready' before it ever consults status, and the host still
renders Connected while the test waits for Disconnected.

Rewrite the snapshot coherently instead, pinned at the top sequence so the live
status owner cannot restore the host mid-assertion. The disconnected leg uses
transport 'unknown' rather than 'disconnected', because a dropped transport is
unverifiable and renders as Connecting; only a never-reached host renders
Disconnected. remoteControl is nulled because runtimeControlHealth answers
'available' on a ready control socket even with a null status.

Ablated with ORCA_E2E_WEB_CLIENT=1 (the whole file is test.skip'd without it,
so a run without that flag reports a passing skip): fails without the change,
passes with it.

* test(e2e): preserve paired runtime status metadata
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…s it (stablyai#20762)

* fix(e2e): seed the runtime host with a snapshot the host cannot overwrite

Since stablyai#20003 the published snapshot owns runtime-host health, so a bare status
seed no longer survives: main's status owner publishes `checking` for this
unreachable synthetic host as soon as any runtime RPC touches it, the host
reads `connecting`, and the Add Project dialog falls back to Local — so the
host-scoped copy the test asserts never renders.

Seed a snapshot pinned at the top sequence instead. applyRuntimeHostStatusSnapshot
drops any later publication whose sequence is not higher, and setRuntimeEnvironmentStatus
no-ops a snapshot-less write once a snapshot exists, so the bare seed could not
have worked either way.

Ablated: passes with the pinned snapshot, fails without it.

* fix(e2e): fabricate paired-web host health through the snapshot that owns it

Companion to the onboarding seed fix. Since stablyai#20003 the published snapshot owns
runtime-host health, so writing `status: null` alone leaves the paired-web
client's verified/ready snapshot in place: addRuntimeHost reads
snapshot.transport 'ready' before it ever consults status, and the host still
renders Connected while the test waits for Disconnected.

Rewrite the snapshot coherently instead, pinned at the top sequence so the live
status owner cannot restore the host mid-assertion. The disconnected leg uses
transport 'unknown' rather than 'disconnected', because a dropped transport is
unverifiable and renders as Connecting; only a never-reached host renders
Disconnected. remoteControl is nulled because runtimeControlHealth answers
'available' on a ready control socket even with a null status.

Ablated with ORCA_E2E_WEB_CLIENT=1 (the whole file is test.skip'd without it,
so a run without that flag reports a passing skip): fails without the change,
passes with it.

* test(e2e): preserve paired runtime status metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant