Repository navigation
agentHost: let any chat change its workspace or move to a new worktree - #345805
Merged
Sandeep Somavarapu (sandy081) merged 2 commits intoNov 3, 2026
Merged
Sandeep Somavarapu (sandy081) merged 2 commits into
Sandeep Somavarapu (sandy081) merged 2 commits into
Conversation
A chat moved out into a session of its own is that session's default chat but keeps its own storage, so the Copilot agent, which decided the default chat by storage, refused to change its working directory and its session-level operations missed it. The host now answers whether a chat is its owner's default chat, and the agent uses that answer. In a session without a workspace, only its default chat (working in the session's folder) converts the whole session; a peer, or a default chat recording folders of its own, changes only its own workspace, including to a new worktree. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A mixed-session inheriting peer’s worktree move fails because the pending snapshot includes all session folders while preparation pins only the primary scratch folder, requiring consistent inherited-folder validation and a regression test.
1 open issue
What changed in this PR
This PR extends Agent Host workspace changes to promoted and nested chats, building on the existing chat-move and workspace-conversion support.
Changes:
- Uses host-recorded default-chat identity instead of inferring it from storage.
- Refines whole-session versus chat-only conversion and permits nested chats to move to another folder’s worktree.
- Adds regression coverage for promoted-chat routing and workspace-less session transitions.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/sessionWorkspaceConversion.test.ts |
Adds workspace-less chat and worktree conversion tests. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Tests host-defined default-chat identity and session-level routing. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Uses host-defined identity for workspace changes, lookup, and resume. |
src/vs/platform/agentHost/node/chatContributions/sessionWorkspaceConversion/sessionWorkspaceConversionService.ts |
Updates conversion routing, worktree eligibility, and workspace-less metadata. |
src/vs/platform/agentHost/node/agentChatContext.ts |
Exposes a live host-backed default-chat check. |
src/vs/platform/agentHost/common/agent.ts |
Adds the optional owner-reference check and compatibility helper. |
Review effort: Balanced
A chat without folders of its own in a workspace-less session next to a chat with its own folder recorded all session folders as its previous ones, while preparing its new folder pins it to only the folders it inherits, so the move failed as "The chat changed while preparing its new workspace". Read both through inheritedChatFolders. Co-authored-by: Copilot <[email protected]>
Contributor
Ladislau Szomoru (lszomoru)
approved these changes
Nov 3, 2026
Sandeep Somavarapu (sandy081)
deleted the
sandy081/agents/chat-move-to-worktree-issue
branch
November 3, 2026 12:56
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.

Lets any chat change its workspace or move to a new worktree with
set_workspace, including a chat moved out into a session of its own and a nested chat in a session without a workspace.No issue is filed for this. It was found while using the Agents window: after Move to New Session,
set_workspacefailed withCannot change the working directory for peer chat '…': live working-directory changes are only supported for the owning default chat.What changed and why
IAgentChatOwnerRef.isDefaultChat()is answered by the host from its record of the session's default chat.isAgentChatDefaultChatuses that answer and falls back to the old storage check when the host has none._setWorkingDirectory, resume reanchoring and_findSessionChat. Checks that are really about where data is stored are unchanged.Regression history: likely regressions, not bisected. The storage-equals-default assumption dates from #329633 and #334250, and #341788 (moving a chat into its own session) broke it. The routing and the worktree guard weren't updated when #343022 allowed changing a single chat's workspace in sessions without one.
No protocol change, and the provider-facing addition is optional.
How to test
chat.agentHost.moveChats.enabledtotrueand open the Agents window.set_workspace.pwdshows the new worktree, and the quick chat itself stays in its scratch folder.set_workspace.pwdshows the folder, also on the next turn.Validation
copilotAgent.test.tsandsessionWorkspaceConversion.test.ts. 6 of them were run against the unfixed product code and failed; all 7 pass with the fix.main:node test/unit/node/index.js --runGlob 'vs/platform/agentHost/test/{node,common}/**/*.test.js': passed (16155 passing, 0 failing)./scripts/test.sh --runGlob 'vs/platform/agentHost/test/{browser,electron-browser}/**/*.test.js': passed (785 passing)pnpm run typecheck-client: passednode build/hygiene.ts <changed files>: passedpnpm run eslint <changed files>: passed