Skip to content

fix(runtime): publish remote control outages to host surfaces - #17531

Merged
brennanb2025 merged 10 commits into
mainfrom
brennanb2025/fix-false-green
Aug 31, 2026
Merged

brennanb2025 merged 10 commits into
mainfrom
brennanb2025/fix-false-green

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​173 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​168
Prod 28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​752 $\color{#cf222e}{\Huge{\mathbf{−}}}$​192 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​560

Summary

Remote Server host state could remain green after its shared-control transport closed because Settings trusted a mounted RuntimeHostDetails.status phase and the status store had no push path for transport transitions. This change publishes authoritative shared-control diagnostics on state changes, merges them into the existing complete runtime status with transport-generation fencing, and routes Settings, the status-bar Remote Hosts dropdown, and CLI formatting through the same pure state derivation. SSH and Remote Server transport lanes remain separate, and aggregate partial emerald behavior is unchanged.

Validation

  • Added failing-first regression coverage for Settings derivation (closed/reconnecting) and diagnostic publication/store merge; both tests failed before the implementation and pass now.
  • pnpm test src/shared/remote-runtime-shared-control-connection.test.ts src/main/ipc/runtime-environment-diagnostics-broadcast.test.ts src/renderer/src/store/slices/runtime-status-diagnostics.test.ts src/renderer/src/store/slices/runtime-status.test.ts src/renderer/src/runtime/runtime-host-connection-state.test.ts src/renderer/src/components/settings/RuntimeEnvironmentsPane.test.ts src/cli/runtime/status.test.ts (100 passed)
  • Additional CLI/SSH/shared suites (54 passed)
  • pnpm tc passed
  • pnpm run check:code-quality:changed passed (0 new findings)
  • bare oxlint on changed files passed
  • npx oxfmt --check passed
  • Electron CDP visible proof: status-bar Remote Hosts dropdown showed Remote Demo · Remote Server · Connected, then after a simulated transport close showed Disconnected · connection lost with a gray dot and Connect action, then recovered to Connected with a green dot.

Connected:
connected

Outage:
outage

Recovered:
recovered

Do not merge this PR.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR publishes shared-control transport transitions from the main process and merges them into renderer runtime status so host surfaces reflect outages and recovery consistently.

  • Adds generation-fenced diagnostics publication through main-process IPC and preload.
  • Centralizes runtime connection-state derivation for Settings, status surfaces, and CLI output.
  • Refactors shared-control lifecycle helpers and adds regression coverage for outage publication, merging, and presentation.

Confidence Score: 5/5

The reviewed changes appear safe to merge because no blocking failure remains in the eligible follow-up scope.

No blocking failure remains.

Important Files Changed

Filename Overview
src/shared/remote-runtime-shared-control-connection.ts Refactors shared-control lifecycle operations and publishes diagnostics after meaningful connection transitions.
src/main/ipc/runtime-environment-request-connections.ts Connects shared-control diagnostics to an environment-scoped, transport-generation-fenced IPC publisher.
src/renderer/src/store/slices/runtime-status-diagnostics-generation.ts Validates diagnostics capability and generation before merging transport state into complete runtime status.
src/renderer/src/store/slices/runtime-status.ts Integrates pushed diagnostics with the runtime-status store and existing recheck lifecycle.
src/renderer/src/components/settings/runtime-server-row.tsx Makes Settings prefer live store status when deriving each runtime server's connection state.
src/shared/runtime-host-connection-state.ts Provides the shared pure derivation used to classify runtime transport state across host surfaces and CLI paths.
src/preload/index.ts Exposes the diagnostics event subscription with matching listener cleanup across the preload boundary.

Sequence Diagram

sequenceDiagram
    participant T as Shared-control transport
    participant M as Electron main
    participant P as Preload IPC bridge
    participant S as Renderer status store
    participant U as Host surfaces
    T->>M: Diagnostics transition
    M->>M: Check transport generation
    M->>P: Publish environment diagnostics
    P->>S: Merge into complete runtime status
    S->>S: Fence stale generations
    S-->>U: Derive connection state
    U-->>U: Render connected, reconnecting, or disconnected
Loading

Reviews (6): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review 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
📝 Walkthrough

Walkthrough

The change adds a shared runtime host connection-state model with connected, reconnecting, checking, disconnected, and workspace-window-closed states. CLI, SSH, and renderer status projections use this model. Shared-control connections now track and publish deduplicated diagnostics. Main-process IPC broadcasts generation-tagged diagnostics to renderer windows. The preload API and renderer store accept these events, reject stale generations, and merge current diagnostics into runtime status. Runtime settings displays the new states and styles.

Merge Risk: 🟡 Moderate · up to dd185

The PR adds live remote-control outage reporting to host surfaces, but current behavior can clear a host’s status after a transient check failure, leave an idle reconnect running after the last subscription closes, and briefly show recovery with stale failure details. Users may see incorrect availability or connection actions, so merge should wait for fixes or explicit owner acceptance.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, implementation, and validation results, and includes visual proof. However, it omits several required template sections, including ELI5, What Changed, Why, Linked… Add all required template sections. Include a valid linked issue after "Fixes #", complete the Testing checkboxes and platform coverage, address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist items, and place the…
Docstring Coverage ⚠️ Warning Docstring coverage is 2.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 39 functions across 33 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: publishing remote-control outages to host surfaces.
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.
Full details: Description check

Explanation

The description explains the problem, implementation, and validation results, and includes visual proof. However, it omits several required template sections, including ELI5, What Changed, Why, Linked Issue with a real issue reference, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Add all required template sections. Include a valid linked issue after "Fixes #", complete the Testing checkboxes and platform coverage, address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist items, and place the visual proof under the required Visual Proof section.

Full details: Docstring Coverage

Explanation

Docstring coverage is 2.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 39 functions across 33 files. (1 skipped: 1 unsupported.)

✨ 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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 970dc6a3-a2a4-4d5f-a5cf-e449c5b155c0

📥 Commits

Reviewing files that changed from the base of the PR and between a0d36f5 and 678b5e6f1c5a7a18bfc18f3093933aabe0cbc586.

📒 Files selected for processing (29)
  • src/cli/format.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/status.test.ts
  • src/cli/runtime/status.ts
  • src/main/ipc/runtime-environment-diagnostics-broadcast.test.ts
  • src/main/ipc/runtime-environment-diagnostics-broadcast.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ssh/ssh-remote-cli-format.ts
  • src/main/ssh/ssh-remote-orca-cli.ts
  • src/preload/api/runtime-api.ts
  • src/preload/index.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.test.ts
  • src/renderer/src/components/settings/runtime-environment-host-details.ts
  • src/renderer/src/components/settings/runtime-server-row.tsx
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.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.test.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/remote-runtime-shared-control-connection-actions.ts
  • src/shared/remote-runtime-shared-control-connection-frame.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-diagnostics.ts
  • src/shared/remote-runtime-shared-control-ready-wait.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/runtime-environment-diagnostics.ts
  • src/shared/runtime-host-connection-state.ts
  • src/shared/runtime-session-contracts.ts

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

Comment on lines 247 to 255
private closeSubscription(requestId: string): void {
closeSharedControlConnectionSubscription({
closeRuntimeControlSubscription({
subscriptions: this.subscriptions,
retiredRequestIds: this.retiredRequestIds,
requestId,
deviceToken: this.pairing.deviceToken,
send: (payload) => this.sendEncrypted(payload)
send: (payload) => this.sendEncrypted(payload),
clearWhenIdle: (isIdle) => this.reconnect.clearWhenIdle(isIdle && this.state === 'closed')
})

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

Publish diagnostics after a subscription close.

If the final subscription closes after an outage, clearWhenIdle cancels the scheduled reconnect. No call then publishes the new closed state or the zero subscription count. The renderer can retain the prior reconnecting diagnostic until another transport transition occurs.

Proposed fix
     closeRuntimeControlSubscription({
       subscriptions: this.subscriptions,
       retiredRequestIds: this.retiredRequestIds,
       requestId,
       deviceToken: this.pairing.deviceToken,
       send: (payload) => this.sendEncrypted(payload),
       clearWhenIdle: (isIdle) => this.reconnect.clearWhenIdle(isIdle && this.state === 'closed')
     })
+    this.publishDiagnostics()
📝 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
private closeSubscription(requestId: string): void {
closeSharedControlConnectionSubscription({
closeRuntimeControlSubscription({
subscriptions: this.subscriptions,
retiredRequestIds: this.retiredRequestIds,
requestId,
deviceToken: this.pairing.deviceToken,
send: (payload) => this.sendEncrypted(payload)
send: (payload) => this.sendEncrypted(payload),
clearWhenIdle: (isIdle) => this.reconnect.clearWhenIdle(isIdle && this.state === 'closed')
})
private closeSubscription(requestId: string): void {
closeRuntimeControlSubscription({
subscriptions: this.subscriptions,
retiredRequestIds: this.retiredRequestIds,
requestId,
deviceToken: this.pairing.deviceToken,
send: (payload) => this.sendEncrypted(payload),
clearWhenIdle: (isIdle) => this.reconnect.clearWhenIdle(isIdle && this.state === 'closed')
})
this.publishDiagnostics()

@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-false-green branch from 678b5e6 to 1d1f92d Compare August 31, 2026 02:10

@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 critical issues — one test-coverage regression inline and one nitpick.

Reviewed changes

This PR publishes authoritative shared-control transport diagnostics from the main process to the renderer store, merges them into the existing complete runtime status behind transport-generation fencing, and routes Settings, the status-bar dropdown, CLI formatting, and SSH formatting through one shared runtimeHostConnectionState derivation.

  • Diagnostics publication — RemoteRuntimeSharedControlConnection now owns a SharedControlDiagnosticsTracker that records lastConnectedAt/lastClose/lastError and emits deduped transitions through a new onDiagnosticsChanged option.
  • Main-process broadcast — getSharedControlConnection fences stale callbacks by transport generation and broadcasts diagnostics to all live renderer windows over a new IPC channel.
  • Renderer store merge — a new publishRuntimeEnvironmentDiagnostics slice action overlays pushed remoteControl onto the stored status snapshot, dropping pushes when no snapshot exists yet.
  • Shared state derivation — runtimeHostConnectionState and its helpers moved to src/shared/ (renderer path re-exports), and getRuntimeServerConnectionState now derives from runtimeStatus.remoteControl instead of trusting the ready phase.
  • Settings row — runtime-server-row.tsx reads the live store entry, exposing workspace-window-closed/reconnecting states with yellow dots and a Connect action.
  • CLI/SSH surfaces — CliStatusResult.runtime.connectionState is populated via the shared derivation and printed by both local and SSH format paths.

ℹ️ Nitpicks

  • The two import type statements at the bottom of src/renderer/src/store/slices/runtime-status-diagnostics-generation.ts are valid but unconventional; move them to the top of the file.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | 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 in this delta.

Reviewed changes

This incremental delta adds one defensive guard: window.api.runtimeEnvironments?.onSharedControlDiagnostics now optional-chains the runtimeEnvironments namespace itself, so the diagnostics subscription is skipped cleanly in contexts where that preload namespace is absent rather than throwing on property access.

The prior review's inline finding on src/shared/remote-runtime-shared-control-connection.test.ts remains open and is not addressed by this delta.

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

@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-false-green branch from 323bac5 to 9b55641 Compare August 31, 2026 05:06

@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

Caution

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

⚠️ Outside diff range comments (2)
src/renderer/src/store/slices/runtime-status-recheck.ts (1)

166-166: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Do not publish null after an observe-only recheck fails.

Lines 148-155 convert a transient probe failure to null. Line 166 publishes it. The status slice then cancels the recheck because null does not satisfy shouldRecheck. Later diagnostics cannot restore the host because the overlay requires an existing complete status snapshot. Keep the cached status and arm the next retry when this probe fails.

Proposed fix
-  state.publish(status)
+  if (status === null) {
+    armRuntimeStatusRecheck(environmentId, state)
+    return
+  }
+  state.publish(status)
src/shared/remote-runtime-shared-control-connection.ts (1)

251-257: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Stop recovery after the final subscription closes.

At Line 251, the delegated action can remove the final subscription, but this method does not clear a reconnect already scheduled for a closed socket. The connection can then continue opening sockets after its last subscriber has closed.

After the action, clear the retry when the map is empty and publish the updated diagnostics.

Proposed fix
     closeSharedControlSubscription({
       subscriptions: this.subscriptions,
       retiredRequestIds: this.retiredRequestIds,
       requestId,
       deviceToken: this.pairing.deviceToken,
       send: (payload) => this.sendEncrypted(payload)
     })
+    if (this.subscriptions.size === 0 && this.state === 'closed') {
+      this.reconnect.clear()
+    }
+    this.publishDiagnostics()

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5bf789da-cacb-47de-a5b5-8b274b041508

📥 Commits

Reviewing files that changed from the base of the PR and between 323bac5e2d86015fa31ec1155b9152cdbf148996 and 9b55641.

📒 Files selected for processing (10)
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/preload/api/runtime-api.ts
  • src/preload/index.ts
  • src/renderer/src/store/slices/runtime-status-connection-generation.ts
  • src/renderer/src/store/slices/runtime-status-recheck.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/runtime-session-contracts.ts

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

@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 recovery path drops ready diagnostics after the recheck ladder publishes a failed probe, so a recovered host can remain "Disconnected" until a manual refresh.

Reviewed changes

This delta replaces the connection's inline diag fields with a deduping SharedControlDiagnosticsTracker, adds the publishRuntimeEnvironmentDiagnostics renderer store action behind a diagnostics-generation fence, extracts several shared/renderer helper modules, and updates the lifecycle test for the new diagnostics listener.

  • Diagnostics tracker — RemoteRuntimeSharedControlConnection now owns a SharedControlDiagnosticsTracker that records lastConnectedAt/lastClose/lastError, dedupes transitions, and emits through onDiagnosticsChanged; every state transition routes through the new publishDiagnostics().
  • Renderer merge + fence — the new publishRuntimeEnvironmentDiagnostics slice action overlays pushed remoteControl onto the existing snapshot, dropping pushes whose transportGeneration is stale.
  • Helper extraction — connection send/close/replay helpers moved to remote-runtime-shared-control-connection-actions.ts, frame handling to remote-runtime-shared-control-connection-frame.ts, ready-wait to remote-runtime-shared-control-ready-wait.ts, and the connection-generation map to runtime-status-connection-generation.ts.
  • Lifecycle test — useIpcEvents-lifecycle.test.ts accounts for the runtimeEnvironments.onSharedControlDiagnostics listener registration.

⚠️ Recovery diagnostics are dropped after a failed recheck probe

When the transport drops, the diagnostics merge arms the recheck ladder, whose first observe-only probe fails during the outage and publishes null — wiping the status snapshot and cancelling the ladder. When the host then recovers, the pushed ready diagnostics hit mergePushedRuntimeEnvironmentDiagnostics, which returns early because current?.status is now null, so the UI stays on Disconnected until a user-triggered refresh (the disconnect toast's "Try again" is the only escape hatch today, and only while it is on screen).

Technical details
# Recovery diagnostics dropped after a failed recheck probe

## Affected sites
- `src/renderer/src/store/slices/runtime-status-diagnostics-generation.ts:26-31` — `mergePushedRuntimeEnvironmentDiagnostics` returns early when `current?.status` is null, silently dropping the push.
- `src/renderer/src/store/slices/runtime-status-recheck.ts:145-166` — `fireRuntimeStatusRecheck` publishes `null` when its observe-only `getStatus` probe fails.
- `src/renderer/src/store/slices/runtime-status-recheck.ts:109-115` — `shouldRecheck(null)` is false, so publishing `null` cancels the ladder.
- `src/shared/runtime-host-connection-state.ts:26-28` — a `null` status derives to `disconnected`.

## Required outcome
- A host that recovers after an outage returns to `connected` without user interaction, even when the outage outlasted the recheck ladder's first probe.

## Suggested approach (optional)
- When `mergePushedRuntimeEnvironmentDiagnostics` receives a push with no snapshot, re-arm a full `refreshRuntimeEnvironmentStatus` instead of dropping; or keep the recheck ladder alive on a failed probe so the snapshot is repopulated by a later successful probe.

## Open questions for the human (optional)
- Is publishing `null` + toast the intended terminal state for the recheck, or should it keep probing? Either way the push channel needs a defined recovery path for the missing-snapshot case.

ℹ️ Nitpicks

  • closeRuntimeControlSubscription in src/shared/remote-runtime-shared-control-connection-actions.ts:83-93 is exported but has no callers after the connection switched to closeSharedControlSubscription; remove it or wire up the idle-clear it provides.

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

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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

No new issues in this delta, but the recovery gap raised in the prior review is still open — a host that recovers after an outlasting outage stays Disconnected until a manual refresh.

Reviewed changes

Four commits landed on top of the prior pullfrog review, plus a merge and an i18n label commit: a shared-control capability fence, a diagnostics-overlay lifecycle guard, a checking state in the runtime server row, and diagnostics publication on standing-retry pause. The connection-count/request-order test assertions called out earlier are restored.

  • Capability fence — mergePushedRuntimeEnvironmentDiagnostics and shouldRecheck now require the shared-control capability, mirroring the main-side attachRemoteControlDiagnostics gate.
  • Overlay lifecycle — updateRuntimeEnvironmentStatusOverlay drops an overlay whose runtimeId no longer matches the stored snapshot, and the publisher is extracted into runtime-status-diagnostics-publish.ts.
  • Server row checking state — while details is loading and no live status exists, the row shows checking instead of jumping to a verdict.
  • Standing-retry pause — pauseStandingRetry() publishes closed diagnostics when there are no active subscriptions.
  • Test restoration — the shared-control test keeps connectionCount() === 1 and the request-order assertion alongside the state-transition check, and adds a capability-fence case.

⚠️ Recovery diagnostics are still dropped after a failed recheck probe

The outage-recovery path is unchanged from the prior review. When the recheck ladder's first observe-only probe fails mid-outage it publishes null, wiping the snapshot and cancelling the ladder (shouldRecheck(null) is false); the later ready push then hits the current?.status gate in mergePushedRuntimeEnvironmentDiagnostics and is dropped, so a recovered host stays Disconnected until a user-triggered refresh. The four new commits harden adjacent seams (capability fencing, runtime-id guarding) but do not add a recovery path for the missing-snapshot case.

Technical details
# Recovery diagnostics dropped after a failed recheck probe

## Affected sites
- `src/renderer/src/store/slices/runtime-status-diagnostics-generation.ts:42-47` — the `!current?.status?...` gate drops the `ready` push once the snapshot is wiped to `null`.
- `src/renderer/src/store/slices/runtime-status-recheck.ts:145-166` — the observe-only probe publishes `null` on failure.
- `src/renderer/src/store/slices/runtime-status-recheck.ts:109-115` — `shouldRecheck(null)` is false, so publishing `null` cancels the ladder.

## Required outcome
- A host that recovers after an outage returns to `connected` without user interaction, even when the outage outlasted the first probe.

## Suggested approach (optional)
- On a push with no snapshot, re-arm `refreshRuntimeEnvironmentStatus` instead of dropping; or keep the recheck ladder alive on a failed probe so a later successful probe repopulates the snapshot.

## Open questions for the human (optional)
- Is publishing `null` + toast the intended terminal state for the recheck, or should it keep probing?

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review complete and fixes pushed.

  • Merged the current origin/main into the PR branch (016fdff537).
  • Fixed the localization CI failure by adding the missing runtime connection-state labels.
  • Same-model review found and fixed stale/in-flight state handling, diagnostics-generation fencing, overlay lifecycle cleanup, and stale reconnect publication. No scope-expanding changes were made.
  • pnpm tc, targeted runtime/shared-control tests, pnpm run check:code-quality:changed, and git diff --check pass. The intermittent large-RPC timeout is pre-existing and passes standalone.
  • Readiness checklist is clean at both the start and end of review.
  • Electron/CDP validation visibly covered connected → outage → reconnecting → recovered, including Settings surfaces.

Electron evidence:
Outage
Reconnecting
Recovered
Settings outage
Settings reconnecting

The prior PR-check run reported one unrelated static-analysis error in the unchanged 847-line WorktreeJumpPalette.recent-tabs.test.tsx from the base branch; the new checks for the latest head are still running.

@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 in this follow-up commit.

Reviewed changes

9565bf5 (fix(runtime): avoid publishing unchanged diagnostics state) repoints the diagnostics publisher's setState through a new updateRuntimeStatusStore helper. When the overlay is a no-op it returns the unchanged AppState so zustand skips the subscriber notification; otherwise it returns a partial { runtimeStatusByEnvironmentId }. afterPublish gating is unaffected because applyRuntimeEnvironmentStatusOverlay still derives updated from the map-reference comparison. Correct and behavior-preserving.

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 63304917-b849-4bae-9895-ab966f99b09d

📥 Commits

Reviewing files that changed from the base of the PR and between 393992c and dd185cf.

📒 Files selected for processing (34)
  • src/cli/format.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/status.test.ts
  • src/cli/runtime/status.ts
  • src/main/ipc/runtime-environment-diagnostics-broadcast.test.ts
  • src/main/ipc/runtime-environment-diagnostics-broadcast.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ssh/ssh-remote-cli-format.ts
  • src/main/ssh/ssh-remote-orca-cli.ts
  • src/preload/api/runtime-api.ts
  • src/preload/index.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.test.ts
  • src/renderer/src/components/settings/runtime-environment-host-details.ts
  • src/renderer/src/components/settings/runtime-server-row.tsx
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/renderer/src/hooks/useIpcEvents-lifecycle.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/runtime/runtime-host-connection-state.ts
  • src/renderer/src/store/slices/runtime-status-connection-generation.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.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/remote-runtime-shared-control-connection-actions.ts
  • src/shared/remote-runtime-shared-control-connection-frame.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-diagnostics.ts
  • src/shared/remote-runtime-shared-control-ready-wait.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/runtime-environment-diagnostics.ts
  • src/shared/runtime-host-connection-state.ts
  • src/shared/runtime-session-contracts.ts
🚧 Files skipped from review as they are similar to previous changes (27)
  • src/cli/format.ts
  • src/renderer/src/components/settings/runtime-server-row.tsx
  • src/shared/remote-runtime-shared-control-connection-frame.ts
  • src/renderer/src/runtime/runtime-host-connection-state.ts
  • src/renderer/src/components/settings/runtime-environment-host-details.ts
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/main/ssh/ssh-remote-orca-cli.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.test.ts
  • src/main/ipc/runtime-environment-diagnostics-broadcast.test.ts
  • src/shared/runtime-environment-diagnostics.ts
  • src/shared/runtime-host-connection-state.ts
  • src/main/ssh/ssh-remote-cli-format.ts
  • src/preload/api/runtime-api.ts
  • src/renderer/src/hooks/useIpcEvents-lifecycle.test.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/renderer/src/store/slices/runtime-status-recheck.ts
  • src/shared/remote-runtime-shared-control-diagnostics.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/status.test.ts
  • src/shared/remote-runtime-shared-control-connection-actions.ts
  • src/shared/remote-runtime-shared-control-ready-wait.ts
  • src/main/ipc/runtime-environment-diagnostics-broadcast.ts
  • src/shared/runtime-session-contracts.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/renderer/src/store/slices/runtime-status-connection-generation.ts
  • src/cli/runtime/status.ts

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


private closeSubscription(requestId: string): void {
closeSharedControlConnectionSubscription({
closeSharedControlSubscription({

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

Cancel the reconnect when the last subscription closes.

handleSocketClosed can schedule a reconnect while subscriptions exist. This delegated close path does not clear that timer after it removes the final subscription. The timer can then reopen an idle control transport and publish a misleading reconnecting state.

After the helper returns, if this.subscriptions.size === 0 and this.state === 'closed', clear the reconnect and publish diagnostics.

Proposed fix
 private closeSubscription(requestId: string): void {
   closeSharedControlSubscription({
     subscriptions: this.subscriptions,
     retiredRequestIds: this.retiredRequestIds,
     requestId,
     deviceToken: this.pairing.deviceToken,
     send: (payload) => this.sendEncrypted(payload)
   })
+  if (this.subscriptions.size === 0 && this.state === 'closed') {
+    this.reconnect.clear()
+  }
+  this.publishDiagnostics()
 }
📝 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
closeSharedControlSubscription({
private closeSubscription(requestId: string): void {
closeSharedControlSubscription({
subscriptions: this.subscriptions,
retiredRequestIds: this.retiredRequestIds,
requestId,
deviceToken: this.pairing.deviceToken,
send: (payload) => this.sendEncrypted(payload)
})
if (this.subscriptions.size === 0 && this.state === 'closed') {
this.reconnect.clear()
}
this.publishDiagnostics()
}

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final readiness pass on exact pushed HEAD 016fdff537 is clean: no proven P0/P1/P2 findings, 41 targeted tests passed, and the worktree remains clean. The hosted checks triggered by the latest-main merge are still pending; the earlier static-analysis failure was isolated to the unchanged base-branch 847-line test file.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

CI attribution update:

  • static analysis is failing on src/renderer/src/components/WorktreeJumpPalette.recent-tabs.test.tsx:847 (844 lines). That file is unchanged by this PR and is identical to origin/main, so this red is on the base branch.
  • verify is only the required-checks gate reporting that static-analysis failure; it is downstream, not an additional code failure.
  • e2e / changed e2e specs had 9 passes and 1 failure in the unchanged ssh-reconnect-tab-destruction.spec.ts. The failure was an Electron renderer/network-service crash (renderer-process-gone, execution context destroyed), with a concurrent EADDRINUSE port collision elsewhere in the lane. This does not implicate the runtime-diagnostics diff; it looks like CI infrastructure/test flakiness rather than a deterministic regression.
  • All runtime-focused tests, typecheck, package checks, native smoke, and local Electron validation passed.

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ai#17531)

* fix(runtime): publish remote control diagnostics to renderer

* test(runtime): account for diagnostics bridge listener

* fix(i18n): add runtime connection state labels

* test(runtime): clean up shared control connection

* fix(runtime): fence diagnostics by shared-control capability

* fix(runtime): preserve authoritative transport state

* fix(runtime): preserve diagnostic overlay lifecycle

* fix(runtime): avoid publishing unchanged diagnostics state

---------

Co-authored-by: Merge Sim <sim@local>
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