feat: open the waiting pane for cloud agent launches the desktop did not create
Stacked on #9937.
Summary
- host-service: new query
sandbox.pendingLaunch({ workspaceId }). It returns the box's launch as aCloudAgentLaunchDescriptorwhile the launch has a promised terminal id and the launch marker is absent. It returns null otherwise, on non-sandbox hosts, and for any other workspace id. - trpc:
startCloudWorkspacegives every launch a terminal id (queuedLaunch: the caller'sterminalId, or a new UUID). The queued launch andinitialLaunchalways carry it. Before this, the CLI and automation dispatch sent none, so the box picked its own andsandbox.pendingLaunchhad nothing to report for exactly those creators. - desktop: one pure rule,
withPendingCloudLaunch(layout, launch). It adds the waiting pane as a new tab unless a pane already claims the launch's terminal id. Both the create path's collections writer (seedPendingCloudLaunch) and a new workspace-route hook (useHostPendingCloudLaunch) use it.
Why
A cloud workspace created outside this desktop (CLI ws create --cloud --agent, automation cloudDispatch) opened on the empty workspace view while its box booted. Only the creator gets initialLaunch back from cloudWorkspace.create. The box already knows its own launch (from its env) and knows when it claims it (launchSandboxAgentOnce writes the marker before launching and removes it if the launch fails). So the box is the source of truth. There is no DB column, schema change or migration. There is one API change: startCloudWorkspace (start.ts) now assigns the terminal id that every launch carries.
Agent tasks (agent/tasks.ts) are out of scope: they start the workspace with no launch, so there is no agent launch to show a waiting pane for.
How it works
readPendingSandboxLaunch(workspaceId, env)insandbox-self-seedreads the identity from env and reusesdescribeCloudAgentLaunchfrom@superset/shared/cloud-agent-launch.useHostPendingCloudLaunchruns only for asandboxhost target, once the layout is ready. It refetches when the host reconnects, so a box that is still booting is asked again. It skips a launch whose terminal the user dismissed (isChatTerminalIgnored; closing the waiting pane already callsignoreChatTerminal), so a closed pane does not come back, including one the create path opened. There is no separate "seeded" set. An open or attached pane still claims the terminal id, a closed or dropped one is in the ignore record, and a launch that already started is null on the host. One case reopens the pane: a chat pane released on timeout while the box has still not launched. That launch really is still pending.- The query also returns the launch prompt (
PendingCloudAgentLaunch= the shared descriptor plusprompt). The pane opened from the box shows it aslaunchPrompt, the same as the creator's pane. fetchPendingCloudLaunchmaps a missing procedure (isMissingProcedureError) to null, so an older host keeps today's behaviour. Other errors stay errors, so the query retries.- Behaviour change on the create path: a layout that already had tabs used to be skipped. Now it gets the waiting pane as a new tab unless a pane claims the terminal id. A freshly created workspace has no layout, so this path is unchanged in practice.
- No empty-view flash:
canShowEmptyLayouttreats the layout as known to be empty only once it is ready and, on a sandbox host, the firstsandbox.pendingLaunchfetch has settled.useHostPendingCloudLaunchreturns it from its own query, so there is no second fetch. Until then the pane area renders a blank element instead ofWorkspaceEmptyState. Non-sandbox hosts never wait. An old host settles at once (null), and an unreachable box settles after the query's retries. Seeding runs in a layout effect, so the frame that has the answer is not painted without the pane. This also means a local workspace no longer shows the empty state before its layout's live query is ready. useCreateCloudWorkspaceno longer mintsagentTerminalId; the server owns the id and returns it ininitialLaunch.- Enforcement: a source-scan test keeps
sandbox.pendingLaunchbehindfetchPendingCloudLaunch, and keeps construction of thePENDING_CLOUD_LAUNCH_PANE_KINDpane inside thependingCloudLaunchstore.
tRPC compatibility
- The procedure is new and additive. No existing input, output or error code changed.
cloudWorkspace.create: theagentTerminalIdinput stays optional and is still honoured, because released desktops send it.initialLaunch.terminalIdis now always set for an agent launch. It was nullable before and stays nullable in the type.- Rollout: this desktop no longer sends
agentTerminalId, so it needs the API from this PR (rule 9). The API deploys on merge, long before a desktop release ships it. A desktop on an API without this change would get no waiting pane on create, but nothing would break. - New desktop with an old host: the "No procedure found" error reads as no pending launch, which is today's behaviour.
MIN_HOST_SERVICE_VERSIONis not raised because the client handles this case.
Testing
bun testonreadPendingSandboxLaunch.test.ts(host-service): returns the descriptor before the marker exists and null after; keeps the chat surface; null outside sandbox mode; null for another workspace, an idle box, or a launch with no terminal id.bun testonqueued-launch.test.ts(trpc): a launch with no terminal id gets a UUID in both the queued launch andinitialLaunch; a caller's id and the chat surface are kept. Fails without the change.bun testonpendingCloudLaunch.test.tsandfetchPendingCloudLaunch.test.ts(desktop): seeds once, never over a pane that claims the terminal id, never for a null or absent launch, null for a host without the procedure, other errors rethrown, plus the source-scan test.- Proved the new tests fail without the change. Removing the marker and run-mode checks fails 2 host tests. Removing the claim check and the missing-procedure mapping fails 4 desktop tests. A probe file that calls
sandbox.pendingLaunchfails the scan test. bun testonseedHostPendingLaunch.test.ts(desktop): the box's launch opens one waiting pane that shows its prompt, and a pane the user closed does not come back. Each test fails without its change. The host test also checks the returned prompt and fails without it. The "only the store builds the waiting pane" scan test now lives inpendingCloudLaunch.test.ts.bun testoncanShowEmptyLayout.test.ts(desktop): a sandbox host waits while its first answer is pending and stops waiting on success or error; a non-sandbox host never waits; a layout that is not ready is not known to be empty. Fails without the pending check.bun test src/router/cloud-workspace(trpc) also has 7 failures, all undicimarkAsUncloneableload errors in suites this PR does not touch. They are identical with the originalstart.ts.- Passed:
bun run typecheck(packages/trpc),bunx tsc --noEmit(apps/desktop),bunx tsc --noEmit(packages/host-service, packages/shared), biome on the changed files. No new strings, socheck:i18nis not needed.
Not verified here
I did not run this end to end. That is planned against a fake cloud box: create a cloud workspace with an agent from the CLI (an automation works too), open it in the desktop while the box boots, and check that "Starting " shows and turns into the agent's terminal or chat in place. Reopening after the launch should show no waiting pane.
Summary by CodeRabbit
- New Features
- Cloud sandbox launches can appear as waiting panes with their prompt while the workspace loads.
- Existing panes are preserved when a waiting pane is added, and duplicate waiting panes are avoided.
- Queued launches receive a terminal identifier when one is not provided.
- Bug Fixes
- The workspace empty state stays hidden while a sandbox launch is pending and appears after the launch check completes or fails.