feat(mobile,trpc): create cloud workspaces from the phone

Merged
SA
3mo ago
+516-73

Links

  • Decision log: apps/mobile/plans/20260817-cloud-workspaces.md (PR B section)
  • Predecessor: #6596 (list/open/terminal/actions)

Summary

  • Create a cloud workspace from the mobile composer: the project sheet gains a Cloud section (API-listed projects, available with zero machines online), branches come from the GitHub remote via the App installation, and submit is one call — cloudWorkspace.create returns the provisioning row, the cloud list is seeded, and the app navigates straight into the provisioning screen.
  • Two interim API procedures, fenced until the environments entity: cloudWorkspace.listProjects (the v2_projects rows that still resolve to a repo) and cloudWorkspace.listBranches (App-token branch listing that degrades to the default branch when the installation can't be authenticated, instead of breaking the picker).

How It Works

  • NewChatTarget gains kind: "host" | "cloud"; cloud targets come from useCloudProjects under the same flag + FORBIDDEN gating as the cloud list, keyed by the CLOUD_TARGET_ID sentinel (desktop's CLOUD_HOST_ID).
  • The project sheet is sectioned: Cloud first (it is never offline), then each online machine. The composer chip reads "Project · Cloud"; the agent chip is hidden for cloud targets (create launches nothing — the prompt feeds the server-side auto-name; the sandbox-side launch is a follow-up).
  • The branch chip and branch sheet read listBranches for cloud targets; host targets are unchanged.
  • Submit routes cloud targets to useCreateCloudWorkspace: one mutation, seed cloudWorkspace.list, router.push — same shape as desktop's #6566. Attachments are refused with a clear error (host-bound today; blob-backed attachments are the follow-up).

Manual QA (on the iPhone 16e simulator against the local API and real Blaxel sandboxes)

  • Composer defaults to "Superset · Cloud" with branch main when no machine is online; agent chip hidden
  • Project sheet: CLOUD section header + API projects; picking one updates the chip
  • Send → row created (provisioning), server auto-named it from the prompt ("Mobile Flow Test"), immediate navigation to the provisioning screen → flipped to ready → workspace opened
  • In the phone-created sandbox (fresh superset-hostsvc image): Start a session → Claude boots with "bypass permissions on", no root refusal; composer prompt answered (mobile-e2e-ok)
  • Test workspace deleted after; branch listing verified to degrade (local App/installation mismatch) rather than 500

Testing

  • bunx tsc --noEmit (mobile, trpc)
  • bun run lint

Known Limitations

  • listProjects reads retired v2_projects (fenced; replaced by the environments entity). Projects created since the sync era won't appear until then.
  • Cloud attachments unsupported (SUPER-1915 / blob follow-up).
  • The project sheet's checkmark falls back to the alphabetical first target when preferences haven't hydrated — pre-existing sheet behavior, chip is authoritative.

Also in this PR

  • Sandbox image superset-hostsvc was rebuilt from main and deployed (operational, no code): new sandboxes now run the merged host-service, which is what activated the Claude-as-root fix verified above.

Summary by cubic

Create cloud workspaces from the mobile composer. Previously mobile could only create on an online host; now users can choose a cloud project, pick a branch from GitHub, and submit one call that creates the provisioning row and navigates to the workspace. Agent picker is hidden for cloud targets; attachments are rejected.

  • New cloud target in the composer: project sheet is sectioned (Cloud first, then each online machine). The project chip shows “Project · Cloud”.

  • Branch picker uses cloudWorkspace.listBranches for cloud targets. It lists from the GitHub App installation and falls back to the default branch if the installation can’t be authenticated. Host targets are unchanged.

  • Create uses useCreateCloudWorkspace: calls cloudWorkspace.create, seeds the cloud list cache to avoid a provisioning/not-found flash, and routes to the workspace.

  • Feature flag FEATURE_FLAGS.CLOUD_WORKSPACES gates cloud data. A FORBIDDEN response is treated as “no projects,” not an error. Cloud projects load via useCloudProjects.

  • TRPC: adds cloudWorkspace.listProjects (interim, v2_projects with a repo) and cloudWorkspace.listBranches; server implements listRemoteBranches.

  • Review and rollout

    • No migrations. Cloud attachments are not supported yet; the create path blocks them with a clear error.
    • Known interim: listProjects only returns v2_projects that still resolve to a repo; newer projects arrive with the environments entity.

Summary by CodeRabbit

  • New Features
    • Added Cloud workspace targets to New Chat.
    • Browse Cloud projects and Git branches, with Cloud projects grouped separately from host projects.
    • Create a Cloud workspace directly from New Chat and continue in the new workspace.
    • Added branch search with default branches prioritized.
    • Added clearer empty states and Cloud-specific progress and error handling.
  • Bug Fixes
    • Improved handling when Cloud access or project data is unavailable.
  • Documentation
    • Documented Cloud workspace verification results.