Skip to content

Fix agent host worktree terminal cwd#310893

Merged
roblourens merged 2 commits intomainfrom
roblou/fix-agent-host-worktree-terminal-cwd
Apr 17, 2026
Merged

Fix agent host worktree terminal cwd#310893
roblourens merged 2 commits intomainfrom
roblou/fix-agent-host-worktree-terminal-cwd

Conversation

@roblourens
Copy link
Copy Markdown
Member

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:

  • Pass the resolved session working directory into ShellManager on create and resume paths.
  • Use that directory as the default cwd when shell tools create Agent Host terminals, while preserving explicit cwd overrides.
  • Add unit coverage for the ShellManager cwd fallback.
  • Extend the real SDK worktree integration test to run pwd in the shell terminal and verify the terminal cwd/output matches the resolved worktree path.

Validation:

  • VS Code build task clean: Core Transpile, Core Typecheck, Ext Build, Copilot Build.
  • 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.ts
  • AGENT_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)

Copilot AI review requested due to automatic review settings April 17, 2026 02:04
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

Screenshot Changes

Base: ea34727c Current: 7fbe1808

Changed (8)

editor/inlineChatAffordance/InlineChatOverlay/Light
Before After
before after
editor/inlineCompletions/other/JumpToHint/Dark
Before After
before after
agentSessionsViewer/CompletedRead/Dark
Before After
before after
agentSessionsViewer/CompletedRead/Light
Before After
before after
agentSessionsViewer/WithFileChangesList/Dark
Before After
before after
agentSessionsViewer/WithFileChangesList/Light
Before After
before after
agentSessionsViewer/BackgroundProvider/Dark
Before After
before after
agentSessionsViewer/BackgroundProvider/Light
Before After
before after

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ShellManager on 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

Comment thread src/vs/platform/agentHost/test/node/copilotShellTools.test.ts Outdated
Comment thread src/vs/platform/agentHost/test/node/copilotShellTools.test.ts Outdated
@roblourens roblourens marked this pull request as ready for review April 17, 2026 02:17
@roblourens roblourens enabled auto-merge (squash) April 17, 2026 02:17
@roblourens roblourens merged commit b6035ba into main Apr 17, 2026
40 of 41 checks passed
@roblourens roblourens deleted the roblou/fix-agent-host-worktree-terminal-cwd branch April 17, 2026 03:26
@vs-code-engineering vs-code-engineering Bot added this to the 1.117.0 milestone Apr 17, 2026
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.

3 participants