Skip to content

fix(mobile): keep loading a session's tabs until the desktop has sent them - #46118

Merged
AmoabaKelvin merged 2 commits into
mainfrom
fix/phone-tabs-ask-later-44840
Nov 21, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
fix/phone-tabs-ask-later-44840

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When the desktop is still starting up, it tells the phone "I don't know this workspace's tabs yet, ask again later". The phone read that as "this workspace has no tabs" and showed "No tabs in this session". It also saved that empty list as the last known tabs. Now the phone keeps showing "Loading tabs" until the desktop sends the real list.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​50 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33

What Changed

  • Before:
    • Until the desktop's window has published its tab inventory (desktop startup, or a phone reconnecting during a desktop restart), the host answers session.tabs.list/subscribe for a workspace it holds no entry for with a placeholder: publicationEpoch: 'none' (or 'none:client-navigation'), tabs: [].
    • The phone's snapshot gate accepted it like any snapshot. That set tabs loaded, showed "No tabs in this session" with Create Tab, and wrote [] over the saved last-tabs cache, which survives a force-quit.
    • Paired desktop clients already ignore this placeholder (hostSnapshotAffirmsWorktreeContents). That's why a laptop on the same proxy showed the tabs and the phone didn't.
  • After:
    • The phone drops placeholder frames through that same rule. It keeps loading and keeps the last strip until a real answer lands; the 2 s reconciliation poll keeps asking until then.
    • The rule moved from the renderer to src/shared/remote-runtime/session-graph/ so both clients share it instead of keeping a mobile copy.
  • Host change: a macOS desktop whose window has closed keeps running but will never publish. It used to answer an empty workspace with "ask later" forever. It now answers an authoritative empty:<epoch> when no window is attached, so Create Tab is still offered there. Workspaces with saved tabs are hydrated before this answer, as before.
  • Mixed versions: the phone waits on placeholders only from hosts that advertise the new session-tabs.placeholder-settles.v1 capability. With older desktops it keeps today's behaviour, so an older windowless desktop never leaves the phone spinning.

Why

The host's contract already says a 'none' frame means "ask later, never evidence tabs closed" (runtime-session-contracts.ts). The phone was the only client breaking that contract, so the fix belongs in the phone's snapshot gate, using the shared rule.

The host change is needed so the contract stays true in the one case where nothing would ever follow the placeholder: a windowless desktop. Without it, the phone would spin forever there.

The alternative was a phone-side timeout that turns "ask later" into "empty" after N tries. That brings back the false "No tabs" on a slow host and needs a tuned number; the capability handles mixed versions exactly.

Linked Issue

Refs #44840. This is a partial fix: the phone no longer shows or saves an empty tab list from the desktop's "ask later" answer, which covers the restart and reconnect cases. The reporter says a force-quit still showed no tabs, and that isn't reproduced on current main; the issue stays open for their details on a current desktop build.

Visual Proof

N/A. No new UI. The phone now shows the existing "Loading tabs" state, instead of the existing "No tabs in this session" state, during the window before the desktop publishes. It's a timing change of under a second on a desktop restart (measured below), with no layout, wording or control changes.

Testing

  • Reproduced on main with a hidden e2e desktop build and a paired client speaking the real phone protocol (pairMobileClient), polling session.tabs.list every 15 to 40 ms:

    • desktop quit and relaunch: the host answered none:client-navigation with tabs=0 19 times (about 0.5 to 0.9 s) before the real renderer:… list with 2 tabs. The subscription got snapshot none/0 tabs, then updated with 2 tabs.
    • window closed (macOS keeps running): an empty workspace answered none:client-navigation forever. On this branch it answers empty:1, and a phone terminal.create there still works (headless:pty-backed with 1 tab).
    • controls with no empty list on main: renderer reload, a phone-side tab close, a new worktree, and a worktree deleted and recreated at the same path.
  • Added src/main/runtime/session-tabs/publication/windowless-empty-session-tabs.test.ts. It fails without the host change (expected 'none' not to be 'none').

  • No phone test added: applySessionTabs has no test harness, and a hook test would pin internal setters rather than behaviour. The gate is one call to the shared rule. The host frame sequences above are the real evidence.

  • pnpm check:changed passes. Platforms: macOS (desktop e2e build). The host change applies to any desktop platform; the windowless state is reachable on macOS only, since other platforms quit when their last window closes.

  • I manually tested these changes locally

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

  • Every added test fails without this change and avoids the test anti-patterns

Risk

  • Riskiest part: the phone now waits instead of showing "No tabs" on any 'none' answer from a capable host.
  • Known edge: if the desktop renderer crashes and stays attached without recovering, an empty workspace on the phone shows "Loading tabs", then the existing "Tabs are taking longer than expected" state with Retry, instead of Create Tab. Tab creation can't work while the graph is unavailable anyway.
  • Performance:
    • While a host owes an answer, the phone keeps its existing 2 s session.tabs.list poll per open session screen. Before, it stopped after accepting the placeholder.
    • On a desktop restart that is at most one extra request (the placeholder lasted about 0.5 to 0.9 s).
    • Phone gate cost: one string compare per frame, and the capability is read through a ref, so it never rebuilds the tab stream.
    • Host cost: one null check per answer for a workspace with no entry.
  • Older phones and desktops:
    • Older phones ignore the new capability.
    • Older desktops don't advertise it, so new phones behave as before with them.
    • Older phones paired with a new windowless desktop now get empty:<n> where they got 'none'. Both render as "No tabs", which is correct there.
  • Back out: a plain revert.

Level: Low

AI Disclosure

Review

Two review rounds (Codex and Claude).

  • Round 1: both found the same P1, fixed in this PR: a new phone with an older desktop whose window is closed would spin forever on an empty workspace. That's why the capability gate exists.
  • Round 2: clean. Two P3s were left:
    • Polling continues while a crashed renderer stays attached; noted above.
    • A placeholder that lands before the host's capabilities load on first connect still flashes "No tabs" once. The host's follow-up frame settles it.

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

  • Security: no change.
  • Cross-platform: the host change only triggers when no window is attached, which only macOS keeps running.
  • SSH/remote: serve and orcad publish a headless graph before RPC starts, so they never hit the new branch. Relayed routes need the paired desktop to forward the capability (useRouteCapability) and otherwise keep today's behaviour.
  • Mobile: covered above.
  • Backwards compatibility: covered by the capability gate.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

…ished them

A desktop that hasn't published its tab inventory yet (startup, reconnect
during a restart) answers session.tabs with an empty "ask later" frame
(publicationEpoch 'none'). The phone treated it as a final empty list:
it showed "No tabs in this session" and saved [] over its tab cache.
Paired desktops already ignore these frames.

The phone now drops them through the same shared rule, so it keeps
loading and keeps the last strip until the real list arrives.

A desktop whose window has closed will never publish, so the host now
answers a workspace it has no tabs for with an authoritative empty
instead of "ask later". That keeps Create Tab reachable there.
…tle them

An older desktop whose window has closed keeps answering 'none' and never
publishes, so the phone keeps treating its placeholder as empty there. The
host now advertises session-tabs.placeholder-settles.v1.
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The changes add a runtime capability for hosts that settle placeholders, and use it to gate mobile session snapshot acceptance. They also update publication epoch selection for a missing snapshot when no authoritative window exists, with a test for an empty tab result. Renderer consumers now import host snapshot authority helpers from the shared session-graph module. Mobile draft pruning now uses confirmsMirroredTabSelection.

Merge Risk: Low · up to 199e2

The change stops the phone from showing "No tabs in this session" during desktop restarts and keeps its saved tab strip. One narrow edge remains. A tab update from a very old desktop that omits the publication epoch could be rejected by the renderer, leaving that workspace's tabs stale. This is unlikely for current hosts and is worth tightening before or soon after merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the mobile fix: the phone keeps loading a session's tabs until the desktop sends them. This matches the main change, which makes the snapshot gate ignore placeholder 'ask later' frames…
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.
Description check Passed The description follows the repository template closely. It has ELI5, What Changed (before/after and host change), Why (with alternatives considered), a partial Linked Issue (Refs #44840, with explana…
Full details: Title check

Explanation

The title names the mobile fix: the phone keeps loading a session's tabs until the desktop sends them. This matches the main change, which makes the snapshot gate ignore placeholder 'ask later' frames (publicationEpoch 'none') instead of showing 'No tabs'. The title does not mention the host-side windowless change or the new capability, but those are secondary to the primary fix.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed (before/after and host change), Why (with alternatives considered), a partial Linked Issue (Refs #44840, with explanation that it is a partial fix; the template asks for 'Fixes #' with an actual issue, and the author states the issue stays open), Visual Proof marked N/A with a reason, Testing with the three checkboxes checked and concrete reproduction steps, a Risk section with level, back-out plan and compatibility notes, an Agent skill boundary checkbox, and a Checklist. Gaps: the AI Disclosure section is empty, although the template only asks for it from non-team contributors, and the Review section names the Codex and Claude review rounds, which is informative. The Linked Issue section uses 'Refs' instead of 'Fixes', which the template says is not sufficient for outside contributors; the author's note that the issue remains open explains why, but the repository rule may still need a decision. The final checklist item for lint, typecheck, test and build is unchecked, so those checks are not reported as passing. The description is substantive and mostly complete, so it passes, with these items noted for the author.

  • 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

@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: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 444ad427-dba9-4697-8ed2-de0aaeed63e3
Commits

Reviewing files that changed from the base of the PR and between fe1c72c and 199e2b9.

Files selected for processing: 15

  • mobile/src/session/tabs/session-tab-snapshot-gate.ts
  • mobile/src/session/tabs/use-mobile-session-tab-application.ts
  • src/main/runtime/session-tabs/publication/session-tabs-change-publication.ts
  • src/main/runtime/session-tabs/publication/windowless-empty-session-tabs.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport.ts
  • src/renderer/src/runtime/hosted-terminals/recovery/panes/web-session-terminal-orphan-recovery-pane.ts
  • src/renderer/src/runtime/local-structured-session-tabs-sync/snapshot-apply.ts
  • src/renderer/src/runtime/web-session-tabs-sync/snapshots/apply-preparation-base.ts
  • src/renderer/src/runtime/web-session-tabs-sync/snapshots/apply-preparation-browser.ts
  • src/renderer/src/runtime/web-session-tabs-sync/subscriptions/active-session-subscription.ts
  • src/renderer/src/runtime/web-session-tabs-sync/terminal-handles/web-session-terminal-handle-events.ts
  • src/renderer/src/runtime/web-session-tabs-sync/tracking/tracking-decisions.ts
  • src/renderer/src/runtime/web-session-tabs-sync/tracking/tracking.ts
  • src/shared/remote-runtime/protocol/session-tabs-runtime-capabilities.ts
  • src/shared/remote-runtime/session-graph/host-session-snapshot-authority.ts

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

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