Repository navigation
fix(sidebar): recover the runtime host disconnected glyph - #16518
ASDFGHoney wants to merge 8 commits into
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughRuntime host status derivation now distinguishes disconnected hosts from unprobed and reconnecting hosts. UI surfaces use shared entry-based state helpers. Runtime status refreshes return reachable, unreachable, or superseded outcomes. Recovery probes target disconnected environments with backoff and retry scheduling. Successful remote runtime RPC calls report reachability. Tests cover state rendering, refresh outcomes, recovery behavior, RPC feedback, and end-to-end recovery. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description is complete and aligned with the repository template. It explains the problem, implementation, rationale, linked issue, visual proof, testing, AI use, review considerations, and checklist status. Full details: Linked Issues checkExplanation The changes satisfy issue Full details: Out of Scope Changes checkExplanation The production changes, shared helpers, recovery logic, and tests are directly related to runtime host recovery and sidebar disconnected-state rendering. No unrelated code or platform-specific changes are evident. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 69940146-ca92-4e60-b1b8-221a222c57ca
📥 Commits
Reviewing files that changed from the base of the PR and between 76f7e78 and 817bab7cf37d5e910af29bad31c4ed2d6b058565.
📒 Files selected for processing (12)
src/renderer/src/components/sidebar/NoticeHostGlyph.test.tsxsrc/renderer/src/components/sidebar/NoticeHostGlyph.tsxsrc/renderer/src/components/sidebar/WorktreeCard.ssh-reconnect-prompt.test.tsxsrc/renderer/src/components/sidebar/use-worktree-card-foundation.tssrc/renderer/src/components/sidebar/worktree-card-runtime-host-state.test.tssrc/renderer/src/runtime/runtime-rpc-client.tssrc/renderer/src/runtime/runtime-status-recovery-probe.test.tssrc/renderer/src/runtime/runtime-status-recovery-probe.tssrc/renderer/src/runtime/runtime-status-recovery-rpc-feedback.test.tssrc/renderer/src/runtime/use-remote-runtime-recovery-triggers.test.tssrc/renderer/src/runtime/use-remote-runtime-recovery-triggers.tstests/e2e/sidebar-runtime-host-disconnected-glyph.spec.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
`runtimeStatusByEnvironmentId` was written only by explicit probes — boot hydration, the status-bar host dropdown, the settings pane, and the connect/disconnect actions. Nothing fed a transport that recovered on its own back into it, so a boot probe that failed (host asleep, network not up yet) pinned a live remote server to a red ServerOff glyph and an opacity-60 card for the rest of the session, while its mirroring, agents and terminals kept working over the same connection. The state was self-reinforcing: `getRuntimeClientEventEnvironmentIds` subscribes client events only for environments whose status is truthy, so a non-active environment stuck on `null` never got the subscription that could have reported its own reconnect. Add a recovery probe with two triggers, both of which only ask `refreshRuntimeEnvironmentStatus` to run the real `status.get` again: - an answered remote request is evidence the host is reachable, so a stale entry gets re-probed on the next call through `callRuntimeRpc` - entries still recorded unreachable are re-probed on a per-host backoff (5s doubling to 60s), collapsed on `online`/system-resume alongside the shared-control and pane recovery backoffs Neither trigger decides reachability itself: consumers read the whole `RuntimeStatus`, and per docs/reference/ssh-execution-boundary.md loss of contact is never evidence of death in either direction. A manually disconnected host still answers `ok: false` locally, so it stays disconnected. The sidebar also judged the glyph on raw truthiness instead of the shared `runtimeHostConnectionState`, painting "disconnected" over hosts that had simply not been probed yet. Both sidebar surfaces now use the derivation, so only its 'disconnected' verdict earns the destructive glyph and the dim. Fixes stablyai#16516 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The unprobed-vs-unreachable split happens in the selector that feeds the worktree card's render, so a store-slice test cannot see the glyph and the dim it produces. Seed a runtime-host workspace, drive the recorded probe result, and assert on the rendered card across all three states.
817bab7 to
586ed72
Compare
The sweep deferred re-arming to the probe's own `finally`, so a refresh that never settled — a wedged IPC round trip — ended the recovery loop for every other host, not just its own. A host whose backoff came due afterwards was never re-probed. Re-arm on every sweep instead. A probe in flight contributes a pending guard rather than its stored deadline, which is already in the past: scheduling against that deadline would spin, and skipping the schedule is what stranded the other hosts. Reported by CodeRabbit on stablyai#16518.
Code review — two axes: Standards / SpecFixed point: The two axes ran independently. They are reported side by side, unmerged and unranked against each other, so neither masks the other. StandardsA. Documented-standard violations1. 2. A third encoding of the same predicate, already out of step with the derivation 3. Duplication inside the port B. Judgement calls (smell baseline)4. Mysterious Name / vocabulary collision — 5. Possible Speculative Generality / Middle Man — 6. Hot path — 7. Divergence from a neighbouring convention — 8. Comments — the three-line Checked, not violationsThe e2e spec honours Spec (against #16516)The two core requirements are genuinely met. After a boot probe records (a) Missing or partial
(b) Not asked for
(c) Implemented but looks wrong
Summary — Standards: 8 findings (3 hard / 5 judgement calls); worst is #2 — Both worst findings sit in the same pair of files ( Two-axis review by Claude Opus 5 (Claude Code) — Standards and Spec run as independent sub-agents. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e6c3735f-e457-4f9e-a8d8-5ddc6e706856
📥 Commits
Reviewing files that changed from the base of the PR and between 817bab7cf37d5e910af29bad31c4ed2d6b058565 and fffa301.
📒 Files selected for processing (2)
src/renderer/src/runtime/runtime-status-recovery-probe.test.tssrc/renderer/src/runtime/runtime-status-recovery-probe.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
`noteRuntimeEnvironmentReachable` dropped the backoff entry before every probe, so a host that answers requests while its `status.get` keeps failing was re-probed once per RPC — 21 probes for 20 requests in the new test. Gating traffic on the failure deadline instead would regress what this PR exists to fix: `backoffFor` seeds `nextAttemptAt` 5s out on first sighting, so the very first traffic probe after a failed boot probe never runs, and at the 60s cap a host the user is actively working with keeps the red glyph for another minute (stablyai#16516). That variant fails 8 of these tests, 3 of them pre-existing. Traffic gets a floor of its own instead — the sweep's base interval — so it can never probe faster than the recovery loop already does while still recovering within 5s however long the outage ran. The backoff entry now survives a traffic probe, so answered requests no longer reset the sweep's widening retry budget. Reported by CodeRabbit on stablyai#16518. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/runtime/runtime-status-recovery-probe.ts (1)
180-198: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winIsolate probe completion from a stopped session.
probe()mutates the globalprobingEnvironments,backoffByEnvironment, and timer state afterrefreshRuntimeEnvironmentStatus()settles. A stopped session can clear these structures before an old probe settles, so its completion can clear a new session’s in-flight marker and re-arm a duplicate probe. Guard all completion handlers with a per-session token.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7ea829c9-a6b8-4964-8636-4c0b5867c358
📒 Files selected for processing (3)
src/renderer/src/runtime/runtime-status-recovery-probe.test.tssrc/renderer/src/runtime/runtime-status-recovery-probe.tssrc/renderer/src/runtime/runtime-status-recovery-rpc-feedback.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
`{ hasStatusEntry: Boolean(entry), status: entry?.status }` was re-assembled at four
call sites, two of them with the same three-line comment. Re-assembling the argument
per surface is how the sidebar drifted into its own predicate in the first place, so
`runtimeHostConnectionStateForEntry` takes the store entry directly and
`isDisconnectedRuntimeHostState` names the verdict the glyph and the recovery loop
must share.
Deliberate, and now pinned by a test: a host with `remoteControl.state === 'closed'`
and a `lastError` keeps reading disconnected in the sidebar. The status bar and
Settings > Available Hosts already called it that; the sidebar was the outlier, and
that channel closing with an error is the host's own report, not silence.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`use-remote-runtime-recovery-triggers.ts` encoded "disconnected" as `entry.status === null`, but `runtimeHostConnectionState` also returns 'disconnected' for `remoteControl.state === 'closed' && lastError`, where `status` is truthy. Such a host got the red glyph and the dimmed card while the recovery probe never considered it a candidate, so its red state was terminal for the session — the exact defect stablyai#16516 is about, reintroduced one derivation over. Both the port predicate and its candidate list now come from the shared derivation. Once the candidate set includes hosts with a truthy status, a successful `status.get` stops being proof of recovery: such a host would clear its backoff on every probe and be re-probed at the base interval forever. The probe therefore re-reads the verdict after the refresh instead of trusting the RPC's own answer. A revision mismatch is also not a reachability failure. `refreshRuntimeEnvironmentStatus` returned `false` without publishing when a same-id re-pair retired the answer in flight, and the probe charged that against the new pairing's retry budget. `refreshRuntimeEnvironmentStatusOutcome` reports 'reachable' / 'unreachable' / 'superseded'; the boolean action is now its projection, so every existing caller — `runtime-environment-disconnect-toast.ts` included — is untouched. Also: optional-chain the slice lookup, the way `retainRuntimeDetectedAgents?.()` already does for minimal store assemblies, and `unref()` the sweep timer to match `remote-runtime-pty-recovery-state.ts`. The E2E gains a second spec that drives the loop rather than writing the status map: it seeds a closed-control-channel host, stubs only the probe's network leg, and fires `online`. The app decides what to probe and when. It fails against the old predicate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks — this was a good review. Worked through both axes finding by finding. Re-verified against Two new commits: Standards#2 — a third encoding of the predicate · fixed (
|
| shape | per-RPC cost |
|---|---|
| predicate (kept) | getState() + Map.get + ≤5 comparisons — O(1), zero allocations |
| derived from the list | [...map].filter().map() — O(total environments), 3 allocations |
Shrinking the surface by one method would put an array build and two intermediate arrays on the hot path to save a four-line method. The predicate is also now load-bearing a second time — probe() re-reads it to decide whether recovery actually happened (see #2) — so it is no longer a pure projection of the list.
#5 — four-method port with one production impl · kept, cycle proven
Not speculative generality: the port is what keeps the cycle open. Concretely, on HEAD —
@/store → store/slices/runtime-status.ts:9 (imports clearRuntimeCompatibilityCache
→ @/runtime/runtime-rpc-client)
runtime-rpc-client.ts:10 → ./runtime-status-recovery-probe
so a @/store import inside runtime-status-recovery-probe.ts closes store → runtime-status → runtime-rpc-client → recovery-probe → store. The test doubles are a side benefit, not the reason. Left at four methods (see #3 for why the fourth stays).
#6 — hot path · checked, within budget; reasoned, not benchmarked
Two additions, measured against docs/reference/renderer-agent-status-performance.md's own model (burst work ≈ status events × store listeners × selector work):
- Per-RPC.
getState()is a closure property read;Map.getis O(1);runtimeHostConnectionStateForEntryisBoolean(entry)plus at most three field reads plusisRuntimeWorkspaceWindowClosed(two comparisons,runtime-workspace-window-availability.ts:9-14). No allocation, no iteration — same order as theentry.status === nullit replaced, a handful more comparisons. Not on the agent-status burst path at all. - The subscription. One additional Zustand listener whose whole body is a reference comparison on
state.runtimeStatusByEnvironmentId, with an early return. It does no selector work, so it contributes to thelistenersterm only. Against the doc's pinned censuses — 1,218 listeners for the 100-worktree fixture without agents, 1,618 with 100 agent rows, 8,518 / 9,279 on the pre-design baseline — that is one listener out of ≥1,218, i.e. ≤0.08%, and it is a single app-shell subscription, not per-card, so none of the per-surface budgets in the doc's table move.
What I did not do: run pnpm bench:idle-cpu. That harness wants a built Electron runtime and a quiet machine to produce numbers comparable to the doc's baseline, and a noisy run would be worse than no number. The reasoning above is from the doc's model and its own pinned figures; if you want the harness run before merge, say so and I will.
Spec
(c)1 — the traffic trigger defeats the backoff · already fixed in 3e349bc3ca
Confirmed for myself rather than taking it on faith. That commit predates the review's fixed point by one, so the review could not see it. noteRuntimeEnvironmentReachable no longer calls backoffByEnvironment.delete; RecoveryBackoff gained trafficProbedAt, and traffic gets its own floor of RECOVERY_PROBE_BASE_DELAY_MS (runtime-status-recovery-probe.ts:189-200). Covered by does not turn RPC frequency into probe frequency after a failed probe and lets traffic probe again once the floor between traffic probes has elapsed. The description's "per-host backoff" claim now holds.
(c)3 — a revision mismatch is not a reachability failure · fixed (4f54271129)
Agreed, and there is a real window even though a same-id re-pair does clear the entry (runtime-status.ts deletes replacedEnvironmentIds from nextStatuses): a probe in flight across the re-pair resolves after the new pairing's own boot probe has recorded status: null, and recordProbeFailure then charged the old pairing's answer to the new host — 10s instead of 5s, compounding per stale in-flight probe.
Signal change, kept minimal and non-breaking:
runtime-status-refresh.tsreturnsRuntimeStatusRefreshOutcome = 'reachable' | 'unreachable' | 'superseded'.- The slice exposes
refreshRuntimeEnvironmentStatusOutcome;refreshRuntimeEnvironmentStatusis now its one-line projection (=== 'reachable'), so every existing caller is untouched —runtime-environment-disconnect-toast.ts:55,sidebar-worktree-activation.ts,ephemeral-vm-worktree-creation.ts,hydrateRuntimeEnvironmentStatuses, and ~12 E2E helpers all keep reading the boolean. - Only the recovery port takes the outcome.
One thing the review's framing missed, worth flagging: "leave the budget alone" cannot be implemented as a bare return. The deadline is already in the past when the probe fires, so rearmSweep computes a 0ms timer and spins — I hit exactly that, 5001 calls in a 5s tick. It re-arms at the current interval without incrementing failures instead (deferProbeWithoutPenalty): nothing learned, nothing charged, no spin.
Tests: runtime-status-recovery-probe.test.ts › does not count a superseded probe against the host (confirmed red pre-fix), and the existing runtime-status.test.ts › drops a stale refresh %s after the same environment id is re-paired now also asserts resolves.toBe('superseded').
(c)4 — missing optional chaining · fixed (4f54271129)
Confirmed it throws. Now refreshRuntimeEnvironmentStatusOutcome?.(environmentId) ?? Promise.resolve('superseded' as const), matching the retainRuntimeDetectedAgents?.() idiom in runtime-status.ts. The superseded fallback is deliberate: a store without the slice never asked the host, so the loop must learn nothing rather than count a failure. Test: survives a store assembly without the runtime-status slice, confirmed red without the ?..
(b)1 — "red spreads" · kept deliberately, and now pinned by tests
This is the one judgement call, so, explicitly: the widening is correct and stays.
The only behavioural expansion is remoteControl.state === 'closed' && lastError. Reasons, in order of weight:
- The sidebar was the outlier, not the new behaviour. The status bar (
SshStatusSegment→runtimeStatusForOverall→'disconnected') and Settings › Available Hosts (RepositoryHostSetupsSection→isConnectedRuntimeHostState→ false) already called that host disconnected. Three surfaces disagreeing about one host is precisely whatruntimeHostConnectionState's own doc comment exists to prevent. - It is not a loss-of-contact inference.
ssh-execution-boundary.mdforbids reading silence as death. A control channel that transitioned toclosedand recorded alastErroris the host's own report — positive evidence, not absence of it.reconnectingand "no entry" stay unverifiable and stay un-red, which is the direction [Bug]: A saved Orca server stays "disconnected" in the sidebar for the whole session after one failed boot probe #16516 asked for. - Narrowing it would mean writing a fourth private predicate — the exact drift Fix Ctrl+Backspace not deleting word in terminal #2 flags — and it would have to live in the sidebar only.
- It is no longer red-and-forgotten. Before, that host had a red glyph in two surfaces and no retry anywhere. Now the same derivation feeds the recovery loop, so it is re-probed like every other disconnected host. Most of the discomfort in "red spreads" was really "red is terminal", and Fix Ctrl+Backspace not deleting word in terminal #2 removed that.
Pinned in three places so it cannot drift back silently: worktree-card-runtime-host-state.test.ts › still reports a host whose remote control closed with an error, runtime-host-connection-state.test.ts › names the disconnected verdict for the glyph and the recovery loop alike, and E2E spec 2, which renders it.
(c)5 — the PR description overclaims · fixed both ways
You are right that spec 1 cannot demonstrate row 3: it writes store.setState itself, so the recovery is performed by the test.
Rather than only softening the prose, I added a second E2E spec that drives the loop: it seeds a host whose control channel closed with an error, replaces only the probe's network leg (the store's probe action), fires window.dispatchEvent(new Event('online')) — a real production trigger — and touches nothing else. The scheduler, its backoff, the port's candidate list, the real setRuntimeEnvironmentStatus publication and the card's selectors all run; the app decides what to probe and when. It then asserts the DOM recovered and that the loop actually enumerated that environment id.
It is a real regression test: against the pre-fix candidate list it fails with element(s) not found for svg.lucide-server — the card stays red, because the loop never enumerates a closed + lastError host.
The PR body's Visual Proof section is also rewritten: the two specs are now separate tables, spec 1 is labelled as showing the rendered verdict only ("It does not exercise the recovery loop, and is not evidence about it"), and the "was terminal for the session" claim now sits with spec 2, which demonstrates it.
(c)2 — publish the status ensureRuntimeEnvironmentCompatible already holds · declined
Your own caution is the smaller half of the problem, but it is real: getCachedRuntimeCompatibilityCheck returns an entry carrying status + statusCheckedAt under a TTL, so a naive entry.status publish would republish a cached observation as freshly observed — the exact lie this PR exists to prevent. Only the fresh check IIFE (runtime-rpc-client.ts:123-136) has a genuinely fresh result.
Two further reasons it does not pay:
- Publishing is not just writing the map.
refreshRuntimeEnvironmentStatusOutcome's publish callback also runsensureBrowserClientHostsForRestoredPagesandreplayClientHostedBrowserCloseIntents(runtime-status.ts). FeedingsetRuntimeEnvironmentStatusdirectly, as suggested, would recover the glyph while silently skipping the restored-page re-attach and the close-intent replay — a worse bug than the round trip it saves. - It needs the cycle or a fifth port method.
runtime-rpc-client.tscannot import@/store(see Fix PTY listener leak, use local restty with selection support #5), so this would need a fifth method on the port Fix PTY listener leak, use local restty with selection support #5 already calls too big.
And the saving is one round trip, not a recovery: the same call path already triggers a real probe via noteRuntimeEnvironmentReachable, so the host recovers either way.
(a)1 getRuntimeClientEventEnvironmentIds · confirmed, and left untouched
Verified: runtime-environment-subscription-selection.ts:22-27 still gates on state.runtimeStatusByEnvironmentId?.get(id)?.status being truthy, unchanged. The review's "no functional impact" is right — the recovery probe calls window.api.runtimeEnvironments.getStatus directly and never depends on a client-event subscription, so the self-reinforcing loop is broken at the probe, not at the selection. Once a re-probe succeeds the status turns truthy and the subscription follows on the next reconcile.
Deliberately out of scope: subscribing client events for environments believed unreachable widens IPC fan-out on the path renderer-agent-status-performance.md budgets, for hosts that by definition are not answering. That is a separate change with its own perf argument.
(a)2 settings.ts:193 · confirmed, and left untouched
Verified at settings.ts:191-192 — the "A recorded null still means the host was checked" comment gates the all-host boot re-probe on coverage, and the recovery loop is a separate per-host clock that does not consult it. Removing the guard would fire an all-host probe burst on every settings refresh, which is what the guard is there to prevent. No impact.
(b) note — the issue's reconnecting claim · agreed, and corrected at the source
You are right: !entry?.status returns false whenever status is truthy, so a re-attaching host already drew a normal glyph. I wrote that sentence in #16516 and it was wrong. Corrected in the issue body, and the same claim removed from this PR's description.
(b) — online / system-resume wiring
Noted as outside the issue and left as is — it sits with the shared-control and pane-recovery backoffs already advanced in the same handler, and E2E spec 2 now uses it as its trigger.
Verification
All on 4f54271129:
pnpm tc— cleanpnpm test src/renderer/src/{runtime,components/sidebar,store/slices,hooks,components/settings,components/status-bar}/— 1035 files, 8490 tests passedoxlint --format=stylishon all 16 changed files — clean (exit 0; sanity-checked against a seededno-debuggerviolation so a silent no-op could not pass for a clean run)pnpm exec electron-vite build --mode e2ethenSKIP_BUILD=1 playwright test tests/e2e/sidebar-runtime-host-disconnected-glyph.spec.ts --project=electron-headless --workers=1— 2 passed (32.7s)
Every new test was confirmed red against the pre-fix source hunk before being kept — revert, run, restore:
| test | pre-fix result |
|---|---|
| re-probes a host whose control channel closed with an error | ✗ 1 failed | 5 passed |
| survives a store assembly without the runtime-status slice | ✗ 1 failed | 5 passed |
| keeps widening the backoff for a host that answers but still reads disconnected | ✗ 2 failed | 16 passed |
| does not count a superseded probe against the host | ✗ (same run) |
| E2E recovers a red card through the recovery loop, not a store write | ✗ element(s) not found for svg.lucide-server |
Known-red and unrelated (identical on origin/main): pnpm run typecheck:e2e (237 errors), worktree-jump-palette-filter.spec.ts, sidebar-agent-row-identity.spec.ts.
Not done
- No
bench:idle-cpurun for Fix MaxListenersExceededWarning with singleton PTY dispatcher #6 — reasoned from the doc's model and pinned censuses instead, see above. - CodeRabbit's 80% docstring threshold stays declined:
AGENTS.mdasks for concise, non-obvious, "WHY not HOW" comments, one line where possible, and padding files to hit a coverage number is directly opposed to that.
Addressed by Claude Opus 5 (Claude Code).
`probe()` writes `backoffByEnvironment`, `probingEnvironments` and the sweep timer after the refresh settles, but the stop function clears all three. A probe that outlives its session therefore lands in the next one: its `.finally` cleared the live session's in-flight marker and re-armed, so the following sweep opened a second probe for a host already being probed, and its verdict widened a retry budget it knew nothing about. React StrictMode makes this the common path, not a corner case — the port is installed from a `useEffect`, so every dev mount runs start/stop/start. A generation counter captured at probe start and bumped when the port is retired makes those completions settle into nothing. The sweep timer and the recorded-status subscription need no equivalent: neither captures per-session state, and stop clears the timer and unsubscribes before either can run. Reported by CodeRabbit on stablyai#16518.
CodeRabbit review 5026107015 — "Isolate probe completion from a stopped session" (Major)Confirmed and fixed in Reproduced first, both harmsI wrote the tests before touching the source and watched them fail against pre-fix The exact trace, with
The budget harm is separable, which is what assertion 2 pins: when A's probe settles before B's first attempt is due, the stale failure widens B's backoff and pushes B's first real attempt from 5s out to 11s — a host the user is looking at stays red a base interval longer for a verdict about a pairing that no longer exists. The fixA module-level generation counter, captured at Note the guard also keeps The other async completions in the module — no guard neededI checked both and they are not stale-able, so I did not add tokens there:
The bump sits inside the existing Verification
Not addressed, deliberately
Also still declining the 80% docstring coverage pre-merge check — this repo's AGENTS.md mandates concise, non-obvious, WHY-not-HOW comments, and padding docstrings to hit a percentage conflicts with it directly. |
|
Heads up: I hit this bug on my own setup and, not realizing how far this PR had gotten, put up #19163 for the same issue before I found it. Sorry for the overlap. Two servers, neither of them the active environment, app up ~28h, Mine is smaller and written against current Worth noting your write-up here still holds up on current Happy to close mine in favor of this one if you want to rebase it. Whichever a maintainer prefers is fine by me. |
ELI5
Orca remembered "I couldn't reach that server" from the moment it started up, and then never checked again. So if your remote Mac happened to be asleep when Orca launched, its workspaces stayed greyed out with a red "disconnected" icon for the rest of the day — even while you were happily running agents and terminals on that exact server.
This makes Orca ask again: whenever it successfully talks to a server it had written off, and on a slow retry timer otherwise. It never assumes the server is back — it just re-asks the question and believes the answer.
What Changed
The recovery loop. New
runtime-status-recovery-probe.tsre-runs the existingrefreshRuntimeEnvironmentStatus(a realstatus.get) for environments recorded unreachable,on two triggers:
callRuntimeRpcis the renderer's single remote-RPC chokepoint. Asuccessful response for an environment whose entry is
nullschedules one probe; every othercall is a no-op, and a burst collapses to one in-flight probe per environment.
nullare re-probed at 5s doubling to a 60s cap, each hoston its own clock.
onlineand system-resume collapse the backoff, alongside the shared-controland pane-recovery backoffs already advanced there.
The port carries a status-map subscription because the probe starts with the app shell, before
boot hydration has recorded anything — without it an empty map at start leaves it idle for good.
The sidebar verdict.
use-worktree-card-foundation.tsandNoticeHostGlyph.tsxnow use theshared
runtimeHostConnectionStatederivation the status bar and Settings › Available Hostsalready use, instead of raw truthiness.
runtimeHostConnectionStateForEntry(entry)+isDisconnectedRuntimeHostStatereplace the{ hasStatusEntry, status }assembly at all fourcall sites, and the recovery loop's candidate list reads the same two helpers — a host the
sidebar paints red is by construction a host the probe retries.
Why
runtimeStatusByEnvironmentIdwas written only by explicit probes: boot hydration, the status-barhost dropdown, the settings pane, and the connect/disconnect actions. Nothing fed a transport that
recovered on its own back into it, and
settings.ts:191deliberately treats a recordednullascovered ("A recorded null still means the host was checked"), so the coverage re-probe skipped it too.
It was also self-reinforcing:
getRuntimeClientEventEnvironmentIdssubscribes client events onlyfor environments whose status is truthy, so a non-active environment stuck on
nullnever got thesubscription that could have reported its own reconnect.
onReplayedAfterReconnectdoes notcover the boot case either — replays are tagged only once
everReadyis true.Why re-probe rather than infer. These surfaces read the whole
RuntimeStatus— capabilities,remoteControl, workspace-window availability — so "we exchanged a message, therefore connected"would be its own lie. Both triggers only ask the existing probe to run again and let its answer
stand. This is the
live/unverifiable/exitedrule fromdocs/reference/ssh-execution-boundary.md, applied in both directions: the old behaviour assertedexitedonunverifiableevidence and never revisited it; the fix must not overcorrect intoasserting
live.A manually disconnected environment is unaffected —
runtimeEnvironments:getStatusshort-circuitsto
ok: falselocally for it, so the re-probe re-confirmsnullwithout touching the network.On the sidebar side,
runtimeHostConnectionStatealready separated "no entry ⇒checking" from"entry with
status: null⇒disconnected". Reading truthiness collapsed those, so every remotecard was painted destructive between launch and the first probe. (
reconnectinghosts were notaffected — truthiness returns false whenever
statusis truthy. #16516 said otherwise and hasbeen corrected.)
Adopting the shared derivation does change one case deliberately: a host with
remoteControl.state === 'closed'and alastErrorhas a truthy status, so the old sidebar drewit normally while the status bar and Settings already called it disconnected. The sidebar was the
outlier, and a control channel that closed with an error is the host's own report rather than
silence, so
ssh-execution-boundary.mddoes not argue for softening it. It is not ared-and-forgotten state either: the same derivation now feeds the recovery loop's candidate list,
so that host is re-probed like any other.
No wire change: no new RPC params, stream frames, or published content, so mixed client/host
versions are unaffected. Folder workspaces and git worktrees reach the glyph through the same
repo
executionHostId, so both are covered by the same path.Linked Issue
Fixes #16516
Visual Proof
Captured by two E2E specs in
tests/e2e/sidebar-runtime-host-disconnected-glyph.spec.ts.Artifacts land in
test-results/…-electron-headless/.Spec 1 — the rendered verdict. Seeds each recorded state directly and screenshots the same
sidebar card, so it shows what the card draws for a given store entry. It does not exercise the
recovery loop, and is not evidence about it.
runtime-host-glyph-before-probe.pngServerOff, card atopacity-60Serverglyph, full opacitystatus: null(probe said unreachable)runtime-host-glyph-disconnected.pngServerOff, dimmedServerOff, dimmedruntime-host-glyph-recovered.pngServerglyphThe middle row is the deliberate no-change case: a host a probe actually reported unreachable must
still read disconnected.
Spec 2 — the loop, not a store write. Seeds a host whose control channel closed with an error,
stubs only the probe's network leg, then fires
onlineand touches nothing else. The scheduler,its candidate list, the real
setRuntimeEnvironmentStatuspublication and the card's selectors allrun; the app decides what to probe and when.
remoteControl: closed+lastErrorrecordedruntime-host-glyph-control-channel-closed.pngServerOff, dimmed (before this PR: plainServer)onlinefires, loop probes, host answersruntime-host-glyph-loop-recovered.pngServerglyph, full opacityThis is the spec that demonstrates the unreachable state is no longer terminal. It fails against
the pre-fix candidate list (
entry.status === null), which never enumerates this host: the cardstays red and
svg.lucide-serveris never found.Testing
Tested on macOS 26.5.2, against a paired remote macOS Orca server (
ws://…:6768) and locally.Not exercised on Linux or Windows; the change is renderer-only with no platform-dependent paths.
electron-headless,--workers=1): 2 passed in 32.7s(
src/renderer/src/{runtime,components/sidebar,store/slices,hooks,components/settings,components/status-bar}/)pnpm tccleanoxlintandoxfmtclean on changed filesPre-existing failures confirmed unrelated by re-running them on
origin/main@cac5388545,where they fail identically:
worktree-jump-palette-filter.spec.ts(2) andsidebar-agent-row-identity.spec.ts(1).pnpm run typecheck:e2eis also already red onmain(237 errors across 86 files); the new spec contributes none.
Manual reproduction of the original defect: put the paired host to sleep, launch Orca, wake the
host, then use the remote workspace. Before this PR the card stayed red until the status-bar host
dropdown was opened; after, the first answered request clears it.
AI Disclosure
Claude Opus 5 via Claude Code, under review.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
status.getpath and adds no data to it.ssh-execution-boundaryreasoning above.SSH host chips are untouched.
Map.geton the hot RPC path and returnsimmediately unless the entry is
null. The backoff timer only exists while some host isrecorded unreachable, and self-cancels when none is.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)