Repository navigation
fix(runtime): hold the session mirror through an unverifiable probe - #20085
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe change adds Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to Repositories can be missing after startup until a later refresh when a host begins with an unverifiable status. Fix the first-publication transition before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides detailed defect, root-cause, fix, scope, and verification information. It does not follow the required template structure and omits several required sections, including Visual Proof, Testing checkboxes, Review, Notes, and Checklist. Resolution Reorganize the content under all required template headings. Add an actual linked issue after
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
✅ No new issues found.
Reviewed changes
- Mirror reachability now uses the shared verdict —
getReachableRuntimeSessionMirrorTargetsgates the destructive drop onisDisconnectedRuntimeHostState(runtimeHostConnectionStateForEntry(entry))and reads the runtime id vialastVerifiedRuntimeStatus, so an unverifiable probe over a ready transport no longer reads as "gone". lastVerifiedRuntimeStatusaccessor — new shared helper insrc/shared/runtime-host-status.tsthat preferssnapshot.status(retained across a loss of contact) overentry.status;runtime-status.tsreuses it in place of its inlinepreviousVerifiedStatus, collapsing one spelling into one.- Regaining contact is its own recovery trigger —
setRuntimeEnvironmentStatusadvances the connection epoch onreconnectedAfterLostContact(same-runtime return after a null-status entry), so the mirror's "host is back" signal no longer depends on teardown. Restart hook, provider session bump, and toast stay gated on the runtime session, preserving the#19241first-publication guard. - Tests — a failing-first reproduction, reconnect-generation and mirror-target suites, and one pre-existing snapshot test updated to assert the epoch advances without manufacturing a restart or toast.
I verified the snapshot producer (shared/runtime-host-status-owner.ts) never nulls snapshot.status on failure, that reconnectedAfterLostContact fires in every outage shape (transport drop, probe timeout, and their recovery), that the mirror key depends on connectionGeneration, and that the changed tests pass with a clean tsc -p config/tsconfig.tc.web.json.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
d6e2033 to
ef82ede
Compare
Siblings of the session-mirror defect fixed in #20085. runtime-status-snapshot nulls `entry.status` for any non-verified probe while the snapshot retains the host's identity, so a host with a ready transport that is still delivering reads as gone to anything gating on `entry.status != null`. - client-event subscription selection dropped the stream for such a host, and its disconnect edge bumped the SSH generation, rebuilding even the active host's subscription - the web client's active session-tabs stream tore down and cold-rebuilt, twice per blip - landing preflight discarded its whole result - runtime-aware SSH selectors blanked mirrored target rows Each now reads the shared verdict, isConnectedRuntimeHostState of runtimeHostConnectionStateForEntry, or lastVerifiedRuntimeStatus where the read is host identity rather than reachability. No new predicate: every "genuinely gone" case is byte-identical, so nothing gains a retry loop.
…ration `connectionGeneration` carried two meanings and one reader was always wrong. holding the session mirror through an outage leaves its subscriptions stranded and that edge was the only thing left to revive them. But the same value is the mirror's cache key -- use-runtime-session-mirror-environment-key.ts keys the subscription effect on it, every published frame is stamped with it, and web-session-terminal-retirement-proof-ledger.ts drops retained proofs when it moves. So the bump #20085 needed as a resubscribe signal re-keyed and rebuilt the mirror after any brief flap, which is the #19647 symptom #19873/#20059 fix. Measured first: with the reconnect bump deleted, an ended stream followed by recovery issues zero resubscribes, and the mirror's subscribe call registers no `onClose`, so main's terminal close is dropped. #20085's claim is true -- the subscription really is dead after recovery -- so the trigger has to exist. It just must not be the cache key. Give each meaning its own value: - `connectionGeneration` returns to identity only: a new runtime session, a re-pair, an explicit clear. A same-runtime return no longer moves it, so no stamp, fence or retained proof is invalidated by a flap. - `hostContactEpoch` counts "the host answered again after we lost contact". It lives on the store entry and is read only as a dependency of the two subscription effects in use-web-session-tabs-sync.ts -- never passed to an installer, never part of `environmentKey`, so it cannot become a stamp. `useRuntimeSessionMirrorEnvironmentKey` becomes `useRuntimeSessionMirrorEnvironmentKeys`, returning `environmentKey` (identity) and `resubscribeSignal` (the epoch edge) from the one target scan, so the hot ownership scan is not doubled. Each direction is pinned by its own test: removing the resubscribe dependency fails only 'reinstalls both session-tabs subscriptions when the host answers again'; restoring the reconnect bump fails only the two key-stability tests.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 6a6b91c0-b944-4396-9298-83b5311e49ca
📒 Files selected for processing (3)
src/renderer/src/lib/runtime-session-mirror-unverifiable-host.test.tssrc/renderer/src/store/slices/runtime-status-reconnect-connection-generation.test.tssrc/renderer/src/store/slices/runtime-status.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| previous !== undefined && (runtimeSessionStarted || reconnectedAfterLostContact) | ||
| const activeEnvironmentId = s.settings?.activeRuntimeEnvironmentId?.trim() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '150,225p' src/renderer/src/store/slices/runtime-status.ts
sed -n '1,80p' src/shared/runtime-host-status.ts
sed -n '1,190p' src/renderer/src/store/slices/runtime-status-reconnect-connection-generation.test.ts
rg -n "setRuntimeEnvironmentStatus|applyRuntimeHostStatusSnapshot|runtimeSessionStarted|reconnectedAfterLostContact|entryForSnapshot" src/renderer/src/store src/sharedRepository: stablyai/orca
Length of output: 27848
🏁 Script executed:
sed -n '1,120p' src/renderer/src/store/slices/runtime-status-snapshot.ts
sed -n '1,150p' src/renderer/src/store/slices/runtime-status-snapshot.test.ts
sed -n '1,110p' src/renderer/src/store/slices/runtime-status-first-publication.test.ts
sed -n '225,245p' src/renderer/src/store/slices/runtime-status.tsRepository: stablyai/orca
Length of output: 11111
🏁 Script executed:
rg -n -C 4 "verification:\s*'checking'|verification:\s*'unavailable'|verification:\s*'blocked'|RuntimeHostStatusSnapshot" src | head -240Repository: stablyai/orca
Length of output: 21122
Exclude an initial unverified snapshot from connection changes.
applyRuntimeHostStatusSnapshot stores an initial checking snapshot with status === null. The first verified snapshot then sets both runtimeSessionStarted and reconnectedAfterLostContact to true. Because previous exists, this advances the generation even though no connection existed.
Preserve reconnects from direct status entries, which are valid transitions.
Proposed fix
const connectionChanged =
- previous !== undefined && (runtimeSessionStarted || reconnectedAfterLostContact)
+ previous !== undefined &&
+ (previous.snapshot === undefined || previousVerifiedStatus != null) &&
+ (runtimeSessionStarted || reconnectedAfterLostContact)Two derivations read the same host state and reached opposite verdicts, and the destructive one won. When a status probe came back unverifiable over a still-ready transport, runtimeHostConnectionStateForEntry called the host 'runtime-unavailable' (connected) while getReachableRuntimeSessionMirrorTargets dropped it, tearing down and cold-rebuilding the session-tab mirror while the host's flows were still delivering. The root cause is that applyRuntimeHostStatusSnapshot nulls entry.status for any non-verified probe while the snapshot retains the runtime identity. The connection-state reader consults the snapshot; the mirror-target reader did not. Give both readers one answer: - lastVerifiedRuntimeStatus() in shared/runtime-host-status.ts is now the single definition of "the last identity the host answered with". runtime-status.ts already had this inline as previousVerifiedStatus and now calls it. - The mirror-target reader asks the shared connection verdict instead of entry.status, gated on isDisconnectedRuntimeHostState -- only the one exit verdict earns a destructive read, per docs/reference/ssh-execution-boundary.md. 'checking' and 'reconnecting' are unverifiable, not evidence of an exit. Holding the target through the outage would strand the mirror on its own: the subscription is installed by the effect in use-web-session-tabs-sync.ts keyed on useRuntimeSessionMirrorEnvironmentKey(), a stream 'end' frame is dropped without resubscribing, and the parking layer retries only a rejected subscribe call. The teardown was the recovery. So regaining contact now advances the connection epoch, giving recovery its own "the host is back" trigger rather than leaving the mirror to be restored as a side effect of having been destroyed. The connection epoch is not the runtime session: a same-runtime return fires no restart hook, no provider session bump, and no toast.
ef82ede to
e7046b1
Compare
Siblings of the session-mirror defect fixed in #20085. runtime-status-snapshot nulls `entry.status` for any non-verified probe while the snapshot retains the host's identity, so a host with a ready transport that is still delivering reads as gone to anything gating on `entry.status != null`. - client-event subscription selection dropped the stream for such a host, and its disconnect edge bumped the SSH generation, rebuilding even the active host's subscription - the web client's active session-tabs stream tore down and cold-rebuilt, twice per blip - landing preflight discarded its whole result - runtime-aware SSH selectors blanked mirrored target rows Each now reads the shared verdict, isConnectedRuntimeHostState of runtimeHostConnectionStateForEntry, or lastVerifiedRuntimeStatus where the read is host identity rather than reachability. No new predicate: every "genuinely gone" case is byte-identical, so nothing gains a retry loop.
…ration `connectionGeneration` carried two meanings and one reader was always wrong. holding the session mirror through an outage leaves its subscriptions stranded and that edge was the only thing left to revive them. But the same value is the mirror's cache key -- use-runtime-session-mirror-environment-key.ts keys the subscription effect on it, every published frame is stamped with it, and web-session-terminal-retirement-proof-ledger.ts drops retained proofs when it moves. So the bump #20085 needed as a resubscribe signal re-keyed and rebuilt the mirror after any brief flap, which is the #19647 symptom #19873/#20059 fix. Measured first: with the reconnect bump deleted, an ended stream followed by recovery issues zero resubscribes, and the mirror's subscribe call registers no `onClose`, so main's terminal close is dropped. #20085's claim is true -- the subscription really is dead after recovery -- so the trigger has to exist. It just must not be the cache key. Give each meaning its own value: - `connectionGeneration` returns to identity only: a new runtime session, a re-pair, an explicit clear. A same-runtime return no longer moves it, so no stamp, fence or retained proof is invalidated by a flap. - `hostContactEpoch` counts "the host answered again after we lost contact". It lives on the store entry and is read only as a dependency of the two subscription effects in use-web-session-tabs-sync.ts -- never passed to an installer, never part of `environmentKey`, so it cannot become a stamp. `useRuntimeSessionMirrorEnvironmentKey` becomes `useRuntimeSessionMirrorEnvironmentKeys`, returning `environmentKey` (identity) and `resubscribeSignal` (the epoch edge) from the one target scan, so the hot ownership scan is not doubled. Each direction is pinned by its own test: removing the resubscribe dependency fails only 'reinstalls both session-tabs subscriptions when the host answers again'; restoring the reconnect bump fails only the two key-stability tests.
…#20095) * fix(runtime): hold the session mirror through an unverifiable probe Two derivations read the same host state and reached opposite verdicts, and the destructive one won. When a status probe came back unverifiable over a still-ready transport, runtimeHostConnectionStateForEntry called the host 'runtime-unavailable' (connected) while getReachableRuntimeSessionMirrorTargets dropped it, tearing down and cold-rebuilding the session-tab mirror while the host's flows were still delivering. The root cause is that applyRuntimeHostStatusSnapshot nulls entry.status for any non-verified probe while the snapshot retains the runtime identity. The connection-state reader consults the snapshot; the mirror-target reader did not. Give both readers one answer: - lastVerifiedRuntimeStatus() in shared/runtime-host-status.ts is now the single definition of "the last identity the host answered with". runtime-status.ts already had this inline as previousVerifiedStatus and now calls it. - The mirror-target reader asks the shared connection verdict instead of entry.status, gated on isDisconnectedRuntimeHostState -- only the one exit verdict earns a destructive read, per docs/reference/ssh-execution-boundary.md. 'checking' and 'reconnecting' are unverifiable, not evidence of an exit. Holding the target through the outage would strand the mirror on its own: the subscription is installed by the effect in use-web-session-tabs-sync.ts keyed on useRuntimeSessionMirrorEnvironmentKey(), a stream 'end' frame is dropped without resubscribing, and the parking layer retries only a rejected subscribe call. The teardown was the recovery. So regaining contact now advances the connection epoch, giving recovery its own "the host is back" trigger rather than leaving the mirror to be restored as a side effect of having been destroyed. The connection epoch is not the runtime session: a same-runtime return fires no restart hook, no provider session bump, and no toast. * test(runtime): drop the redundant status casts the new casting gate rejects * fix(runtime): hold four more host reads through an unverifiable probe Siblings of the session-mirror defect fixed in #20085. runtime-status-snapshot nulls `entry.status` for any non-verified probe while the snapshot retains the host's identity, so a host with a ready transport that is still delivering reads as gone to anything gating on `entry.status != null`. - client-event subscription selection dropped the stream for such a host, and its disconnect edge bumped the SSH generation, rebuilding even the active host's subscription - the web client's active session-tabs stream tore down and cold-rebuilt, twice per blip - landing preflight discarded its whole result - runtime-aware SSH selectors blanked mirrored target rows Each now reads the shared verdict, isConnectedRuntimeHostState of runtimeHostConnectionStateForEntry, or lastVerifiedRuntimeStatus where the read is host identity rather than reachability. No new predicate: every "genuinely gone" case is byte-identical, so nothing gains a retry loop. * test(runtime): build real host statuses instead of casting partials
…ration `connectionGeneration` carried two meanings and one reader was always wrong. holding the session mirror through an outage leaves its subscriptions stranded and that edge was the only thing left to revive them. But the same value is the mirror's cache key -- use-runtime-session-mirror-environment-key.ts keys the subscription effect on it, every published frame is stamped with it, and web-session-terminal-retirement-proof-ledger.ts drops retained proofs when it moves. So the bump #20085 needed as a resubscribe signal re-keyed and rebuilt the mirror after any brief flap, which is the #19647 symptom #19873/#20059 fix. Measured first: with the reconnect bump deleted, an ended stream followed by recovery issues zero resubscribes, and the mirror's subscribe call registers no `onClose`, so main's terminal close is dropped. #20085's claim is true -- the subscription really is dead after recovery -- so the trigger has to exist. It just must not be the cache key. Give each meaning its own value: - `connectionGeneration` returns to identity only: a new runtime session, a re-pair, an explicit clear. A same-runtime return no longer moves it, so no stamp, fence or retained proof is invalidated by a flap. - `hostContactEpoch` counts "the host answered again after we lost contact". It lives on the store entry and is read only as a dependency of the two subscription effects in use-web-session-tabs-sync.ts -- never passed to an installer, never part of `environmentKey`, so it cannot become a stamp. `useRuntimeSessionMirrorEnvironmentKey` becomes `useRuntimeSessionMirrorEnvironmentKeys`, returning `environmentKey` (identity) and `resubscribeSignal` (the epoch edge) from the one target scan, so the hot ownership scan is not doubled. Each direction is pinned by its own test: removing the resubscribe dependency fails only 'reinstalls both session-tabs subscriptions when the host answers again'; restoring the reconnect bump fails only the two key-stability tests.
…ration (#20359) * fix(runtime): split the host-contact epoch out of the connection generation `connectionGeneration` carried two meanings and one reader was always wrong. holding the session mirror through an outage leaves its subscriptions stranded and that edge was the only thing left to revive them. But the same value is the mirror's cache key -- use-runtime-session-mirror-environment-key.ts keys the subscription effect on it, every published frame is stamped with it, and web-session-terminal-retirement-proof-ledger.ts drops retained proofs when it moves. So the bump #20085 needed as a resubscribe signal re-keyed and rebuilt the mirror after any brief flap, which is the #19647 symptom #19873/#20059 fix. Measured first: with the reconnect bump deleted, an ended stream followed by recovery issues zero resubscribes, and the mirror's subscribe call registers no `onClose`, so main's terminal close is dropped. #20085's claim is true -- the subscription really is dead after recovery -- so the trigger has to exist. It just must not be the cache key. Give each meaning its own value: - `connectionGeneration` returns to identity only: a new runtime session, a re-pair, an explicit clear. A same-runtime return no longer moves it, so no stamp, fence or retained proof is invalidated by a flap. - `hostContactEpoch` counts "the host answered again after we lost contact". It lives on the store entry and is read only as a dependency of the two subscription effects in use-web-session-tabs-sync.ts -- never passed to an installer, never part of `environmentKey`, so it cannot become a stamp. `useRuntimeSessionMirrorEnvironmentKey` becomes `useRuntimeSessionMirrorEnvironmentKeys`, returning `environmentKey` (identity) and `resubscribeSignal` (the epoch edge) from the one target scan, so the hot ownership scan is not doubled. Each direction is pinned by its own test: removing the resubscribe dependency fails only 'reinstalls both session-tabs subscriptions when the host answers again'; restoring the reconnect bump fails only the two key-stability tests. * test(runtime): pin the mirror hydration verdict across a host flap The generation tests assert the key string; this asserts what the user feels. The mirror's hydration verdict is stamped with the connection generation, so any bump discards it and every mirrored pane re-parks -- the tab-list rebuild. Held across an unverifiable probe, still discarded when the runtime id actually moved. * test(runtime): build real host statuses instead of casting partials
…ration `connectionGeneration` carried two meanings and one reader was always wrong. holding the session mirror through an outage leaves its subscriptions stranded and that edge was the only thing left to revive them. But the same value is the mirror's cache key -- use-runtime-session-mirror-environment-key.ts keys the subscription effect on it, every published frame is stamped with it, and web-session-terminal-retirement-proof-ledger.ts drops retained proofs when it moves. So the bump #20085 needed as a resubscribe signal re-keyed and rebuilt the mirror after any brief flap, which is the #19647 symptom #19873/#20059 fix. Measured first: with the reconnect bump deleted, an ended stream followed by recovery issues zero resubscribes, and the mirror's subscribe call registers no `onClose`, so main's terminal close is dropped. #20085's claim is true -- the subscription really is dead after recovery -- so the trigger has to exist. It just must not be the cache key. Give each meaning its own value: - `connectionGeneration` returns to identity only: a new runtime session, a re-pair, an explicit clear. A same-runtime return no longer moves it, so no stamp, fence or retained proof is invalidated by a flap. - `hostContactEpoch` counts "the host answered again after we lost contact". It lives on the store entry and is read only as a dependency of the two subscription effects in use-web-session-tabs-sync.ts -- never passed to an installer, never part of `environmentKey`, so it cannot become a stamp. `useRuntimeSessionMirrorEnvironmentKey` becomes `useRuntimeSessionMirrorEnvironmentKeys`, returning `environmentKey` (identity) and `resubscribeSignal` (the epoch edge) from the one target scan, so the hot ownership scan is not doubled. Each direction is pinned by its own test: removing the resubscribe dependency fails only 'reinstalls both session-tabs subscriptions when the host answers again'; restoring the reconnect bump fails only the two key-stability tests.
…tablyai#20085) * fix(runtime): hold the session mirror through an unverifiable probe Two derivations read the same host state and reached opposite verdicts, and the destructive one won. When a status probe came back unverifiable over a still-ready transport, runtimeHostConnectionStateForEntry called the host 'runtime-unavailable' (connected) while getReachableRuntimeSessionMirrorTargets dropped it, tearing down and cold-rebuilding the session-tab mirror while the host's flows were still delivering. The root cause is that applyRuntimeHostStatusSnapshot nulls entry.status for any non-verified probe while the snapshot retains the runtime identity. The connection-state reader consults the snapshot; the mirror-target reader did not. Give both readers one answer: - lastVerifiedRuntimeStatus() in shared/runtime-host-status.ts is now the single definition of "the last identity the host answered with". runtime-status.ts already had this inline as previousVerifiedStatus and now calls it. - The mirror-target reader asks the shared connection verdict instead of entry.status, gated on isDisconnectedRuntimeHostState -- only the one exit verdict earns a destructive read, per docs/reference/ssh-execution-boundary.md. 'checking' and 'reconnecting' are unverifiable, not evidence of an exit. Holding the target through the outage would strand the mirror on its own: the subscription is installed by the effect in use-web-session-tabs-sync.ts keyed on useRuntimeSessionMirrorEnvironmentKey(), a stream 'end' frame is dropped without resubscribing, and the parking layer retries only a rejected subscribe call. The teardown was the recovery. So regaining contact now advances the connection epoch, giving recovery its own "the host is back" trigger rather than leaving the mirror to be restored as a side effect of having been destroyed. The connection epoch is not the runtime session: a same-runtime return fires no restart hook, no provider session bump, and no toast. * test(runtime): drop the redundant status casts the new casting gate rejects
…stablyai#20095) * fix(runtime): hold the session mirror through an unverifiable probe Two derivations read the same host state and reached opposite verdicts, and the destructive one won. When a status probe came back unverifiable over a still-ready transport, runtimeHostConnectionStateForEntry called the host 'runtime-unavailable' (connected) while getReachableRuntimeSessionMirrorTargets dropped it, tearing down and cold-rebuilding the session-tab mirror while the host's flows were still delivering. The root cause is that applyRuntimeHostStatusSnapshot nulls entry.status for any non-verified probe while the snapshot retains the runtime identity. The connection-state reader consults the snapshot; the mirror-target reader did not. Give both readers one answer: - lastVerifiedRuntimeStatus() in shared/runtime-host-status.ts is now the single definition of "the last identity the host answered with". runtime-status.ts already had this inline as previousVerifiedStatus and now calls it. - The mirror-target reader asks the shared connection verdict instead of entry.status, gated on isDisconnectedRuntimeHostState -- only the one exit verdict earns a destructive read, per docs/reference/ssh-execution-boundary.md. 'checking' and 'reconnecting' are unverifiable, not evidence of an exit. Holding the target through the outage would strand the mirror on its own: the subscription is installed by the effect in use-web-session-tabs-sync.ts keyed on useRuntimeSessionMirrorEnvironmentKey(), a stream 'end' frame is dropped without resubscribing, and the parking layer retries only a rejected subscribe call. The teardown was the recovery. So regaining contact now advances the connection epoch, giving recovery its own "the host is back" trigger rather than leaving the mirror to be restored as a side effect of having been destroyed. The connection epoch is not the runtime session: a same-runtime return fires no restart hook, no provider session bump, and no toast. * test(runtime): drop the redundant status casts the new casting gate rejects * fix(runtime): hold four more host reads through an unverifiable probe Siblings of the session-mirror defect fixed in stablyai#20085. runtime-status-snapshot nulls `entry.status` for any non-verified probe while the snapshot retains the host's identity, so a host with a ready transport that is still delivering reads as gone to anything gating on `entry.status != null`. - client-event subscription selection dropped the stream for such a host, and its disconnect edge bumped the SSH generation, rebuilding even the active host's subscription - the web client's active session-tabs stream tore down and cold-rebuilt, twice per blip - landing preflight discarded its whole result - runtime-aware SSH selectors blanked mirrored target rows Each now reads the shared verdict, isConnectedRuntimeHostState of runtimeHostConnectionStateForEntry, or lastVerifiedRuntimeStatus where the read is host identity rather than reachability. No new predicate: every "genuinely gone" case is byte-identical, so nothing gains a retry loop. * test(runtime): build real host statuses instead of casting partials
…ration (stablyai#20359) * fix(runtime): split the host-contact epoch out of the connection generation `connectionGeneration` carried two meanings and one reader was always wrong. holding the session mirror through an outage leaves its subscriptions stranded and that edge was the only thing left to revive them. But the same value is the mirror's cache key -- use-runtime-session-mirror-environment-key.ts keys the subscription effect on it, every published frame is stamped with it, and web-session-terminal-retirement-proof-ledger.ts drops retained proofs when it moves. So the bump stablyai#20085 needed as a resubscribe signal re-keyed and rebuilt the mirror after any brief flap, which is the stablyai#19647 symptom stablyai#19873/stablyai#20059 fix. Measured first: with the reconnect bump deleted, an ended stream followed by recovery issues zero resubscribes, and the mirror's subscribe call registers no `onClose`, so main's terminal close is dropped. stablyai#20085's claim is true -- the subscription really is dead after recovery -- so the trigger has to exist. It just must not be the cache key. Give each meaning its own value: - `connectionGeneration` returns to identity only: a new runtime session, a re-pair, an explicit clear. A same-runtime return no longer moves it, so no stamp, fence or retained proof is invalidated by a flap. - `hostContactEpoch` counts "the host answered again after we lost contact". It lives on the store entry and is read only as a dependency of the two subscription effects in use-web-session-tabs-sync.ts -- never passed to an installer, never part of `environmentKey`, so it cannot become a stamp. `useRuntimeSessionMirrorEnvironmentKey` becomes `useRuntimeSessionMirrorEnvironmentKeys`, returning `environmentKey` (identity) and `resubscribeSignal` (the epoch edge) from the one target scan, so the hot ownership scan is not doubled. Each direction is pinned by its own test: removing the resubscribe dependency fails only 'reinstalls both session-tabs subscriptions when the host answers again'; restoring the reconnect bump fails only the two key-stability tests. * test(runtime): pin the mirror hydration verdict across a host flap The generation tests assert the key string; this asserts what the user feels. The mirror's hydration verdict is stamped with the connection generation, so any bump discards it and every mirrored pane re-parks -- the tab-list rebuild. Held across an unverifiable probe, still discarded when the runtime id actually moved. * test(runtime): build real host statuses instead of casting partials

The defect
Two derivations read the same host state and reached opposite verdicts, and the destructive one won.
When a host's status probe comes back unverifiable over a transport that is still ready:
runtimeHostConnectionStateForEntrycalls the entryruntime-unavailable— i.e. connected.getReachableRuntimeSessionMirrorTargetscalled it gone, and dropped it.User impact: the session-tab mirror for that host was torn down and cold-rebuilt while the host's flows were still delivering.
This is
docs/reference/ssh-execution-boundary.mdviolated: the verdict vocabulary islive/unverifiable/exitedwith no synonyms, and loss of contact is never evidence of process death. An unverifiable probe was being treated as an exit verdict by one reader while another correctly treated it as still-connected.Root cause
applyRuntimeHostStatusSnapshot(runtime-status-snapshot.ts:29) nullsentry.statusfor any non-verifiedprobe:while
snapshot.statusretains the last verified runtime identity.runtimeHostConnectionStateForEntryconsults the snapshot and gets the right answer. The mirror-target reader only readentry.status, so it sawnulland concluded the host was gone.One concept, two implementations. The fix is not to make the destructive reader less destructive — it is to make there be one answer.
Why the obvious fix alone would strand the mirror
Simply holding the target through the outage strands it, because today's teardown is what restores it. I verified each link rather than assuming:
web-session-tabs-sync/use-web-session-tabs-sync.ts:78-91, whose only deps are[runtimeSessionMirrorEnvironmentKey, workspaceSessionReady]→installGlobalSessionTabsSubscriptions.{ type: 'end' }frame is dropped without resubscribing (global-session-events.ts:85falls throughif (event.type !== 'snapshot' && event.type !== 'updated') return).window-visibility-subscription-parking.tsretries only a rejectedsubscribe()call, never an ended stream.So nothing but that effect re-running restores the mirror. The env leaving the key and re-entering it was the recovery.
The fix
Three files, no retry, no timer, no reconciliation sweep, no third predicate.
shared/runtime-host-status.ts—lastVerifiedRuntimeStatus()becomes the single definition of "the last identity the host actually answered with".runtime-status.tsalready had this inline aspreviousVerifiedStatusand now calls it, so there is one spelling instead of two.runtime-session-mirror-targets.ts— asks the shared connection verdict instead ofentry.status, gated onisDisconnectedRuntimeHostState. That predicate is already documented in this repo as "Only this verdict earns the destructive glyph. 'checking' and 'reconnecting' are unverifiable, not down." Dropping a mirror is a destructive read, so it earns the same gate.runtime-status.ts— regaining contact advances the connection epoch, giving recovery its own trigger that means "the host is back," rather than restoring the mirror as a side effect of having destroyed it.The connection epoch is not the runtime session: a same-runtime return fires no restart hook, no provider session bump, and no toast. The
#19241first-publication guard is preserved.One thing I got wrong
I first gated on
isConnectedRuntimeHostState. That was wrong — it would have newly dropped targets onchecking, adding a teardown wheremainhas none. Caught by enumerating every verdict against current behavior.isDisconnectedRuntimeHostStateis monotone againstmaineverywhere except a closed control channel, where dropping now matches every other host surface.This is one instance of a family
A reviewer who thinks they are approving a single-site fix will under-weight this. The same root cause — reading
entry.status != nullas a reachability verdict — appears at other readers. Sites I confirmed directly:store/slices/runtime-environment-ssh-selectors.ts:15hooks/ipc-events/runtime-environment-subscription-selection.ts:24components/browser-pane/restored-client-hosted-recovery-window.ts:42components/landing-preflight-runtime.ts:26A parallel audit reports at least eight sites, four of them destructive — client-event streams unsubscribed for a live host (with the gap-replay path skipped, because the stream was closed deliberately), an SSH-generation bump that cold-rebuilds the client-event subscription for even the active host, the active workspace's tab list cold-reloading twice per probe blip, and the landing integration banner vanishing until a probe re-verifies. I have not independently reproduced those four; they are flagged here so this PR is not read as the whole problem.
lastVerifiedRuntimeStatus()is the intended reuse point for those sites.Verification
Reproduction test was written and confirmed failing on
mainat94c2f96before any source change.Mutation testing — 9 mutations, 0 survivors. Each re-introduces the specific regression an assertion claims to catch:
entry.status !== nullisConnectedinstead of!isDisconnectedconnectionChangedback tomainGates, each proven able to fail before being believed:
tsc -p config/tsconfig.tc.web.json/.node/.cli— clean (it reported 4 real errors first; an empty log is the pass state).oxlint— clean; proven non-silent with a duplicate-identifier canary that exited 1.oxfmt --check— clean.vitest run --config config/vitest.config.ts src/renderer/src src/sharedon a clean checkout of this exact SHA: 4416 files / 38987 tests, 0 failures.src/mainshows 12 failures under full-suite load that are unrelated to this change (Electron, real-CLI, real-zsh, and timing/throughput measurements); a base-vs-branch comparison is in progress and will be reported in a comment.Pre-existing gap, deliberately not folded in
runtimeHostConnectionStateForEntry's snapshot branch handlestransport: 'disconnected'and'ready'but not'connecting'/'unknown', which fall through to a'disconnected'verdict. Same defect family, but both readers now agree there, and changing it moves the host-status UI — that needs its own evidence and its own PR.One pre-existing test updated
runtime-status-snapshot.test.tsasserted the connection generation stays put across an outage. Its stated intent is "without manufacturing a session restart or toast"; that intent is preserved and strengthened (asserts sameruntimeId,ensureBrowserClientHostForRestartedRuntimenot called, no toast). Only the epoch assertion changed, because the connection epoch is a distinct concept from the runtime session.