Skip to content

sessions: offer New Worktree for All Folders for a new multi-folder session - #350809

Draft
Sandeep Somavarapu (sandy081) wants to merge 12 commits into
mainfrom
sandy081/agents/workspaces-10b-worktree-all-folders
Draft

Sandeep Somavarapu (sandy081) wants to merge 12 commits into
mainfrom
sandy081/agents/workspaces-10b-worktree-all-folders

Conversation

@sandy081

@sandy081 Sandeep Somavarapu (sandy081) commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

What: When a new session's folders are in two or more Git repositories and workspaces are enabled (sessions.workspaces.enabled, Insiders only), the isolation picker offers New Worktree for All Folders. It creates a worktree for every Git folder of the session (the host's worktreeFolders: 'all', from #350551), instead of only for the main folder.

Changes:

  • agentHostSessionConfigPicker.ts: a third isolation choice, on desktop and in the phone sheet. Selecting it sets the isolation to worktree and worktreeFolders to all in one tracked, sequenced operation of the draft; Branch and New Worktree set it back to primary.
  • The offer counts the Git repositories the agent host lists for the session's folders, by their roots (folders in one repository count once; paths compare by the platform's URI identity), and appears once the host has listed them. A new session now also applies the host's Git state and repositories for its other folders, not only its first.
  • agentHostGitStateService.ts: the host lists a session's repositories also when two or more of its folders are in Git repositories (each its own root included) or a folder's repository root is above the folder, so clients know which folders share a repository. A session with one folder in its own repository is unchanged.
  • The separate Worktree Folders picker is hidden only where this choice replaces it (a writable two-way folder/worktree isolation with the offer available); other host schemas keep it.
  • A saved all choice is shown, never reset silently: when the folders no longer offer it, the picker keeps it labelled and checked, disabled with the note "Saved choice; not available here". The choice still applies on send.
  • A new session stops listing repositories the host no longer records, and repository roots compare through IUriIdentityService, so roots that differ only in case stay separate on a case-sensitive (remote) host.
  • Accessibility: the shared phone picker sheet focuses only rows that can be picked (falling back to Done), and a disabled action list row that stays focusable to explain why it's unavailable now shows the focus border (actionWidget.css; also applies to the mode picker's policy-disabled rows).
  • Dev Container execution that can't use a worktree disables both worktree choices, with the reason, also on phone; a choice the session no longer offers is never written.
  • Fixtures: NewWorktreeForAllFolders, KeptNewWorktreeForAllFolders (desktop), PhoneNewWorktreeForAllFoldersWithDevContainer and PhoneKeptNewWorktreeForAllFolders (phone).

Notes for reviewers:

  • Based on main; the branch carries only this PR's commits.
  • Screenshot baselines: the "Screenshots & Tests" check will need a baseline update. The new fixtures add baselines, and the existing isolationPicker/NewWorktree baseline changes. Its fixture chat had no resource, so the picker found no configuration and focused Branch; it now focuses the selected New Worktree row.

Validation:

  • pnpm run typecheck-client: passed
  • ./scripts/test.sh --runGlob "**/platform/agentHost/test/**/*.test.js": 19158 passing, 0 failing
  • ./scripts/test.sh --runGlob "**/sessions/contrib/**/test/**/*.test.js": 8003 passing, 0 failing
  • ./scripts/test.sh --runGlob "**/workbench/contrib/sessions/**/test/**/*.test.js": 3486 passing, 0 failing
  • ./scripts/test.sh --runGlob "**/platform/actionWidget/**/test/**/*.test.js": 323 passing, 0 failing
  • pnpm run oxlint <changed files>, node build/stylelint.ts actionWidget.css, pnpm run valid-layers-check, pnpm run check-mobile-boundary: passed
  • component-explorer render --fixture-id-regex '/Light$': all fixtures render without errors

Written by GitHub Copilot on behalf of Sandeep Somavarapu (@sandy081)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Agent Host drafts ignore multi-folder creation options and lack the capability needed to offer folder addition, while the folder comparison can also reject valid saved drafts.

3 open issues
What changed in this PR

Adds the client-side New Worktree for All Folders choice for new multi-repository sessions, building on the Agent Host support in #350551. The PR also includes workspace selection and multi-folder draft UI.

Changes:

  • Adds desktop and phone isolation choices with repository eligibility checks, sequenced configuration writes, and Dev Container restrictions.
  • Adds workspace selection, folder attachment pills, and saved-draft target handling while keeping Workspaces Insiders-only.
  • Expands unit tests and component fixtures for isolation choices, workspace selection, and draft restoration.
File Description
src/​vs/​workbench/​test/​browser/​componentFixtures/​chat/​chatFixtureUtils.ts Adds context-picker registration stubs.
src/​vs/​workbench/​contrib/​sessions/​test/​browser/​sessionWorkspacesService.test.ts Tests product-quality gating for Workspaces.
src/​vs/​workbench/​contrib/​sessions/​test/​browser/​chat/​sharedChatInputComposer.test.ts Updates input-event mocks.
src/​vs/​workbench/​contrib/​sessions/​providers/​agentsView/​test/​browser/​agentsViewServices.test.ts Includes the context-picker service dependency.
src/​vs/​workbench/​contrib/​sessions/​providers/​agentHost/​browser/​agentHostSessionConfigPicker.ts Adds the combined all-folder isolation choice and guards.
src/​vs/​workbench/​contrib/​sessions/​common/​sessionConfig.ts Centralizes Workspaces enablement.
src/​vs/​workbench/​contrib/​sessions/​common/​savedSessionDrafts.ts Stores and validates workspace and folder targets.
src/​vs/​workbench/​contrib/​sessions/​browser/​sessionWorkspacesService.ts Uses shared Workspaces enablement.
src/​vs/​workbench/​contrib/​sessions/​browser/​sessionWorkspacesContextKeys.ts Applies product-quality gating to the context key.
src/​vs/​workbench/​contrib/​sessions/​browser/​sessionsService.ts Identifies newly created drafts in results.
src/​vs/​workbench/​contrib/​sessions/​browser/​sessionsConfiguration.ts Excludes the Workspaces setting from Stable.
src/​vs/​workbench/​contrib/​sessions/​browser/​chat/​webWorkspacePicker.ts Forwards new workspace-picker dependencies.
src/​vs/​workbench/​contrib/​sessions/​browser/​chat/​sharedChatInputComposer.ts Exposes user attachment-removal events.
src/​vs/​workbench/​contrib/​sessions/​browser/​chat/​sessionWorkspacePicker.ts Adds workspace rows and session-folder selection state.
src/​vs/​workbench/​contrib/​sessions/​browser/​chat/​newChatWidget.ts Connects folder pills, creation options, and draft restoration.
src/​vs/​workbench/​contrib/​sessions/​browser/​agentsView/​editorWindowSessionsService.ts Marks successfully created editor-window drafts.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostSessionConfigPicker.fixture.ts Adds desktop and phone isolation fixtures.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHost/​agentHostSessionConfigPicker.test.ts Tests eligibility, configuration writes, and stale selections.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​sessionWorkspacePicker.test.ts Tests workspace selection and added-folder behavior.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​sessionWorkspacePicker.fixture.ts Adds workspace rows, chips, and keyboard-focus fixtures.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newChatWidget.test.ts Tests creation options, folder pills, and restoration.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newChatWidget.fixture.ts Adds folder-pill and focus fixtures.
src/​vs/​sessions/​contrib/​automations/​test/​browser/​automationDialog.fixture.ts Stubs the new workspace-service dependency.

Review effort: Balanced

Comment on lines +2689 to +2690
...(workspaceConfig ? { workspaceConfig } : undefined),
...(folders ? { folders } : undefined),
* them ({@link ISessionCapabilities.supportsChatFolders}). A provider that cannot drops the folders it is created with.
*/
private _supportsSessionFolders(reader: IReader): boolean {
return this._session.read(reader)?.capabilities.read(reader).supportsChatFolders === true;
const isSavedWorkspace = !!sessionWorkspace && !sessionWorkspace.missing && !!target.sessionWorkspaceUri
&& [sessionWorkspace.uri, ...sessionWorkspace.previousUris ?? []].some(uri => extUri.isEqual(uri, target.sessionWorkspaceUri));
if ((target.folderUri && target.sessionWorkspaceUri && !isSavedWorkspace)
|| (target.folderUri && target.sessionFolders?.length && !isSameFolderSet(folders ?? [], target.sessionFolders))) {
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: f1c92721 Current: cdf66957

Changed (2)

sessions/chat/isolationPicker/agentHostSessionConfigPicker/NewWorktree/Light
Before After
before after
chat/SessionPathConfirmation/chatSessionPathConfirmation/Narrow/Light
Before After
before after

Added (4)

sessions/chat/isolationPicker/agentHostSessionConfigPicker/NewWorktreeForAllFolders/Light

current

sessions/chat/isolationPicker/agentHostSessionConfigPicker/KeptNewWorktreeForAllFolders/Light

current

sessions/chat/isolationPicker/agentHostSessionConfigPicker/PhoneKeptNewWorktreeForAllFolders/Light

current

sessions/chat/isolationPicker/agentHostSessionConfigPicker/PhoneNewWorktreeForAllFoldersWithDevContainer/Light

current

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved repository metadata prevents the new option from appearing for normal multi-checkout drafts, and stale mobile selections can display unavailable choices as selected without saving them.

5 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Missing repository metadata for ordinary Git-backed folders and incorrect deduplication of case-sensitive remote roots prevent “New Worktree for All Folders” from appearing when it should.

5 open issues
2 resolved since last review

Review effort: Balanced

this._hasSeveralGitRepositories = derived(this, reader => {
// The roots of the folders' own repositories, as the host found them: folders in one repository share its root
const roots = new ResourceSet(uri => this._uriIdentityService.extUri.getComparisonKey(uri));
for (const repository of this._session.read(reader)?.workspace.read(reader)?.repositories ?? []) {
*/
applyFolderState(meta: SessionMeta | undefined, toHost: (uri: URI) => URI, toClient: (uri: URI) => URI, tx?: ITransaction): void {
const workspace = this._workspace.get();
const next = withSessionFolderState(workspace, meta, toHost, toClient);

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
applyFolderState(meta: SessionMeta | undefined, toHost: (uri: URI) => URI, toClient: (uri: URI) => URI, tx?: ITransaction): void {
const workspace = this._workspace.get();
const next = withSessionFolderState(workspace, meta, toHost, toClient);

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a new session's folders are in two or more Git repositories and
workspaces are enabled, the isolation picker offers "New Worktree for All
Folders". It selects worktree isolation and the host's 'all' worktree
folders together; Branch and New Worktree reset the folders to the main
folder. The separate Worktree Folders picker is no longer shown.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Offer it as folders are added and their Git repositories resolve, and
  count a repository once across case variants of its path where the
  platform ignores path case.
- Offer it in the phone repository sheet too.
- Set the isolation and the worktree folders in one tracked, sequenced
  operation of the draft, also when another session shows meanwhile.
- Keep the host's Worktree Folders picker for isolation schemas without
  the two-way folder and worktree choice.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e set

- Check Dev Container execution and the live offer whenever a worktree
  isolation is selected, on desktop and in the phone sheet, which now
  shows the unavailable choice disabled.
- Never write the choice to an isolation that no longer offers it.
- Keep the Worktree Folders picker unless the new session's writable
  isolation choice offers worktrees for all folders.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Dev Container

With Dev Container execution that cannot use a worktree, the phone
repository sheet shows Worktree disabled with its reason, like New
Worktree for All Folders, instead of a row that does nothing when tapped.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A new Agent Host session applies what the host reports about its other
folders, as a running session does: their own Git state, or that they
are not repositories. Before, only its first folder was updated, so
New Worktree for All Folders was never offered for a new session in
several Git repositories.

The phone repository sheet also closes when a worktree choice can no
longer be made, instead of showing it as selected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… the host finds

New Worktree for All Folders is offered when the host finds the folders
of a new session in at least two Git repositories, by their roots, so
folders in one repository, such as a repository and its subfolder,
count once. A new session publishes a change of the repositories the
host finds even when its folders' Git state stays the same.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A host update that changes the Git state of a new session's first folder
and of its other folders updates its workspace once, in one transaction,
instead of twice.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The agent host lists a session's repositories also when a folder's own
repository root is above the folder, so folders that share one
repository have its root. When each folder is its own repository, it
still lists none, and the isolation picker then takes each folder in a
Git repository as its root. So two separate checkouts offer New
Worktree for All Folders, and two folders of one repository do not.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… the repositories

The agent host lists the repositories of a session with several folders
in Git repositories, also when each is its own, so that clients know
which folders share one. The isolation picker offers New Worktree for
All Folders only once those repositories are listed, so it is never
offered, nor selected, while the host has read the folders' Git state
but not yet found which share a repository.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…choice

When a new session's folders no longer offer worktrees for all folders but the
session still stores that choice, the isolation picker keeps it labelled and
checked, disabled with a note, instead of showing New Worktree while the choice
still applies on send.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ories

- The phone picker sheet focuses only rows the user can pick, falling back to
  Done, so a checked but disabled row never leaves focus outside the sheet.
- The desktop isolation picker keeps a checked but disabled choice focusable,
  so its reason can be read; the note is neutral and short.
- The Worktree Folders picker stays unless the isolation picker offers
  worktrees for all folders.
- A new session stops listing the repositories the host no longer records, and
  repository roots compare as their file system compares paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A disabled action list row that is focusable to explain why it is unavailable
shows the focus border when focused; other disabled rows are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants