sessions: add explicit worktree option to create_session - #335076
Open
Sandeep Somavarapu (sandy081) wants to merge 8 commits into
Open
sessions: add explicit worktree option to create_session#335076Sandeep Somavarapu (sandy081) wants to merge 8 commits into
Sandeep Somavarapu (sandy081) wants to merge 8 commits into
Conversation
Honor user-requested worktree overrides while preserving isolation inheritance when omitted. Reject overrides for current-session chats and resolve known worktree folders to their project root when worktree is false. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
September 8, 2026 14:49
Copilot started reviewing on behalf of
Sandeep Somavarapu (sandy081)
September 8, 2026 14:49
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Workspace resolution can incorrectly rewrite ordinary nested or additional roots to the primary project.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/vs/platform/agentHost/node/shared/sessionServerTools.ts — preferProject currently rewrites every matching working directory to the session's project URI,… |
What changed in this PR
Adds an explicit worktree override to create_session, including validation, workspace resolution, tests, and documentation.
Changes:
- Adds and validates the optional
worktreeargument. - Updates workspace and isolation resolution.
- Expands regression coverage and documentation.
| File | Review |
|---|---|
src/vs/platform/agentHost/node/shared/sessionServerTools.ts |
Requires correction: preferProject can incorrectly replace nested or additional workspace roots. |
src/vs/platform/agentHost/test/node/sessionServerTools.test.ts |
Adds coverage for validation, inheritance, overrides, and URI resolution. |
src/vs/platform/agentHost/AGENTS.md |
Documents isolation behavior; should clarify that inheritance applies within the same project. |
Suppressed comments (2)
src/vs/platform/agentHost/AGENTS.md:266
- This sentence says every independent session inherits isolation, while the implementation and tool schema restrict inheritance to the same project. State that condition here so the architecture contract does not misdescribe different-project sessions.
An independent session inherits the creating session's host-owned isolation
selection independently of provider-owned configuration;
otherwise it uses worktree isolation. The optional `worktree` argument overrides
src/vs/platform/agentHost/node/shared/sessionServerTools.ts:836
- When
worktreeis omitted, this only recognizes the same project ifargs.workspaceequals the project root. Existing linked-worktree sessions are represented withprojectset to the primary root andworkingDirectoriesset to the checkout (for example,agentService.test.ts:6085-6099), so passing that known working directory falls through to the defaultworktreeisolation instead of inheriting the source'sfolderisolation. Resolve the known project identity for this comparison without rewriting the requested working directory, and add the corresponding folder-isolation regression case.
} else if (defaults?.project !== undefined && isEqual(defaults.project, args.workspace)) {
isolation = defaults.isolation;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
Base:
|
Benjamin Christopher Simmonds (benibenj)
previously approved these changes
Sep 8, 2026
Resolve only exact linked-worktree roots reported by Git to the primary checkout. Preserve nested and additional workspace folders instead of inferring worktree identity from session project metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Christof Marti (chrmarti)
previously approved these changes
Sep 8, 2026
…ption-to-create-session-tool-and
Use drive-qualified paths for Windows filesystem test inputs and regenerate Copilot prompt baselines for the explicit worktree tool option. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Martin Aeschlimann (aeschli)
previously approved these changes
Sep 8, 2026
…ption-to-create-session-tool-and Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ption-to-create-session-tool-and
…ption-to-create-session-tool-and
Martin Aeschlimann (aeschli)
approved these changes
Sep 9, 2026
|
Closes #334727 |
Sandeep Somavarapu (sandy081)
enabled auto-merge
September 9, 2026 09:29
Sandeep Somavarapu (sandy081)
disabled auto-merge
September 9, 2026 09:29
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
September 9, 2026 09:29
auto-merge was automatically disabled
September 9, 2026 09:41
Pull request was closed
…ption-to-create-session-tool-and Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
worktreeoverride tocreate_session, with guidance to supply true or false only when explicitly requested by the user.relationship: currentSession.worktree: false, resolve a known worktree folder to its project root instead of sharing the existing worktree.Validation
npm run compilepassed.