Repository navigation
fix(runtime): publish remote control outages to host surfaces - #17531
Conversation
Greptile SummaryThe 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.
Confidence Score: 5/5The reviewed changes appear safe to merge because no blocking failure remains in the eligible follow-up scope. No blocking failure remains.
|
| 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
Reviews (6): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile
|
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:
📝 WalkthroughWalkthroughThe 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 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)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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 CoverageExplanation 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 💡
🛠️ Fix failing CI checks 💡
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: 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.tssrc/cli/runtime/client.tssrc/cli/runtime/status.test.tssrc/cli/runtime/status.tssrc/main/ipc/runtime-environment-diagnostics-broadcast.test.tssrc/main/ipc/runtime-environment-diagnostics-broadcast.tssrc/main/ipc/runtime-environment-request-connections.tssrc/main/ssh/ssh-remote-cli-format.tssrc/main/ssh/ssh-remote-orca-cli.tssrc/preload/api/runtime-api.tssrc/preload/index.tssrc/renderer/src/components/settings/RuntimeEnvironmentsPane.test.tssrc/renderer/src/components/settings/runtime-environment-host-details.tssrc/renderer/src/components/settings/runtime-server-row.tsxsrc/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.tssrc/renderer/src/runtime/runtime-host-connection-state.tssrc/renderer/src/store/slices/runtime-status-diagnostics-generation.tssrc/renderer/src/store/slices/runtime-status-diagnostics.test.tssrc/renderer/src/store/slices/runtime-status.tssrc/shared/remote-runtime-shared-control-connection-actions.tssrc/shared/remote-runtime-shared-control-connection-frame.tssrc/shared/remote-runtime-shared-control-connection.test.tssrc/shared/remote-runtime-shared-control-connection.tssrc/shared/remote-runtime-shared-control-diagnostics.tssrc/shared/remote-runtime-shared-control-ready-wait.tssrc/shared/remote-runtime-shared-control-types.tssrc/shared/runtime-environment-diagnostics.tssrc/shared/runtime-host-connection-state.tssrc/shared/runtime-session-contracts.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| 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') | ||
| }) |
There was a problem hiding this comment.
🎯 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.
| 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() |
678b5e6 to
1d1f92d
Compare
There was a problem hiding this comment.
ℹ️ 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 —
RemoteRuntimeSharedControlConnectionnow owns aSharedControlDiagnosticsTrackerthat recordslastConnectedAt/lastClose/lastErrorand emits deduped transitions through a newonDiagnosticsChangedoption. - Main-process broadcast —
getSharedControlConnectionfences stale callbacks by transport generation and broadcasts diagnostics to all live renderer windows over a new IPC channel. - Renderer store merge — a new
publishRuntimeEnvironmentDiagnosticsslice action overlays pushedremoteControlonto the stored status snapshot, dropping pushes when no snapshot exists yet. - Shared state derivation —
runtimeHostConnectionStateand its helpers moved tosrc/shared/(renderer path re-exports), andgetRuntimeServerConnectionStatenow derives fromruntimeStatus.remoteControlinstead of trusting thereadyphase. - Settings row —
runtime-server-row.tsxreads the live store entry, exposingworkspace-window-closed/reconnectingstates with yellow dots and a Connect action. - CLI/SSH surfaces —
CliStatusResult.runtime.connectionStateis populated via the shared derivation and printed by both local and SSH format paths.
ℹ️ Nitpicks
- The two
import typestatements at the bottom ofsrc/renderer/src/store/slices/runtime-status-diagnostics-generation.tsare valid but unconventional; move them to the top of the file.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ 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.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
323bac5 to
9b55641
Compare
There was a problem hiding this comment.
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 liftDo not publish
nullafter 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 becausenulldoes not satisfyshouldRecheck. 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 winStop 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.tssrc/preload/api/runtime-api.tssrc/preload/index.tssrc/renderer/src/store/slices/runtime-status-connection-generation.tssrc/renderer/src/store/slices/runtime-status-recheck.tssrc/renderer/src/store/slices/runtime-status.tssrc/shared/remote-runtime-shared-control-connection.test.tssrc/shared/remote-runtime-shared-control-connection.tssrc/shared/remote-runtime-shared-control-types.tssrc/shared/runtime-session-contracts.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
There was a problem hiding this comment.
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 —
RemoteRuntimeSharedControlConnectionnow owns aSharedControlDiagnosticsTrackerthat recordslastConnectedAt/lastClose/lastError, dedupes transitions, and emits throughonDiagnosticsChanged; every state transition routes through the newpublishDiagnostics(). - Renderer merge + fence — the new
publishRuntimeEnvironmentDiagnosticsslice action overlays pushedremoteControlonto the existing snapshot, dropping pushes whosetransportGenerationis stale. - Helper extraction — connection send/close/replay helpers moved to
remote-runtime-shared-control-connection-actions.ts, frame handling toremote-runtime-shared-control-connection-frame.ts, ready-wait toremote-runtime-shared-control-ready-wait.ts, and the connection-generation map toruntime-status-connection-generation.ts. - Lifecycle test —
useIpcEvents-lifecycle.test.tsaccounts for theruntimeEnvironments.onSharedControlDiagnosticslistener 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
closeRuntimeControlSubscriptioninsrc/shared/remote-runtime-shared-control-connection-actions.ts:83-93is exported but has no callers after the connection switched tocloseSharedControlSubscription; remove it or wire up the idle-clear it provides.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
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. |
There was a problem hiding this comment.
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 —
mergePushedRuntimeEnvironmentDiagnosticsandshouldRechecknow require the shared-control capability, mirroring the main-sideattachRemoteControlDiagnosticsgate. - Overlay lifecycle —
updateRuntimeEnvironmentStatusOverlaydrops an overlay whoseruntimeIdno longer matches the stored snapshot, and the publisher is extracted intoruntime-status-diagnostics-publish.ts. - Server row
checkingstate — whiledetailsis loading and no live status exists, the row showscheckinginstead of jumping to a verdict. - Standing-retry pause —
pauseStandingRetry()publishescloseddiagnostics when there are no active subscriptions. - Test restoration — the shared-control test keeps
connectionCount() === 1and 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?DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Review complete and fixes pushed.
The prior PR-check run reported one unrelated static-analysis error in the unchanged 847-line |
There was a problem hiding this comment.
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.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
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: 63304917-b849-4bae-9895-ab966f99b09d
📒 Files selected for processing (34)
src/cli/format.tssrc/cli/runtime/client.tssrc/cli/runtime/status.test.tssrc/cli/runtime/status.tssrc/main/ipc/runtime-environment-diagnostics-broadcast.test.tssrc/main/ipc/runtime-environment-diagnostics-broadcast.tssrc/main/ipc/runtime-environment-request-connections.tssrc/main/ssh/ssh-remote-cli-format.tssrc/main/ssh/ssh-remote-orca-cli.tssrc/preload/api/runtime-api.tssrc/preload/index.tssrc/renderer/src/components/settings/RuntimeEnvironmentsPane.test.tssrc/renderer/src/components/settings/runtime-environment-host-details.tssrc/renderer/src/components/settings/runtime-server-row.tsxsrc/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.tssrc/renderer/src/hooks/useIpcEvents-lifecycle.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/runtime/runtime-host-connection-state.tssrc/renderer/src/store/slices/runtime-status-connection-generation.tssrc/renderer/src/store/slices/runtime-status-diagnostics-generation.tssrc/renderer/src/store/slices/runtime-status-diagnostics-publish.tssrc/renderer/src/store/slices/runtime-status-diagnostics.test.tssrc/renderer/src/store/slices/runtime-status-recheck.tssrc/renderer/src/store/slices/runtime-status.tssrc/shared/remote-runtime-shared-control-connection-actions.tssrc/shared/remote-runtime-shared-control-connection-frame.tssrc/shared/remote-runtime-shared-control-connection.test.tssrc/shared/remote-runtime-shared-control-connection.tssrc/shared/remote-runtime-shared-control-diagnostics.tssrc/shared/remote-runtime-shared-control-ready-wait.tssrc/shared/remote-runtime-shared-control-types.tssrc/shared/runtime-environment-diagnostics.tssrc/shared/runtime-host-connection-state.tssrc/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({ |
There was a problem hiding this comment.
🎯 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.
| 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() | |
| } |
|
Final readiness pass on exact pushed HEAD |
|
CI attribution update:
|
…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>






Summary
Remote Server host state could remain green after its shared-control transport closed because Settings trusted a mounted
RuntimeHostDetails.statusphase 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
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)pnpm tcpassedpnpm run check:code-quality:changedpassed (0 new findings)oxlinton changed files passednpx oxfmt --checkpassedRemote Demo · Remote Server · Connected, then after a simulated transport close showedDisconnected · connection lostwith a gray dot and Connect action, then recovered toConnectedwith a green dot.Connected:

Outage:

Recovered:

Do not merge this PR.