Skip to content

fix(session-tabs): a tab stream the host ends resubscribes on the retry backoff - #27098

Merged
OrcaWin merged 1 commit into
mainfrom
np/p395-a3-stream-end-resubscribe
Oct 10, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
np/p395-a3-stream-end-resubscribe

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​358 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​358
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56

ELI5

A desktop or web client paired to an Orca server keeps two live tab streams open. If the server ended one of those streams while the connection stayed up, the client never noticed: its tab list froze until the app was restarted. Now the client notices the end and opens the stream again after a short wait, and the fresh stream brings the tab list back up to date.

What Changed

Before: the all-workspaces stream (session.tabs.subscribeAll) and the selected-workspace stream (session.tabs.subscribe) logged an end frame or an error response and kept the dead stream registered. The host does end these streams over a healthy socket, for example when an id-less session.tabs.unsubscribeAll sweeps every stream on the connection, or when a census fails three times (session_tabs_inventory_unstable). Nothing re-subscribed, because the parking layer only retried a subscribe that failed to start. New terminals and new workspaces then never appeared on that client.

After: an end frame, an error response, or the stream's close callback drops that stream and re-subscribes on the parking layer's existing jittered backoff (1 s, doubling to 30 s). On re-subscribe, the all-workspaces stream's census and the selected stream's initial snapshot re-apply through the normal path.

Mechanism:

  • WindowVisibilitySubscriptionContext gains ended(). It bumps the entry's generation (so the old stream's late frames are ignored), unsubscribes the old handle, and schedules the existing retry. Unsubscribing matters: after an error response the logical subscription stays registered for reconnect replay, and keeping it would put two streams side by side after the next reconnect.
  • Repeated short-lived streams keep widening the delay. The streak resets only once a stream has stayed up past the retry ceiling, so a host that ends streams immediately cannot drive a tight loop.
  • onError (a transport drop) is deliberately not an end. Reconnect replay and the host-contact path own that, and loss of contact is never treated as the stream being over.

Why

Reusing the parking layer's retry keeps one backoff policy for every session-tabs stream instead of adding new timers in each subscriber. Alternatives considered: re-running the whole mirror install on an end (heavier, and it would repeat the first-load work), or ignoring ends and relying on the host-contact resubscribe (that only fires when contact is lost, which is not the case here).

Takes over the approach of #21061 (@johnmarktaylor91), with credit.

Linked Issue

Refs #21052, #19092. This removes one way the tab list freezes (a stream the host ended), which matches both reports, but neither report proves that was its cause, so they stay open until confirmed. #27094 fixes the other known cause (#21928).

Visual Proof

N/A: background subscription bookkeeping; covered by the tests below.

Testing

  • window-visibility-subscription-parking-stream-end.test.ts (new; fails on origin/main): an ended stream is unsubscribed and re-subscribed after the backoff; repeated short-lived streams back off 1 s → 2 s → 4 s → 8 s; a duplicate end and an end after disposal do nothing; a stream that ends before its subscribe settles is unsubscribed and retried once.

  • web-session-tabs-stream-end-resubscribe.test.tsx (new; fails on origin/main): after an end frame on the all-workspaces stream, the re-subscribed stream's census mirrors a workspace the host created meanwhile; an error response on the selected stream unsubscribes it and re-subscribes once, not before the backoff; a transport error is not treated as an end.

  • web-session-tabs*, window-visibility*, host-session-mirror* and runtime-host-contact* 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

Renderer-only, no wire change. Works the same with old and new hosts: it only reacts to frames every host already sends. SSH: an unreachable host is not an end, so the existing host-contact handling is unchanged.

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

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d5ad5057-c830-4812-bc41-685a98f8f319

📥 Commits

Reviewing files that changed from the base of the PR and between cbc565d and f804ddd.


📒 Files selected for processing (6)
  • src/renderer/src/runtime/web-session-tabs-stream-end-resubscribe.test.tsx
  • src/renderer/src/runtime/web-session-tabs-sync/active-session-subscription.ts
  • src/renderer/src/runtime/web-session-tabs-sync/global-session-subscription.ts
  • src/renderer/src/runtime/web-session-tabs-sync/state.ts
  • src/renderer/src/runtime/window-visibility-subscription-parking-stream-end.test.ts
  • src/renderer/src/runtime/window-visibility-subscription-parking.ts


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

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