New Tab Auto: the folder's run location, moved only by an explicit request (2/2 of the #26151 fold)

TE
6d ago
+692-30

HOLD: stacked on #26940, which is stacked on #26920 (held behind its Swift stack); this lands after both.

New Tab: a new chat starts in Auto. Auto sends the prompt to the folder's run location, and only an explicit request moves it. This is part 2 of 2 of folding #26151 ("ai-env: let new chats choose the environment automatically") into the run-location default of #26920, as one picker. It supersedes #26151.

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"

From #26151: "why doesn't ai just choose what environment i want", "AI just choose the environment", "Environment choose cloud that would be nice"

Gallery: agent-pane.composer-auto-scope

What changes

  • autoEnvironment.ts (from #26151, reworked) decides where a prompt goes under Auto:
    • The folder's run location (#26920's folder-history default: Cloud when the folder's newest chat went to Cloud, else this Mac) holds for every ordinary prompt. This replaces #26151's "project" fallback, the project's owning remote machine.
    • Only an explicit execution request moves it, as #26151 already required (the prompt starts with run, build, test, deploy, execute, start, continue, work or use, and isn't negated):
      • a ready machine's full name goes to that machine (also "on my gpu-box", or "on gpu-box." at the end of a sentence);
      • an ask for cloud or remote work goes to the Cloud row (#26801: the app picks a machine and copies the folder); when the Cloud row isn't offered, it goes to a ready Cloud machine, else an SSH machine, as before;
      • an ask to run locally goes to this Mac ("locally", "on this Mac").
    • Checked in that order. An incidental "local" ("the local dataset") or "here" is no destination.
  • NewTabScreen.tsx:
    • Auto is selected on a new chat's page and routes the send:
      • Cloud goes through App's Cloud start (onCloud);
      • a machine goes through onAsk with its peer;
      • this Mac goes through onAsk, even while the folder's default is Cloud.
    • A Run as row (Cloud, Sandboxed, New Cloud Machine), a machine or a saved environment ends Auto.
    • A folder pick keeps Auto, since the folder is what Auto reads.
    • A Sandboxed mode carried into the tab is a pick, so Auto is off there.
    • A Cloud refusal (attachments, Cloud not offered now) is shown for the send it refused, also when Auto chose Cloud while Run as reads Persistent.
  • Auto's fallback is the run location of the folder the chip names, read on the page with folderRunLocation, so a folder picked on the page counts at once. App's Run as mode is read under Auto only to see a Sandboxed pick, because App treats the mode a tab comes with as a default too.
  • A machine or saved environment picked here ends Auto and makes Run as a Persistent pick in App, so no Cloud default (now or later) takes the prompt elsewhere.
  • While a Cloud start from the page is out (App cloudStarting), no send goes anywhere, so an edited prompt never also starts somewhere else.
  • App.tsx:
    • onDefault puts Run as back to the folder's default; the picker's Auto row calls it;
    • cloudOffered (Cloud is offered now) and cloudStarting reach the page whatever Run as shows.
  • Kept: the explicit machine, saved-environment, Cloud and Sandboxed choices. No existing choice is removed or switched off. With preview features off, nothing routes automatically.
  • Dropped from #26151: following a project's owning remote machine, because the folder default replaces it. Its two tests for that are gone too.

Before / after

Gallery renders (dark, 620 px, Chromium) from a cmux-ci Linux run at this head's tree. The gallery advisory runs once this PR's base retargets onto feat-cmux-next.

Before: the picker, no AutoAfter: Auto selected, folder default Cloud
beforeafter

Auto as a prompt moves it or the folder keeps it: a folder that runs here, "run the tests on gpu-box".

Tests

  • test/auto-environment.test.ts:
    • #26151's cases on the new result shape;
    • ordinary and negated prompts keep the folder's run location, both this Mac and Cloud;
    • cloud and remote asks map to the Cloud row when it is offered, else to a ready Cloud machine;
    • a named machine or "run locally" moves a Cloud default;
    • a Cloud default with no Cloud row stays on this Mac.
  • test/new-tab-saved-environments.test.tsx:
    • #26151's page tests;
    • with the folder's Cloud default, an ordinary prompt (even "Fix the bug here") starts Cloud, while "Run the tests on devbox" and "Run the tests locally" do not;
    • "Run the tests in the cloud" starts Cloud, not the listed cloud-1;
    • a folder pick keeps Auto, and Auto picked again calls onDefault;
    • a Cloud pick ends Auto;
    • a carried-over Sandboxed mode turns Auto off;
    • a Cloud refusal under Auto is shown;
    • This Mac picked under Auto is a pick;
    • no send while a Cloud start is out;
    • Auto follows a folder picked on the page;
    • with Cloud not offered, a cloud ask goes to a listed Cloud machine.
  • NewTabScreen.test.tsx: the base test "with Cloud picked…" now picks Cloud on the page, since under Auto the Cloud mode a tab comes with is a default, not a pick.
  • cmux-ci (Linux pool) at this head's tree:
    • these tests pass, along with runLocationDefault.test.ts, cloudRun.test.ts, EnvironmentPicker.test.tsx and gallery-agent-pane-entries.test.ts;
    • bun run check is green, apart from #26940's format fix, which is now in.
  • The two gallery-coverage.test.ts tests fail with the same names on lane/run-location-default at fdb7d09, and this stack adds no line to either list.

Risk: medium, behind preview features. It changes where a New Tab prompt goes, and only in three cases:

  • the folder's newest chat went to Cloud (the Cloud default #26920 already sets);
  • the prompt explicitly asks for a machine, cloud or local;
  • otherwise it goes where it went before.

Agent session: agent session

🤖 Generated with Claude Code