Repository navigation
fix(mobile): keep a session's chats when its desktop can't read its chat store - #49366
Conversation
… 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.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
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.
What Changed
Before: when the host's chat store (
agent-session-domain.db) failed to open, the host sent each workspace's tabs withagentSessionsUnverifiable: trueand no chat rows.After:
keepChatsHostCannotReadinmobile/src/session/tabs/session-tab-snapshot-gate.ts, called fromapplySessionTabs): 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.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 rulehostSnapshotAffirmsAgentSessions(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:
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.
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 000on the profile'sagent-session-domain.dbbefore 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.tspins 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:changedpasses. Platforms: macOS desktop + iOS 27 simulator. Phone-only change; it applies the same way to desktop,orca serveand 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
AI Disclosure
Review
Agent skill upstream boundary
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:
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)