Repository navigation
agentHost: run repository hooks only in folders trusted in VS Code - #349330
Merged
Merged
Conversation
The Copilot runtime loads a repository's `.github/hooks` whenever the host enables repository hooks, and leaves the trust check to the host. VS Code enabled them for every folder, so these hooks ran in untrusted folders. Repository hooks are now enabled only when VS Code trusts the session's working folder. Chat Customizations lists the hook files of an untrusted folder as "Won't run until you trust this folder", drops repository hooks the runtime reports through its own trusted folders, and no longer passes an untrusted folder to the hook listing workaround. The list updates when workspace trust changes. Refs #345931 Co-authored-by: Copilot <[email protected]>
This was referenced Nov 19, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Repository hooks lacking both path fields remain visible as enabled when the primary folder is untrusted, contradicting the session’s disabled-hook behavior.
1 open issue
What changed in this PR
This PR ties Copilot Agent Host repository-hook execution to VS Code workspace trust, addressing the untrusted-folder portion of #345931. The reported trusted-folder issue on Windows remains outside the validated scope.
Changes:
- Enables repository hooks only for trusted working folders, excluding virtual workspaces.
- Shows untrusted hook files with a Won't run badge and refreshes discovery when trust changes.
- Adds trust-gating and badge-propagation tests, and updates integration-test setup.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentCustomizationItemProvider.test.ts |
Tests disabled-hook status through file expansion. |
src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationItemSource.ts |
Preserves badges when expanding hook files. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationItemProvider.ts |
Adds the Won't run status to disabled hooks. |
src/vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test.ts |
Tests untrusted-hook discovery and trust-change notifications. |
src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts |
Tests repository-hook gating during create and resume. |
src/vs/platform/agentHost/test/node/copilotSdkCustomizationDiscovery.integrationTest.ts |
Supplies explicit trust configuration for discovery tests. |
src/vs/platform/agentHost/node/copilot/sessionCustomizationDiscovery.ts |
Filters runtime hooks, lists untrusted files, and observes trust changes. |
src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts |
Gates repository-hook execution on workspace trust. |
Review effort: Balanced
A repository hook the runtime reports with neither a project path nor a definition file could not be tied to a folder, so it stayed listed as enabled next to the "Won't run" files of an untrusted folder. Such hooks are now dropped whenever a queried folder is untrusted. Co-authored-by: Copilot <[email protected]>
Vritant Bhardwaj (vritant24)
marked this pull request as ready for review
November 19, 2026 22:03
Vritant Bhardwaj (vritant24)
enabled auto-merge
November 19, 2026 22:04
…gration test Sessions now list a repository's hook files as not running when the folder is not trusted. The test's agent host had no workspace trust configuration, so its workspace hook was listed as untrusted. The suite now turns workspace trust off, as in VS Code without workspace trust. Co-authored-by: Copilot <[email protected]>
Repository hooks of an untrusted folder are now listed as not running, and this suite's agent host had no workspace trust configuration. Its sessions now trust their workspace before they are created, as VS Code does for a trusted folder. Co-authored-by: Copilot <[email protected]>
Bhavya U (bhavyaus)
approved these changes
Nov 19, 2026
Closed
3 tasks done
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.

Refs #345931
What this changes
In a Copilot session, the Copilot runtime runs a repository's
.github/hooksfiles whenever the host turns on repository hooks, and leaves the trust decision to the host. VS Code turned them on for every folder, so these hooks ran in folders the user had not trusted.This covers the untrusted-folder half of #345931. Whether hooks run in a trusted folder on Windows has not been checked on Windows.
How to test
.github/hooks/log.jsonwith asessionStarthook that appends a line to a file.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,545 passing, 1 pending)pnpm run typecheck-client: passedcopilotSdkCustomizationDiscovery.integrationTest.ts(updated; needs the integration runner).