Composer Cloud: a new chat's run location defaults from its folder's history

TE
6d ago
+238-2

HOLD: stacked on #26801, which is stacked on Swift #26791; both are held. This lands after them.

Composer Cloud: where a new chat runs now defaults from its folder's history. If the folder's newest chat ran on a Cloud machine, a new chat there starts with Cloud picked. Otherwise it starts on this Mac. Once the person picks, their pick holds.

Leo, 2026-10-28: "whatever's convenient for cloud, like that can be productionized, operationalized, we ought to just put out there"

Leo, 2026-10-28: "you can just say ... where should this chat run and stuff, and that's just about it. Like, you can determine whether it's in the cloud or otherwise"

Gallery: agent-pane.composer-context

What changes

  • runLocationDefault.ts (new):
    • folderRunLocation(folder, sessions, peerKinds) finds the folder's newest listed chat (by creation, else activity, else last write) in acpmux's session list and returns where it ran:
      • this Mac, when it ran in the same folder;
      • Cloud, when it ran in the folder's copy on a Cloud machine.
    • It skips side chats, archived chats and SSH machines.
    • The copy's path is the one cloud.startChat makes (Swift CloudMoveFolder): the checkout root's name plus 6 hex digits of its FNV-1a hash, under /home/cmux/work or /root/work, then the subpath. The page can't see .git, so the folder and every folder above it count as possible roots.
    • The history comes from acpmux's list, so it holds across launches and devices.
  • App.tsx: while Cloud is offered (Labs on, a fresh chat), a new chat's run mode follows that default until the person picks one in the picker.
    • A Cloud mode set by default goes back to this Mac when the history stops saying Cloud or Cloud stops being offered.
    • A Cloud mode carried over from the chat before is treated as a default.
    • Sandboxed, and a Cloud mode the person picked, never change.
    • Nothing changes while a Cloud start is out.

Before / after

The picker's look is unchanged. Only which row starts selected changes:

  • before, a new chat always started on this Mac;
  • after, a new chat in a folder whose last chat went to Cloud starts with the Cloud row selected (the gallery's environment-picker-cloud-picked state).

The gallery advisory captures Gallery: states only on PRs into feat-cmux-next, so they come once this PR's base retargets after #26801 lands.

Tests

  • runLocationDefault.test.ts:
    • remote folder names, with fixtures computed independently from the Swift hash (one non-ASCII);
    • path normalising;
    • the folder or any folder above it as the copied root, under each work root;
    • a folder with no history;
    • newest-wins;
    • another folder's copy, SSH machines, side chats and archived chats do not count;
    • a peer acpmux names a Cloud peer.
  • cmux-ci (Linux pool): those tests and cloudRun.test.ts pass, and bun run check is green.

Risk: low, behind Labs. The only default it sets is Cloud for folders whose last chat already ran in Cloud, and it never overrides a pick.

Agent session: agent session

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

In Composer Cloud, a new chat's run location now defaults from its folder's history: if the folder's newest chat ran on a Cloud machine, the new chat starts with Cloud picked; otherwise it starts on this Mac. Previously, every new chat started on this Mac.

The default comes from acpmux's existing chat list, so it holds across launches without storing anything new. A Cloud chat is matched to its folder by the copy path the app creates on the machine.

Key behaviors

  • The default applies only while Cloud is offered; a person's explicit pick always holds and never gets overridden.
  • A chat keeps the mode it starts with until its session appears, and sandboxed mode and Cloud starts in flight are never touched by the default; once a Cloud start ends, the default looks at the folder's history again.
  • Cloud mode carried over from the previous chat counts as a default, so the folder's history can undo it.