Skip to content

fix(session-tabs): a returning paired publisher is repaired by an authoritative census - #27094

Merged
OrcaWin merged 3 commits into
mainfrom
np/p395-a2-remote-epoch-repair
Oct 10, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
np/p395-a2-remote-epoch-repair

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​254 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​254
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​140 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​139

ELI5

A desktop paired to an Orca server could stop showing new tabs in a workspace: after the server briefly wrote that workspace's tab list itself, the desktop treated the normal writer as dead and threw away its updates for good. Now, when the desktop throws away an update for that reason, it asks the server for a full tab census, and if the server says that writer is current, the update lands.

What Changed

Before: the server mints short-lived headless: publication ids for a workspace whenever it changes tabs itself (navigation, moving a tab, tab props, closing a structured session). The renderer's own id then comes back. The desktop's fence retires the previous id whenever a new one appears, so the returning renderer id was rejected at every gate and nothing ever revived it. Tabs created after that never appeared until the app restarted (#21928).

After: a frame dropped because its publication id is retired schedules one bounded census (session.tabs.listAll) for that environment and workspace, through the shared repair lane from #27093 (at most 3 attempts per 60 s, backoff 250 ms to 5 s, coalesced per workspace). If the census is labelled authoritative and names that id, its lineage is revived and the census snapshot for that one workspace goes through the normal stream apply path. A delayed frame from the short-lived writer is then the retired one and stays fenced.

Mechanism:

  • retired-epoch-census.ts owns the paired lane. handleGlobalSessionEvent schedules it when the frame it just recorded is retired.
  • Only the dropped workspace's snapshot is applied. The census is not treated as a full inventory, so it cannot prune other workspaces, and it skips the first-load side effects of loadInitialWebSessionTabs.
  • Revival uses the shared admitRetiredValueUnderAuthority with the lineage matcher, so the subscription fence itself is never relaxed.

Why

The local mirror already solved this exact sequence with an authoritative census; the paired path never used it. Asking the host is the only safe way to tell a live returning publisher from a dead one, because a delayed frame from a dead generation can carry a higher version. Alternatives considered: relaxing the fence for higher versions (resurrects dead generations), or a host-assigned total frame order (needs both a new host and a new client, which the upcoming layout stream already covers).

Mixed versions: the host labels a census authoritative only for clients that advertise the authoritative-inventory capability. An older host's unlabeled census may be partial, so it revives nothing and behavior there is unchanged. Takes over the approach of #21932 (@shahidbeig-a11y), with credit.

Linked Issue

Fixes #21928

Refs #19092, #21052 (one of their possible causes).

Visual Proof

N/A: background tab-mirror bookkeeping; covered by the renderer test below.

Testing

  • src/renderer/src/runtime/web-session-tabs-retired-epoch-census-repair.test.tsx (new; the first case fails on origin/main with expected [ 'web-terminal-host-tab-a' ] to include 'web-terminal-host-tab-b'): renderer R@v3 → headless H@v1 → R@v5 carrying a new tab mirrors the new tab after one authoritative census, and a delayed H@v2 is still rejected. An unlabeled (older host) census revives nothing.

  • web-session-tabs*, host-session-mirror* and local-structured-session* suites pass.

  • pnpm tc:web, oxlint, pnpm run check:code-quality:changed.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Stacked on #27093. Renderer-only; no new RPC method or field. SSH-hosted and folder workspaces are keyed by environment and workspace id like any other. Census load is bounded by the existing repair budget and reuses the same listAll the bootstrap already pays for.

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)

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →Review in Change Stack →

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

When a snapshot event uses a retired publication epoch, the handler schedules a census for its environment and worktree. The census applies a selected worktree snapshot only when the subscription remains current, the expected revision matches, the response is successful, valid, and authoritative, and no newer stream frame arrived during the request. The change also adds lifecycle cleanup and tests for authoritative responses, non-authoritative responses, and newer stream frames.







Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 04636

The change repairs the paired session-tab mirror after a temporary headless publisher, with guards against stale or non-authoritative data. No merge-blocking risk remains; a tab-removal test assertion would be a nice addition.

Pre-merge checks | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check Warning Issue #21928 requires paired-host repair after the R → H → R sequence. The implementation schedules a bounded census, requires authoritative: true, revives only the confirmed lineage, and applies th… Add an automated regression assertion that the authoritative R census removes a tab absent from the census snapshot. Keep an assertion that a delayed H frame cannot restore that removed tab.
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check Passed The changed files implement and test the #21928 paired session-tab repair. The census lane, lifecycle cleanup, event integration, and tests support bounded scheduling, authority checks, workspace scop…
Title check Passed The title clearly identifies the main change: repairing a returning paired publisher through an authoritative census. It is concise and specific.
Description check Passed The description includes the required sections, linked issue, user-facing behavior, implementation details, rationale, visual-proof explanation, testing information, and scope notes. Manual testing an…

Full details: Linked Issues check

Explanation

Issue #21928 requires paired-host repair after the R → H → R sequence. The implementation schedules a bounded census, requires authoritative: true, revives only the confirmed lineage, and applies the selected workspace snapshot through the normal event path. The test covers new-tab recovery, delayed headless-frame rejection, unlabeled-census rejection, and the in-flight race. The test does not verify that a tab removal reaches the client after authoritative confirmation, although #21928 explicitly requires new tabs and tab removals.



  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR







🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

🧹 Nitpick comments (1)
src/renderer/src/runtime/web-session-tabs-retired-epoch-census-repair.test.tsx (1)

171-200: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a tab-removal assertion after the census repair.

Issue #21928 requires the client to receive both new tabs and tab removals after authoritative confirmation. This test checks only that host-tab-b appears. Publish one more frame with RENDERER_EPOCH, version 6, and only terminal('a'). Then assert that host-tab-b is gone. This assertion confirms that the revived lineage accepts frames on the normal stream path after the repair.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83f512d8-04c4-480e-9e35-42a62c89a96d
📥 Commits

Reviewing files that changed from the base of the PR and between 33d90bb and 046363b.

📒 Files selected for processing (4)
  • src/renderer/src/runtime/web-session-tabs-retired-epoch-census-repair.test.tsx
  • src/renderer/src/runtime/web-session-tabs-sync/global-session-events.ts
  • src/renderer/src/runtime/web-session-tabs-sync/retired-epoch-census.ts
  • src/renderer/src/runtime/web-session-tabs-sync/tracking-lifecycle.ts

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

@OrcaWin
OrcaWin merged commit f1a09aa into main Oct 10, 2026
74 of 96 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.

[Bug]: Remote tab mirror rejects its live renderer publisher after a headless epoch, hiding new tabs and retaining closed tabs

1 participant