Skip to content

agentHost: give the Copilot runtime the real path of a symlinked folder - #349333

Merged
Vritant Bhardwaj (vritant24) merged 3 commits into
mainfrom
dev/vritant24/hooks-symlink
Nov 21, 2026
Merged

Vritant Bhardwaj (vritant24) merged 3 commits into
mainfrom
dev/vritant24/hooks-symlink

Conversation

@vritant24

Copy link
Copy Markdown
Member

Fixes #347733

What this changes

When a folder is opened through a symbolic link, VS Code gave the Copilot runtime the linked path. The runtime does not run a folder's repository hooks when the session was trusted through a linked path, so these hooks never ran.

  • VS Code now gives the runtime the folder's real path as the session's working directory. If the path cannot be resolved, it falls back to the opened path.
  • Hook files that the runtime reports under the real path are shown in Chat Customizations under the path the user opened.

This is independent of the other hook PRs and is based on main.

How to test

  1. Create a git repository with a .github/hooks/log.json sessionStart hook that appends a line to a file, and a symbolic link to it (ln -s repo link).
  2. Open and trust link in VS Code.
  3. Chat Customizations > Hooks lists the file under the link path. Start a Copilot session: the hook runs.

Validation

  • ./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts --run src/vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test.ts --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentCustomizationItemProvider.test.ts --run src/vs/workbench/contrib/chat/test/browser/aiCustomization/customizationMigration.test.ts --run src/vs/workbench/contrib/chat/test/browser/aiCustomization/customizationMigrationServiceImpl.test.ts: passed (1,543 passing, 1 pending)
  • pnpm run typecheck-client: passed
  • oxlint (pre-commit hygiene): passed
  • Checked the listing manually in Code OSS on macOS. Not checked on Windows, where the test that creates a symbolic link is skipped.

Copilot AI balanced review requested due to automatic review settings November 19, 2026 21:25

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

Linked-workspace URI remapping can incorrectly rewrite hook and MCP definition URIs outside the resolved root, breaking navigation in Chat Customizations.

1 open issue
What changed in this PR

This PR addresses skipped repository hooks when a workspace is opened through a symbolic link. It gives the Copilot runtime the resolved working directory while preserving the opened path in Chat Customizations.

Changes:

  • Resolve local working directories before creating or resuming sessions, falling back to the opened path on failure.
  • Map runtime-reported hook and MCP definition paths back to the opened workspace path.
  • Add symlink regression tests and update working-directory expectations.
File Description
src/​vs/​platform/​agentHost/​test/​node/​sessionCustomizationDiscovery.test.ts Tests hook paths under a linked workspace.
src/​vs/​platform/​agentHost/​test/​node/​copilotSessionLauncher.test.ts Tests working-directory resolution and fallback behavior.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Updates expectations to use resolved working directories.
src/​vs/​platform/​agentHost/​node/​copilot/​sessionCustomizationDiscovery.ts Maps definition paths back to opened workspace paths.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotSessionLauncher.ts Supplies resolved working directories when creating and resuming sessions.

Review effort: Balanced

@vritant24
Vritant Bhardwaj (vritant24) marked this pull request as ready for review November 19, 2026 22:33
@vritant24
Vritant Bhardwaj (vritant24) added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 19, 2026
@vritant24
Vritant Bhardwaj (vritant24) added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@vritant24
Vritant Bhardwaj (vritant24) added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@vritant24
Vritant Bhardwaj (vritant24) added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@vritant24
Vritant Bhardwaj (vritant24) added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@vritant24
Vritant Bhardwaj (vritant24) added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@vritant24
Vritant Bhardwaj (vritant24) added this pull request to the merge queue Nov 20, 2026
The Copilot runtime does not run a folder's repository hooks when the session
was trusted through a symlinked path, so hooks never ran when VS Code opened a
folder through a symlink.

VS Code now passes the folder's real path as the session's working directory,
and maps hook files the runtime reports under the real path back to the path
the user opened.

Fixes #347733

Co-authored-by: Copilot <[email protected]>
Definition files outside the folder's real path, such as user hooks, were
rewritten relative to the opened path, which pointed Chat Customizations at
the wrong files when the link and its target are at different depths.

Co-authored-by: Copilot <[email protected]>
…opilot agent tests

fs.promises.realpath uses the native implementation, which on Windows expands
short path names and changes the drive letter case, so it did not match the
working directory the launcher computes with Promises.realpath.

Co-authored-by: Copilot <[email protected]>
@vritant24
Vritant Bhardwaj (vritant24) added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit d7919fd Nov 21, 2026
38 checks passed
@vritant24
Vritant Bhardwaj (vritant24) deleted the dev/vritant24/hooks-symlink branch November 21, 2026 00:29
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.

Agent host: repo hooks silently skipped when workspace is opened via a symlinked path (/tmp)

5 participants