cmux NEXT: a new chat can see more folders than its project (Add folder…)

TE
3d ago
+969-36

Leo: "but like also being able to have chatgpt (and in this case, any harnesses) see whatever folders/files would be cool" and "and you can also just start with nothing".

This is the web side, part 1: new chats only. acpmux already takes additionalDirectories in session/new (#32811); this lets the composer use it.

What changes

  • Composer folder menu: Add folder… (FolderPopover / ComposerContext). Before the first send, a new chat keeps a list of extra folders. Choosing Add folder… switches the menu into picking one more folder. The search field reads "Add a folder", and the project and folders already added are not offered again. On this Mac, Choose folder… opens the native panel.
    • The menu lists the added folders under "Also sees", each with × to remove it.
    • The chip reads atlas-web +2, or No project +2.
    • The project stays the chat's cwd. With no project, the chat starts in its private folder with the added folders beside it, so nothing is required to start.
  • Other machines (SSH peer, Remote Control machine, Cloud): the folders belong to the machine the chat runs on. They come from that machine's own folder list (machineFolders) or a typed absolute path, never this Mac's panel. Picking a different machine clears the list.
  • session/new: direct.ts setNewChatFolders holds the list. startSession sends it as additionalDirectories, leaving out the chat's own folder. The list is dropped once the chat starts, and a failed start keeps it for the retry. This covers the chat pane's composer and the New Tab page.
  • Session Info → Sources lists a running chat's folders first, by name with the path on hover, read from the session summary's additionalDirectories. This is in both the web panel and the native one, and is read-only for now.
  • Swift pane relay (a thin pass-through):
    • The params rule now allows additionalDirectories on session/new. It was refusing the whole frame (AcpmuxPaneMethods+Params.swift, with policy.json kept in sync).
    • AcpmuxPathPolicy already checked the key as a path field, the same way it checks cwd.
    • For a chat on another machine, the folders are only shape-checked, the same way that machine's cwd is.
  • The logic lives in a small pure module, webviews/src/agent-session/acpmux/extraFolders.ts, with tests.

Design specs: design/composer.md (the folder chip's menu: actions pinned under search, one name column) and design/environment-picker.md (where a chat runs decides whose folders it can name). Nothing settled is replaced. Add folder… is a new action row, and the chip's name gains a +N count.

Out of scope, waiting on #32949 (_acpmux/set_directories): adding or removing folders on a running chat, and an editable Sources list in Session Info.

Gallery

  • agent-pane.composer-context / extra-folders-no-project: no project, two folders
  • agent-pane.composer-context / extra-folders-project: project plus three folders
  • agent-pane.composer-context / extra-folders-adding: Add folder… mode
  • agent-pane.composer-context / extra-folders-peer: an SSH machine's folders
  • agent-pane.session-info / sources-folders: Session Info Sources with two folders

Tests

  • webviews/src/agent-session/acpmux/extraFolders.test.ts: add, remove, the 64 cap, the cwd excluded, the summary read.
  • webviews/test/new-chat-extra-folders.test.ts: session/new carries them on this Mac, with no project and on a peer. The next new chat starts with none, and a failed start keeps them.
  • webviews/test/composer-extra-folders.test.tsx: Add folder… then a pick, × to remove, Choose folder…, no project, another machine's draft hidden, and no Add folder… on a started chat.
  • Packages/macOS/CmuxNext/Tests/CmuxNextAgentPaneTests/AgentPaneExtraFoldersRelayTests.swift: the params rule takes the field; this Mac's folders are canonicalized and limited to the pane's roots; a peer's folders go through as named.

The tests are committed red first (181ed488e0c), then the fix.

Observed / Not run

  • Ran locally, all pass on the head: bun test src/agent-session/acpmux/extraFolders.test.ts test/new-chat-extra-folders.test.ts test/composer-extra-folders.test.tsx (9 + 4 + 5), scripts/web-lint.sh (format and design tokens; type check left to CI on this host) and prepush-gate.py.
  • The Swift suite and compile go to the fleet (results in the comments below).

Changelog

  • Added: a new chat can see more folders than its project. Use Add folder… in the folder menu, even with no project. Session Info's Sources lists them.

Agent session: agent session

🤖 Generated with Claude Code