Skip to content

fix(runtime): an outage is not a handle-gap verdict - #20059

Merged
nwparker merged 2 commits into
mainfrom
nwparker/handle-gap-outage-not-a-verdict
Sep 21, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/handle-gap-outage-not-a-verdict

Conversation

@nwparker

@nwparker nwparker commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

You are working in a workspace that lives on a remote Orca host. An agent is running there. Your network blips for a few seconds. When it comes back, Orca opens a second terminal tab beside the agent's tab that says session restored — a second copy of the same agent, resumed onto the same conversation the first one is still writing to.

That happens because a 15-second timer, which exists to ask "did the host tell us about this terminal yet?", was treated as if it had received an answer when in fact the question could not be delivered. Silence during an outage is not "no". This change makes the timer tell those two apart: if the connection was down at any point while it was waiting, it reports nothing and simply waits again.

What Changed

Before. Open a remote workspace (or wake it) while an agent there has a saved session. Orca briefly holds off on auto-resuming that agent, waiting up to 15 s for the host to publish the terminal's handle. If the network drops during those 15 s — a laptop lid, a Wi-Fi hop, a VPN renegotiation — the wait expires having heard nothing, and Orca reads that silence as "the host has no such terminal" and launches --resume in a new tab. The user sees a duplicate tab beside the agent that is still running (the same symptom as #19735, reached through a disconnect instead of a first-frame race). Both terminals now write into one transcript.

After. The same drop produces no second tab. The wait still ends on schedule so nothing is held indefinitely, but it records no answer; the pane parks again and gets a full fresh 15 s once contact is back. If the host really has nothing for that pane, the next full budget of connected silence decides, exactly as before.

Mechanism. Two files, src/renderer/src/lib/host-mirror-handle-gap-wait.ts and its test.

The deadline callback previously recorded a verdict whenever the connection generation still matched. It now records one only when all three hold:

  1. the generation still matches (unchanged — a reconnect under a new runtime id already voided it);
  2. the client does not currently know it is out of contact (disconnected or reconnecting from the shared runtimeHostConnectionStateForEntry derivation);
  3. the host-contact epoch is unchanged since the wait was armed. This is the counter runtime-status.ts bumps when the host answers again after a loss of contact on the same runtime, which by design does not move the generation. It catches an outage that began and ended inside the 15 s — at the deadline contact is back, the generation is untouched, and check 2 alone would have passed.

When any of the three fails the waiter releases without a verdict and the replayed sweep re-parks it. Nothing else changes: the read side (hasHostMirrorHandleWaitExpired), the four drains, and teardown are untouched.

Why

docs/reference/ssh-execution-boundary.md is the contract: the only verdicts are live / unverifiable / exited, loss of contact is never evidence of exited, and the safe direction is to leak rather than kill. Silence measured across an outage is unverifiable. Recording it as a verdict is the destructive reading, and the destruction is concrete: a duplicated agent writing into a live transcript.

Alternatives considered:

  • Rely on the connection generation. It is what the existing guard used, and it cannot see this case: a plain disconnect leaves the generation alone. runtime-status.ts advances it on the reconnect, and only when the runtime id changed ([Bug] Orca has to reconnect every time I switch tabs #19647 made same-runtime flaps deliberately not move it, because the mirror is keyed on it).
  • Invert isConnectedRuntimeHostState. That reads a never-probed host (checking) as out of contact, so a fresh pairing whose first probe is in flight would never decide. Mutating the guard to that shape turns seven existing tests red. The guard is narrowed to the two states an outage actually produces.
  • Hold the waiter until contact returns. That is the latch-that-never-releases defect this module exists to avoid, and it needs a store subscription on runtime status this module does not have. Releasing and re-parking gives the same result with the existing machinery and a bounded timer.
  • Only the point-in-time contact check (the first version of this PR). Correct for a drop that outlasts the deadline, but an outage that ends one millisecond before the deadline still recorded a verdict after one millisecond of contact — the same defect in a narrower window. A test for that shape failed against the first version; the epoch check closes it.

Linked Issue

Related: #19735 (same user-visible duplicate session restored tab; this is the disconnect path to it). No dedicated issue exists for the outage path.

Visual Proof

N/A — no UI change. The visible effect is the absence of a second session restored tab after a network blip on a remote workspace; the behaviour is pinned by the timed tests below.

Testing

Tested on macOS against the renderer test suite; the code is platform-independent (pure store/timer logic) and only runs for remote (paired-runtime) workspaces.

  • pnpm test on the nine handle-gap / resume / connection-state / runtime-status suites — 136 passed.
  • pnpm tc:web — clean. pnpm run check:code-quality:changed — 0 findings.
  • Reproduced on main (7063c2cbdd3): swapping only host-mirror-handle-gap-wait.ts back to main's version fails exactly one test, does not turn an outage into a verdict when the environment dropped mid-park (resume fires during the outage); the other 12 pass either way and serve as the shape control.
  • Mutation results (each mutation re-introduces one defect; each is caught by exactly the test written for it):
    • drop the contact check entirely → the disconnect test and the transport-down test go red;
    • count a never-probed host as out of contact (!isConnectedRuntimeHostState) → 7 tests go red, including the "contact returns → next budget decides" half;
    • skip the release while out of contact (hold forever) → the "next budget decides" half goes red;
    • drop the reconnecting arm → does not turn a transport-down snapshot into a verdict either goes red (this is the shape main's status channel actually publishes for a dropped link; it was untested before this revision);
    • drop the epoch check → does not record a verdict when contact was lost and regained inside the budget goes red.

Three new tests in host-mirror-handle-gap-resume.test.ts, each asserting both halves: no resume during/after the outage, and a resume once a full budget of connected silence has elapsed — so a fix that merely holds forever cannot pass them.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH / remote: this is the remote path. Local workspaces never reach this module.
  • Not a leak: the waiter always releases on its own timer; the only thing suppressed is the recorded verdict. Sustained churn can keep a pane re-parking, which is the documented-correct behaviour for a pane that genuinely is unverifiable.
  • Not a lost verdict: on a reconnect under a new runtime id the generation moves and the pane is re-evaluated on the new connection with a fresh budget, as before. The runtime-unavailable state (transport up, status probe failed) is deliberately not treated as an outage: the mirror rows arrive over the same transport, so silence there is host evidence.
  • Only consumer of the verdict is findUnhydratedHostMirrorForPane in host-mirrored-pane-liveness.ts, which feeds the sleeping-agent resume sweep. Nothing else reads it.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@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 — the guard is correct and its own test is falsifiable; one test-coverage gap on the reconnecting branch and one dependency observation below.

Reviewed changes

  • Outage guard — host-mirror-handle-gap-wait.ts adds environmentContactIsLost (disconnected or reconnecting) and skips recording an expired handle-gap verdict when the environment is out of contact, so a deadline expiring mid-outage no longer authorizes a resume the host is still running.
  • Resume test — host-mirror-handle-gap-resume.test.ts adds does not turn an outage into a verdict when the environment dropped mid-park plus two store-seeding helpers; it is falsifiable (forcing environmentContactIsLost to return false kills exactly this test).
  • Dependency-visible (#19873 / #19647) — runtimeHostConnectionStateForEntry + isDisconnectedRuntimeHostState land here as visible dependencies; NoticeHostGlyph/use-worktree-card-foundation stop dimming unprobed hosts; the status-recheck ladder re-probes null verdicts and preserves live verdicts across unverifiable probes.

ℹ️ "Not-probed ≠ disconnected" is fixed on only one of the two derivations (belongs to #19873)

NoticeHostGlyph and use-worktree-card-foundation now read an unprobed host as checking, but the shared buildExecutionHostRegistry (src/shared/execution-host-registry.ts, runtimeHealth) still returns 'disconnected' for !status. The registry feeds the sidebar host options, HostSectionHeader, composer targets, and task-page hosts, so those still dim an unprobed host while the worktree card does not. The divergence is introduced by #19873 (visible here as a dependency), not by this PR's commit — flagging so it stays tracked, not as a merge-blocker.

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

const connectionState = runtimeHostConnectionStateForEntry(
useAppStore.getState().runtimeStatusByEnvironmentId.get(environmentId)
)
return isDisconnectedRuntimeHostState(connectionState) || connectionState === 'reconnecting'

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.

The || connectionState === 'reconnecting' clause is untested. The new resume case drives disconnected via { status: null }, but after #19647 the outage-over-a-live-mirror state is reconnecting (live status preserved, remoteControl refreshed to reconnecting); and { status: null } drops the environment from getReachableRuntimeSessionMirrorTargets, which retracts the row and releases the waiter before this deadline path can run. Removing the clause would leave the suite green while regressing the primary production path.

Technical details
# Cover the reconnecting branch of the outage guard

## Affected sites
- src/renderer/src/lib/host-mirror-handle-gap-wait.ts:174 — `|| connectionState === 'reconnecting'` has no integration coverage.
- src/renderer/src/lib/host-mirror-handle-gap-resume.test.ts:143 — helper only seeds `{ status: null }` (→ `disconnected`).

## Required outcome
- A test that seeds a LIVE status whose `remoteControl.state === 'reconnecting'` and asserts the handle-gap wait skips the verdict (pane stays parked, no resume claim), mirroring the existing `does not turn an outage into a verdict` case.

## Open questions
- Is `{ status: null }` (→ `disconnected`) actually reachable at the deadline in production, or always preempted by row retraction via `getReachableRuntimeSessionMirrorTargets`? If preempted, the existing test pins a branch the guard never sees while the reachable `reconnecting`/`closed` branches go unpinned.

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

Reviewed changes

  • Writer-guard comment restated — runtime-status.ts rewords the #19647 guard comment into #20003's vocabulary; the guard line itself is unchanged. Accurate: a null, snapshot-less entry only comes from refreshRuntimeEnvironmentStatus's throw branch, and RuntimeHostStatusOwner.complete preserves snapshot.status on failure while patching only checkedAt/verification.
  • E2E gate demoted to diagnostic — paired-remote-terminal-tab-switch-reconnect.spec.ts replaces expect(flapped.sawNullStatus).toBe(false) with a logged diagnostic. Correct: post-#20003, applyRuntimeHostStatusSnapshot derives entry.status from verification === 'verified', so an outage nulls entry.status by design while the live verdict lives in snapshot.status; the surviving generationAfterRecovery === generationBeforeFlap and finalObservation.mounted gates still fail on the unfixed writer.

ℹ️ No new issues in this incremental delta. The prior review's reconnecting coverage gap in host-mirror-handle-gap-resume.test.ts is not addressed by these commits, so this is a non-approving delta review.

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

@nwparker
nwparker force-pushed the nwparker/fix-19735-handle-gap-wait branch from cb29f42 to e652df2 Compare September 15, 2026 10:16
@nwparker
nwparker deleted the branch main September 17, 2026 05:23
@nwparker nwparker closed this Sep 17, 2026
@nwparker nwparker reopened this Sep 17, 2026
@nwparker
nwparker changed the base branch from nwparker/fix-19735-handle-gap-wait to main September 17, 2026 05:25
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change adds bounded waiting for host-mirror PTY handles before sleeping-agent resume. It records generation- and binding-specific expiry verdicts, drains waiters on handles or row removal, and cleans up verdicts during environment teardown. Replay failures no longer interrupt sibling waiters. Runtime status refreshes preserve established live status after failed probes. Tests cover renderer behavior, runtime hydration, SSH resume handling, paired reconnects, and sidebar connectivity states.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 51ebc

The main reconnect regression may remain undetected because its test does not prove the fault occurred. Strengthen these assertions before merging; also move sidebar screenshots after UI assertions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.87% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 62 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the primary change: an outage must not produce a host-mirror handle-gap verdict.
Description check ✅ Passed The description is complete and directly aligned with the changes. It explains the user impact, mechanism, rationale, alternatives, linked issue, testing, visual-proof status, and checklist coverage.
  • Fix all pre-merge checks with AI
✨ 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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: efedb06d-76b6-419a-81fe-3464b3ce6257

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3b71f and 51ebc04.

📒 Files selected for processing (21)
  • src/renderer/src/lib/host-mirror-handle-gap-drain.test.ts
  • src/renderer/src/lib/host-mirror-handle-gap-landed-handle.test.ts
  • src/renderer/src/lib/host-mirror-handle-gap-replay-containment.test.ts
  • src/renderer/src/lib/host-mirror-handle-gap-resume.test.ts
  • src/renderer/src/lib/host-mirror-handle-gap-subscription-lifetime.test.ts
  • src/renderer/src/lib/host-mirror-handle-gap-teardown.test.ts
  • src/renderer/src/lib/host-mirror-handle-gap-verdict-union.test.ts
  • src/renderer/src/lib/host-mirror-handle-gap-wait.ts
  • src/renderer/src/lib/host-mirrored-pane-liveness.ts
  • src/renderer/src/lib/resume-sleeping-agent-session-provider-claim.test.ts
  • src/renderer/src/lib/resume-sleeping-agent-session.ts
  • src/renderer/src/lib/sleeping-agent-pane-ownership.ts
  • src/renderer/src/lib/ssh-failed-target-sleeping-agent-resume.test.ts
  • src/renderer/src/runtime/host-session-mirror-hydration-drain.test.ts
  • src/renderer/src/runtime/host-session-mirror-hydration.ts
  • src/renderer/src/runtime/web-session-tabs-sync/tracking-lifecycle.ts
  • src/renderer/src/store/slices/runtime-status.test.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • tests/e2e/helpers/runtime-endpoint-link-fault.ts
  • tests/e2e/paired-remote-terminal-tab-switch-reconnect.spec.ts
  • tests/e2e/sidebar-runtime-host-disconnected-glyph.spec.ts

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

Comment on lines +448 to +460
console.log(
`[tab-switch-repro] dials at the hop: accepted=${link.acceptedConnectionCount()} stalled=${link.stalledConnectionCount()}`
)

// ---- Arm B2: the reporter's "reconnecting" state. Sever the established flows
// once while new dials still hang, so the shared-control socket enters
// `reconnecting` and the status recheck ladder arms. What the store does with
// the resulting failed status.get is the writer under test: a live verdict must
// not become `status: null` because the client could not ask.
const generationBeforeFlap = (
await observePane(client.page, target.webTabId, client.environmentId, 0)
).connectionGeneration
const dropped = link.dropEstablished()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '390,535p' tests/e2e/paired-remote-terminal-tab-switch-reconnect.spec.ts

Repository: stablyai/orca

Length of output: 7952


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- candidate symbols ---'
rg -n "function (recordRevealTimeline|observePane)|const (recordRevealTimeline|observePane)|recordRevealTimeline|observePane|class .*Link|stalledConnectionCount|dropEstablished|connectionGeneration|acceptedConnectionCount" tests/e2e src | head -n 240
printf '%s\n' '--- file outline ---'
ast-grep outline tests/e2e/paired-remote-terminal-tab-switch-reconnect.spec.ts
printf '%s\n' '--- file size ---'
wc -l tests/e2e/paired-remote-terminal-tab-switch-reconnect.spec.ts

Repository: stablyai/orca

Length of output: 30266


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- pane and timeline helpers ---'
sed -n '220,330p' tests/e2e/paired-remote-terminal-tab-switch-reconnect.spec.ts
printf '%s\n' '--- fault link helper ---'
sed -n '1,145p' tests/e2e/helpers/runtime-endpoint-link-fault.ts
printf '%s\n' '--- test setup and Arm A assertions ---'
sed -n '1,220p' tests/e2e/paired-remote-terminal-tab-switch-reconnect.spec.ts
sed -n '330,430p' tests/e2e/paired-remote-terminal-tab-switch-reconnect.spec.ts

Repository: stablyai/orca

Length of output: 20316


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- runtime status generation definitions and updates ---'
rg -n -C 4 "runtimeStatusByEnvironmentId|connectionGeneration" src/renderer/src/store src/renderer/src/hooks | head -n 320
printf '%s\n' '--- pane parking/disconnect references ---'
rg -n -C 4 "transportUnsubscribe|unsubscribe.*transport|cold.?park|park.*pane|runtimeStatusByEnvironmentId.*delete|delete.*runtimeStatusByEnvironmentId" src/renderer/src tests/e2e/helpers tests/e2e/paired-remote-terminal-tab-switch-reconnect.spec.ts | head -n 320

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- runtime-related source files ---'
rg --files src/renderer/src | rg 'runtime-status|runtime-environment|ipc-events.*runtime|agent-status'
printf '%s\n' '--- exact runtime status writers ---'
rg -n -C 6 "setRuntimeStatus|runtimeStatusByEnvironmentId:|runtimeStatusByEnvironmentId\\.set|runtimeStatusByEnvironmentId\\.delete|connectionGeneration.*status|status.*connectionGeneration" src/renderer/src --glob '!*.test.*' --glob '!*.test.tsx' | head -n 260

Repository: stablyai/orca

Length of output: 35990


🏁 Script executed:

#!/bin/bash
set -e
sed -n '150,275p' src/renderer/src/store/slices/runtime-status.ts
printf '%s\n' '--- callers of status cleanup and disconnect ---'
rg -n -C 5 "clearRuntimeEnvironmentStatus|removeRuntimeEnvironmentStatus|dropRuntimeEnvironmentStatus|retainRuntimeEnvironmentStatuses|setRuntimeEnvironmentStatus\\(" src/renderer/src --glob '!*.test.*' --glob '!*.test.tsx' | head -n 260

Repository: stablyai/orca

Length of output: 11475


Assert that Arm B2 enters the intended fault state.

recordRevealTimeline can stop immediately because the parked pane already contains READY. It does not prove that a stalled dial occurred. The test only logs stalledConnectionCount() and the result of dropEstablished(). The generation comparison also accepts two null values because observePane maps a missing generation to null.

Add assertions for the stalled dial, dropped established flow, and baseline generation.

Proposed assertions
+    await expect
+      .poll(() => link.stalledConnectionCount(), {
+        timeout: 30_000,
+        message: 'Arm B precondition: a replacement dial must stall at the link'
+      })
+      .toBeGreaterThan(0)
+
     const generationBeforeFlap = (
       await observePane(client.page, target.webTabId, client.environmentId, 0)
     ).connectionGeneration
+    expect(generationBeforeFlap).not.toBeNull()
     const dropped = link.dropEstablished()
+    expect(
+      dropped,
+      'Arm B2 precondition: an established flow must be dropped'
+    ).toBeGreaterThan(0)
📝 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
console.log(
`[tab-switch-repro] dials at the hop: accepted=${link.acceptedConnectionCount()} stalled=${link.stalledConnectionCount()}`
)
// ---- Arm B2: the reporter's "reconnecting" state. Sever the established flows
// once while new dials still hang, so the shared-control socket enters
// `reconnecting` and the status recheck ladder arms. What the store does with
// the resulting failed status.get is the writer under test: a live verdict must
// not become `status: null` because the client could not ask.
const generationBeforeFlap = (
await observePane(client.page, target.webTabId, client.environmentId, 0)
).connectionGeneration
const dropped = link.dropEstablished()
console.log(
`[tab-switch-repro] dials at the hop: accepted=${link.acceptedConnectionCount()} stalled=${link.stalledConnectionCount()}`
)
// ---- Arm B2: the reporter's "reconnecting" state. Sever the established flows
// once while new dials still hang, so the shared-control socket enters
// `reconnecting` and the status recheck ladder arms. What the store does with
// the resulting failed status.get is the writer under test: a live verdict must
// not become `status: null` because the client could not ask.
await expect
.poll(() => link.stalledConnectionCount(), {
timeout: 30_000,
message: 'Arm B precondition: a replacement dial must stall at the link'
})
.toBeGreaterThan(0)
const generationBeforeFlap = (
await observePane(client.page, target.webTabId, client.environmentId, 0)
).connectionGeneration
expect(generationBeforeFlap).not.toBeNull()
const dropped = link.dropEstablished()
expect(
dropped,
'Arm B2 precondition: an established flow must be dropped'
).toBeGreaterThan(0)

await expect(card).toBeVisible()

// Captured before the assertions so a regression run still yields the evidence image.
await captureCard(card, testInfo, 'runtime-host-glyph-before-probe.png')

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

🔎 Supported by static analysis

🏁 Script executed:

sed -n '60,125p' tests/e2e/sidebar-runtime-host-disconnected-glyph.spec.ts

Repository: stablyai/orca

Length of output: 2794


🏁 Script executed:

sed -n '1,75p' tests/e2e/sidebar-runtime-host-disconnected-glyph.spec.ts

Repository: stablyai/orca

Length of output: 2836


Capture screenshots after the expected glyph appears.

seedRuntimeHost updates the store inside page.evaluate and returns without waiting for React to commit the DOM. Each captureCard call invokes Locator.screenshot before the corresponding glyph and opacity assertions. The screenshot can therefore show stale state while the later auto-waiting assertions pass.

Move each captureCard call after its glyph and opacity assertions.

nwparker added a commit that referenced this pull request Sep 17, 2026
…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.
nwparker added a commit that referenced this pull request Sep 17, 2026
…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.
nwparker added a commit that referenced this pull request Sep 17, 2026
…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.
nwparker added a commit that referenced this pull request Sep 17, 2026
…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
nwparker added a commit that referenced this pull request Sep 17, 2026
…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.
The per-pane handle-gap wait releases at a 15s deadline and records that
expiry as a verdict, which authorises the sleeping-agent resume. The
connection generation was the only thing voiding that verdict, and a plain
disconnect never advances it — runtime-status.ts advances on the reconnect,
under a new runtime id. So a network drop mid-turn expired the wait with a
generation that still matched, and the replay forked a second `--resume`
onto the transcript the host was still writing: #19735 through the
disconnect door.

Suppress the verdict while the client positively knows it is out of contact,
reusing the shared runtime-host connection derivation. The waiter still
releases and re-parks, so contact returning gets a full fresh budget and the
pane is still decided on real silence.

Not redundant with the landed-handle drain that follows this commit, nor with
the read-time pane identity from adv2-skew (cdafc90). Mutation on the
composed tree gives three disjoint kills: dropping this guard fails only "does
not turn an outage into a verdict"; dropping the landed-handle drain fails only
the two landed-handle cases; forcing this guard always-true fails 16 across every
suite. Three guards, three holes.
@nwparker
nwparker force-pushed the nwparker/handle-gap-outage-not-a-verdict branch from 51ebc04 to aef5ced Compare September 19, 2026 06:49
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
… either

The contact check at the deadline is a snapshot of now. An outage that began
and ended inside one wait, on the same runtime, leaves contact restored and the
generation untouched, so the deadline recorded a verdict after milliseconds of
real contact. Capture hostContactEpoch at park time and refuse the verdict when
it moved; the waiter still releases and re-parks for a fresh budget.

Also pins the transport-down snapshot shape (reads 'reconnecting'), which is
what main's status channel actually publishes for a dropped link and was the
one arm of the guard no test exercised.
@nwparker
nwparker merged commit f492054 into main Sep 21, 2026
29 of 30 checks passed
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