Fix agent host worktree terminal cwd#310893
Merged
roblourens merged 2 commits intomainfrom Apr 17, 2026
Merged
Conversation
(Written by Copilot)
Contributor
Screenshot ChangesBase: Changed (8) |
Contributor
There was a problem hiding this comment.
Pull request overview
Ensures Agent Host Copilot shell terminals created for worktree-isolated sessions start in the resolved worktree directory (instead of the agent host process cwd), and adds regression coverage around cwd fallback behavior.
Changes:
- Pass the resolved session working directory into
ShellManageron both create and resume paths. - Use the session working directory as the default terminal cwd for shell tool terminals when no explicit cwd override is provided.
- Add unit + real SDK integration coverage asserting terminal cwd/output matches the resolved worktree path.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Creates ShellManager with the resolved session working directory on create/resume paths. |
| src/vs/platform/agentHost/node/copilot/copilotShellTools.ts | Uses workingDirectory.fsPath as the fallback cwd when creating shell terminals. |
| src/vs/platform/agentHost/test/node/copilotShellTools.test.ts | Adds unit coverage for cwd fallback vs explicit override (needs cross-platform fix). |
| src/vs/platform/agentHost/test/node/protocol/toolApprovalRealSdk.integrationTest.ts | Extends real SDK worktree test to validate terminal cwd and pwd output match resolved worktree. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
(Written by Copilot)
pwang347
approved these changes
Apr 17, 2026
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.
Fixes Agent Host Copilot shell terminals created for worktree-isolated sessions so they start in the resolved worktree directory instead of the Agent Host process cwd.
Summary:
ShellManageron create and resume paths.pwdin the shell terminal and verify the terminal cwd/output matches the resolved worktree path.Validation:
node --experimental-strip-types build/hygiene.ts src/vs/platform/agentHost/node/copilot/copilotAgent.ts src/vs/platform/agentHost/node/copilot/copilotShellTools.ts src/vs/platform/agentHost/test/node/copilotShellTools.test.ts src/vs/platform/agentHost/test/node/protocol/toolApprovalRealSdk.integrationTest.tsAGENT_HOST_REAL_SDK=1 ./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/protocol/toolApprovalRealSdk.integrationTest.ts --grep "worktree session uses the resolved worktree as working directory"(Written by Copilot)