cmux-next: Ctrl-` after a New Tab folder pick starts in the picked project

Merged
AU
11d ago
+125-3

Summary

Ctrl-` (and every other terminal opened from an agent chat) now starts in the project the person picked on the New Tab page's folder chip, even before the first send. Fixes https://github.com/manaflow-ai/cmux/issues/22225.

https://github.com/manaflow-ai/cmux/pull/23795 already landed the general fix on feat-cmux-next: a synchronous native resolver (AgentPaneModel.terminalFolder, NewTerminalStart.folder) gives every new-terminal path from a chat the chat's folder, including Ctrl- in the chat's own pane, the docked strip, a split and a new workspace. This PR's original approach (asking the page asynchronously on Ctrl-) is superseded, so it is dropped: the branch now takes the base tree and adds only the gap #23795 left.

The remaining gap

Before the first send there is no session folder yet, so terminalFolder falls back to the folder the page opened with. A project picked on the chip (workspace.useFolder) was never recorded natively (AgentPaneStartFolders.use returns the answer but stores nothing), so Ctrl-` after the pick still started in the old folder.

Fix

  • AgentPaneModel.pickedFolder: set from an ok workspace.useFolder reply, only when the chat may start there: the folder is a root of the pane, or the person's click granted it (addedRoots). A page script's pick of any other folder changes nothing.
  • terminalFolder precedence: the session's folder, then the pick, then Choose Folder…, then the store's start folder, then the handshake folder. Choose Folder… clears the pick so the latest choice wins. Agent-home still gives no folder.
  • An ok pick the pane may not use drops an earlier pick, and a pick that finishes after a later pick or choice changes nothing (per-pick sequence number).
  • Remote chats (useRemote) are untouched: their folders never reach this Mac's daemon.

Changelog

  • Fixed: A terminal opened from an agent chat before its first message starts in the project picked on the New Tab page.

Testing

Focused command: cmux-ci run --class light --script scripts/ci/package-test-lane.sh --arg suite --arg Packages/macOS/CmuxNext --arg AgentPaneTerminalFolderTests (Xcode 26.6).

  • Red at 7efec770d8ce (base plus the test): aTerminalBeforeTheFirstSendStartsInThePickedProject fails (the terminal folder stays the opened folder); the other 4 pass.
  • Green at the head: at a17b89d896fc (fleet step c63acecce64ef229b2a1ecc6, aws-m4pro-2) AgentPaneTerminalFolderTests 8/8 pass, plus AgentPanePickedFolderRootTests 3/3.
  • Dev build: cmux-ci job a08d53f2fa35ab553f6a3873, tag 22225-terminal-picked-project-folder, at a17b89d896fc.

Observed / Not run

  • Observed: the fleet runs above; scripts/cmux-next/prepush-gate.py reports no new violations at the head.
  • Not run: a tagged dev build and GUI dogfood in a tagged build (pick a project on the New Tab chip, press Ctrl-, check pwd`).

No capture: the change is the folder a new terminal's shell starts in; no pixels change.

Review: SHIP at a17b89d896fc (review subagent, correctness first; findings and resolution in the PR comments).

🤖 Generated with Claude Code