Skip to content

fix(mobile): keep a session's chats when its desktop can't read its chat store - #49366

Merged
AmoabaKelvin merged 1 commit into
mainfrom
mobile-keep-chats-host-cannot-read
Nov 26, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
mobile-keep-chats-host-cannot-read

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

If Orca on your computer can't open its saved chats for a moment, it tells the phone "here are the tabs, but I can't see the chats right now". The phone took that as "this session has no chats", so a workspace that only had chats showed "No tabs in this session" and forgot them. Now the phone keeps showing the chats it already knew about until the computer can list them again.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​40

What Changed

Before: when the host's chat store (agent-session-domain.db) failed to open, the host sent each workspace's tabs with agentSessionsUnverifiable: true and no chat rows.

  • The phone applied that frame as the complete list. A chat-only workspace showed "No tabs in this session" + Create Tab while the desktop still drew the chat tab. A workspace with terminals lost only its chat rows.
  • The phone also saved that list over its last-known tabs, so a force-quit didn't bring the chats back.

After:

  • Phone (keepChatsHostCannotRead in mobile/src/session/tabs/session-tab-snapshot-gate.ts, called from applySessionTabs): a frame that doesn't vouch for its chats keeps the chat rows the phone already shows, live or from the saved strip, in their place. They're marked inactive, so the host's selection still decides which tab is open. Frames that do vouch for their chats, and placeholder frames, are unchanged.
  • Nothing changes on the host. As today, the host lists its chats again once its chat store opens, which happens on the next chat request (for example opening a chat). The existing restore then publishes the chats and notifies subscribed phones.

The root cause, reproduced on main with a hidden dev desktop, an iOS simulator and a scripted phone client: the phone's snapshot gate ignored agentSessionsUnverifiable. Every other reader of the host's tab frames honors it through the shared rule hostSnapshotAffirmsAgentSessions (src/shared/remote-runtime/session-graph/host-session-snapshot-authority.ts).

Why

The shared rule says what this flag means: "unreadable chat journals yield empty chat rows despite valid terminals. Absence cannot cull saved chat placement." The flag and the rule shipped together in 59b746f, and the desktop's readers adopted them (apply-preparation-browser.ts, snapshot-apply.ts). The phone's gate was last changed by #46118, which taught it to ignore "ask later" placeholders, but it was never taught the chat part of the rule. So the fix goes in the phone's gate, through the same shared rule, not in a phone-only copy.

Alternatives considered:

  • Refuse such a frame on the phone when it would leave nothing, staying on "Loading tabs". Tried first. Review showed it stalls genuinely empty workspaces with no Create Tab when the store stays refused, and it swallows a host-confirmed close of the last terminal. Dropped.
  • Stop setting the flag on the host for refusals that can't clear. That would let desktop clients drop saved chat placement on a damaged store, which the rule exists to prevent.
  • Also retry the host's chat-store open from tab reads. Tried with a 5 s to 5 min backoff. Each try reinstalls the whole chat host, and installation sweeps every bot's tool files before it opens the store, so even a bounded retry repeats unrelated work. A clean host-side retry needs that install order changed first, so it's left as a follow-up. This PR's phone change doesn't depend on it.

This fixes the path reproduced here. The reporter's exact trigger isn't confirmed: their desktop chats were working, which usually means the chat store was open. Other paths tested on main kept the chat row: desktop restart, renderer reload, switching workspaces, closing the window, chat-only workspaces.

Linked Issue

#44840. This fixes the path reproduced above; the reporter's exact trigger isn't confirmed, so it doesn't close the issue. Linear: STA-16322.

Visual Proof

iOS simulator, a chat-only workspace, the desktop's chat store unreadable.

Before (main) After
before: No tabs in this session after: the Claude Chat tab stays

While the store can't be read, the chat view says so ("Could not load conversation"), which is the chat view's existing state. The tab is there to come back to once the store opens.

Testing

  • Reproduced on main: hidden dev desktop from this worktree (ORCA_BACKGROUND_LAUNCH=1), a scratch repo with a Claude chat tab, chmod 000 on the profile's agent-session-domain.db before launch. A paired phone-protocol client (pairMobileClient) got {"unverifiable":true,"tabs":[]} for the chat-only workspace while the desktop drew the chat tab. The iOS simulator, paired to that desktop, showed "No tabs in this session" + Create Tab.

  • Same setup on this branch: the phone kept the Claude Chat tab, which it had seen before the restart (live, then from its saved strip after relaunch), instead of showing "No tabs in this session".

  • mobile/src/session/tabs/session-tab-snapshot-gate.test.ts pins the rule: chats are kept and inactive on a frame that doesn't vouch for them, a host-confirmed last-tab close goes through, and vouching frames pass unchanged. It fails with the rule removed.

  • pnpm check:changed passes. Platforms: macOS desktop + iOS 27 simulator. Phone-only change; it applies the same way to desktop, orca serve and orcad hosts.

  • 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

Performance

None in the normal case: a frame that vouches for its chats costs one function call that returns the host's list. Only while the host can't read its chats does a frame take one linear pass over the current and incoming tabs. No new requests, timers or writes; the existing equality check still skips unchanged frames.

Risk

Level: Low

  • Riskiest part: during a chat-store outage the phone keeps showing chats it knew. A chat closed on the desktop during the outage stays on the phone until the host can list chats again, then it goes. Desktop clients already behave this way.
  • Mixed versions: older hosts that don't send the flag are unaffected, and every host that sends it benefits. Older phones are unchanged.
  • Back out: a plain revert. Nothing persisted changes shape.

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

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Follow-ups, not in this PR:

  • After a failed open at startup, the host doesn't retry its chat store on its own; it waits for the next chat request. A cheap retry needs chat-host installation to try the store before its install-time work.
  • A phone that never saw a workspace's chats still shows "No tabs" while the host can't list them, until the store opens.

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)

… store

A host whose chat store failed to open sends tabs with agentSessionsUnverifiable
and no chat rows. The phone read that as the full list: a chat-only workspace
showed "No tabs in this session" and saved the empty list over its last tabs.
Desktop clients already follow hostSnapshotAffirmsAgentSessions; the phone now
does too, keeping the chats it already shows (inactive, so the host's selection
still decides the open tab) until the host can list its chats again.
@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The snapshot gate preserves omitted current agent-session tabs when a snapshot affirms worktree contents but not agent sessions. It marks preserved active agent-session tabs inactive and drops omitted non-agent tabs. The application path uses the filtered tabs for tombstones and status/identity processing. Draft ownership tracking and selection/pruning checks continue to use the incoming snapshot tabs.

Merge Risk: Minimal · up to 72829

The phone now keeps known chat tabs, marked inactive, when the host cannot list chats, instead of dropping them. The change is narrow and tested. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the phone keeps a session's chat tabs when the desktop cannot read its chat store. It matches the summarized changes to the snapshot gate and the new keepChatsHostCann…
Description check Passed The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, N…
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.
Full details: Title check

Explanation

The title names the main change: the phone keeps a session's chat tabs when the desktop cannot read its chat store. It matches the summarized changes to the snapshot gate and the new keepChatsHostCannotRead helper. The title is specific and follows the fix(scope) convention.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, and each is filled in with specific detail. The Linked Issue section cites #44840 and states that it does not close the issue. The AI Disclosure and Review sections are left empty; the AI Disclosure section is optional for internal contributors, but the Review section has no content. The Visual Proof section uses before and after images, and the Testing section gives reproduction steps and platforms. The description is mostly complete, so it passes.

  • 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

Recent 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: 3d2809df-c796-45fb-a400-9438cb914001
Commits

Reviewing files that changed from the base of the PR and between eb1ceb4 and 7282945.

Files selected for processing: 3

  • mobile/src/session/tabs/session-tab-snapshot-gate.test.ts
  • mobile/src/session/tabs/session-tab-snapshot-gate.ts
  • mobile/src/session/tabs/use-mobile-session-tab-application.ts

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

@AmoabaKelvin
AmoabaKelvin merged commit b375d6d into main Nov 26, 2026
27 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