feat(desktop): a cloud workspace opens on its chats while its box wakes
Stacked on #9561, which fixes the stored-chat read this depends on (chatHistory.events with latest fails in production with "integer out of range"). Merge #9561 first.
Why
Opening a cloud workspace whose box was asleep showed empty or waiting panes until the box answered, often 20 s or more. On a computer that had never opened the workspace, no tabs appeared at all. The chats are already in the database from chat sync, and the tab layout is stored locally, so there's no reason to wait for the box to show them.
What changes
- Chat panes show the stored conversation for any cloud workspace, and switch to live when the box answers. The merge path already existed (
useStoredChatSnapshot→withStoredHistory) but only ran with theworkspace-movesflag. - Tabs from the database on a first open. If this computer has no tabs for a cloud workspace and the box hasn't listed its chats yet, each stored chat gets a tab (
chatHistory.ofWorkspace).- The database doesn't know which chats were closed, so this runs only when the layout is empty.
- When the box answers, the existing
chatPanesClosedElsewherecloses any it had closed.
- Panes that need the box wait in place. Terminal, files, file tree, changes, diff, review and mobile show "Waking up workspace" until the box first answers (
WaitsForWorkspace, applied in the registry bywaitForWorkspace).- A later drop is left to the pane, so a terminal keeps its scrollback.
- The stored-chat screen shown before the box has an address no longer needs the flag.
New strings ("Starting the cloud workspace…", "Moving its chat(s)…", "# chat(s) stayed in the old workspace.") are translated in every locale; the pane text reuses "Waking up workspace".
Testing
Against production: this branch's desktop app, signed in to my real account, opened "Investigate sandbox snapshot and resume latency". Its box was asleep, it has 4 stored chats, and this app had no tabs for it.
| Time after click | What showed |
|---|---|
| 0.7 s | All 4 chat tabs, from the database |
| 1 s | The selected chat's full conversation, from the database |
| 2.4 s | The "Waking up workspace ~30s · Retry" pill |
| 20.1 s | The box answered and the pill went away |
How that run was set up:
- API: production's API doesn't have #9561's fix yet. For this run only, the dev app sent an explicit
beforeSeqso the stored read worked. That change is not in this PR. - CORS: for this run only, the dev window had web security turned off, so the dev origin could reach production's API. Also not in this PR.
Not checked in the app: a terminal or file pane while the box wakes. The test workspace had none open, and I couldn't fake a sleeping box from inside the app, because its socket goes around the browser network stack.
Checks: desktop typecheck, biome, check:i18n, and the v2-workspace tests (1223 pass, including a new test for turning stored chats into tabs).
Summary by cubic
A cloud workspace with an asleep box now opens on its stored chats instead of showing empty or waiting panes for 20+ seconds, and a workspace never opened on this computer gets a tab per stored chat.
- Chat panes show the stored conversation for any cloud workspace and switch to live when the box answers; this no longer needs the
workspace-movesflag, and a pane never shows another chat's history as a placeholder. - The database doesn't track closed chats, so the box's own list closes those tabs once it answers, for chats the box closed for any reason.
- Panes that read the box itself (terminal, files, file tree, changes, diff, review, mobile) show "Waking up workspace" until it first answers, and keep their scrollback after.
- A moved chat keeps its mode and model on its new host; closed chats are no longer moved.
- A workspace move is one toast with progress and an Open action when done that stays 12 seconds; a chat that stayed behind is named there, and the move banner shows only on the workspace that moved.
Summary by CodeRabbit
- New Features
- Moving a workspace now shows clearer progress, identifies chats that remain behind, and provides an option to open the destination workspace.
- Cloud workspaces display a startup status while reconnecting, and relevant workspace content appears as the host wakes.
- Stored chats can reappear as tabs when live session data is unavailable; tabs are reconciled once live data returns.
- Chat selections are preserved when continuing a moved chat.
- Bug Fixes
- Chat and workspace move statuses are clearer and available in supported languages.
- Cloud chat history and snapshots load without relying on a feature flag.