Repository navigation
fix: keep paired tab updates live after runtime terminal fallback - #19022
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughRuntime-owned mobile-session terminal creation now reuses the existing snapshot Merge Risk: ⚪ Minimal · up to Runtime-owned terminal fallback now keeps the existing session publication lineage, preventing clients from discarding subsequent tab updates. Coverage validates both existing renderer and headless publication cases, with no remaining merge-readiness risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the change, cause, tradeoffs, testing, and scope in detail. However, the required Linked Issue is not provided, and the Review and Agent skill upstream boundary sections are missing.
✨ Finishing Touches📝 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 critical issues — one minor suggestion inline.
Reviewed changes
- Epoch preservation on runtime-owned fallback —
createRuntimeOwnedMobileSessionTerminalnow reusesexisting?.publicationEpochinstead of minting a freshheadless:<ts>epoch, so supplementing a renderer's inventory no longer retires the renderer's publication lineage. - Regression test — a new
runtime-owned-terminal-publication-lineage.test.tscovers both arenderer:and aheadless:seed epoch, asserting the created result and the emitted client snapshot preserve the epoch while the snapshot version still advances.
The fix is minimal and correctly mirrors the pattern already used by the sibling publishPtyBackedMobileSessionTerminal and restoreStructuredAgentSessionTabsOnce paths. I confirmed the new test fails on both cases with the fix reverted (it fails exactly at the created.publicationEpoch assertion) and passes with it, and the touched files lint clean.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Match the file's `// Why:` comment convention on the inherited publication epoch, and drop a redundant duplicate mocks import in the lineage regression test while keeping the required side-effect order. No behavior change.
…ablyai#19022) * fix: preserve session publication during runtime terminal fallback * refactor(runtime): align fallback epoch comment and test preamble Match the file's `// Why:` comment convention on the inherited publication epoch, and drop a redundant duplicate mocks import in the lineage regression test while keeping the required side-effect order. No behavior change.

ELI5
Orca lets you watch the same workspace from two places at once — say the desktop app and a phone or browser tab. The desktop app is normally the one that announces "here are the terminals in this workspace," and the phone just listens.
When you asked for a new terminal and the desktop app couldn't make it itself, Orca quietly made one on the server instead. But in doing so it also announced itself as a brand new narrator. The phone took that literally: it assumed the old narrator had gone away for good and stopped listening to it. So the desktop kept announcing new terminals and the phone ignored every one of them — it sat frozen showing three terminals while the server had seven.
Now the server-made terminal simply joins the existing announcement instead of starting a new one. The original narrator stays trusted, the phone keeps listening, and your terminal list stays correct and live.
What Changed
One line in
src/main/runtime/orca-runtime-create-runtime-owned-mobile-session-terminal.ts: when a runtime-owned (fallback) terminal is added to a workspace that already has a published snapshot, the snapshot keeps the existingpublicationEpochinstead of minting a freshheadless:<ts>one. A fresh epoch is still minted for the first publication, when there is nothing to inherit.snapshotVersionstill advances, so ordering is unchanged.This matches the convention two sibling publishers already use:
orca-runtime-publish-pty-backed-mobile-session-terminal.ts:131—existing?.publicationEpoch ?? \headless:pty-backed:…``orca-runtime-restore-structured-agent-session-tabs-once.ts:139—existing?.publicationEpoch ?? \structured:…``Why
publicationEpochidentifies the publisher generation, not the content. Clients treat a change of epoch as "the previous publisher was retired":src/renderer/src/runtime/web-session-tabs-sync/tracking-decisions.tsrecords the old epoch in a retired set, and every later frame carrying it is dropped asWEB_SESSION_TABS_FRAME_OUTRANKED.So the old code had a fallback terminal creation — an additive event — declare the live renderer retired. The renderer went on publishing under its own epoch, and the paired client discarded all of it. CI reproduced a client pinned at three tabs while the host published seven; raw subscription logs confirm the later frames did arrive and were dropped.
Applies to native, SSH, and folder-workspace terminal creation, since all three share this fallback path.
Tradeoffs
Real, user-facing consequences of the change — not "none":
renderer:epoch, the snapshot is no longer classified as "headless-built" byisHeadlessBuiltMobileSessionPublicationBase, so the blanket preserve-every-terminal arm inorca-runtime-stored-mobile-snapshot-has-stale-preserved-tab.ts:91no longer applies. The runtime-owned tab now survives a renderer republish only through its persisted serve/SSH binding. The create path does passpersistHostSessionBinding: true, andgraph-sync-live-daemon-pty-tab-preservation.test.tscovers exactly this under arenderer:epoch — but it is a narrower guarantee than a blanket one.releaseRuntimeSessionOwnershipForRendererRetiredTabsused to early-return on aheadless:epoch. After a fallback create it now runs, and can release runtime session ownership for a runtime-owned terminal the renderer has dropped from its persisted session. That is the intended semantic (the old behaviour leaked ownership), but it is newly reachable.advancesSessionTabsFreshnesscounted any epoch change as inherently fresh. The fallback create no longer changes the epoch, so it relies entirely onsnapshotVersionadvancing. A publisher that ever failed to advance the version would now be silently dropped instead of accepted.runtime-mobile-session-projection.ts:85setsallowWorktreeOnlyMatchfrom!publicationEpoch.startsWith('headless'), so it flipsfalse → truehere. This is still keyed on the exactsnapshotPtyId; it only additionally tolerates a PTY not yet stamped with a pane identity, and theclaimedLivePtyIdsguard still prevents two tabs sharing a handle.orca terminal createagainst a host with a live renderer.Linked Issue
Fixes #
Visual Proof
N/A — no rendered UI change. The fix is in host-side publication bookkeeping; the visible symptom (a paired client's tab strip going stale) is a multi-device, timing-dependent sync failure that a screenshot of a single window cannot demonstrate. It is covered instead by the two regression cases and by the paired parked-reveal E2E scenario. Per this repo's current AGENTS.md directive, local Electron launches are paused, so no local app launch was used.
Testing
Automated:
src/main/runtime/runtime-owned-terminal-publication-lineage.test.ts(new) parameterises over arenderer:and aheadless:epoch and asserts the epoch is inherited,snapshotVersionadvances, and the paired client receives<epoch>:client-navigation.expected 'headless:mtqbjzj4' to be 'renderer:active-generation'); restoring it passes.src/main/runtime/graph-sync-live-daemon-pty-tab-preservation.test.tsre-run to confirm the narrowed preservation path still holds.pnpm tc:node,oxlinton both changed files, and the full shardedtestjob in CI all pass.Notes
Remote wire (
docs/reference/remote-wire-compatibility.md): this is a Rule 3 change — the frame shape is untouched, but the host publishes a different value for an existing field, which reaches old clients. It is safe because no client branches onrenderer:vsheadless:; client-side epoch handling only special-cases the:headless-merge:infix (publisher-identity-fences.ts:145) and otherwise compares epochs for equality. Epoch length does not grow unboundedly —getMergedMobileSessionPublicationEpochstrips rather than appends a merge suffix, so the worst case (renderer:<uuid>:client-navigation, 63 chars) stays well inside thez.string().max(128)cap on the close-lifecycle RPC.Cross-platform / SSH / folder workspace: no platform-dependent code; the single changed expression is shared by native, SSH, and folder-workspace creation.
Residual risk — this is a correct but partial fix for the class. Eleven other sites across seven files still mint an epoch unconditionally rather than inheriting, so the same "additive change retires the live publisher" failure remains reachable by other routes. Most notably
orca-runtime-reconcile-headless-mobile-session-browser-tabs.ts:56always mintsheadless-hydrated:<ts>, so a worktree with browser tabs can still retire a renderer epoch. Others:orca-runtime-close-structured-agent-session-tab.ts:159,210,orca-runtime-move-headless-mobile-session-tab.ts:64,107,143,orca-runtime-persist-headless-session-tab-props.ts:94,180,orca-runtime-close-headless-mobile-terminal-tab.ts:91,orca-runtime-apply-mobile-session-tab-navigation.ts:132. Scoped out deliberately: the terminal-creation path is the one CI actually reproduced, and each of the others needs its own reasoning about whether inheriting is correct (a close or a move may legitimately be a new generation). Worth a follow-up audit.Known coverage gap:
src/main/runtime/is not inCROSS_VERSION_WIRE_PREFIXESinconfig/scripts/pr-code-change-scope.mjs, so the cross-version wire job skipped for this PR even though this is a Rule 3 published-content change. Left as-is rather than widening CI scope unilaterally, since many other files also write this epoch.Checklist
N/Awith reason