[Chat] Avoid misleading repeated repository-root traces in multi-root workspaces
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
## Bug: misleading repeated repository-root trace messages in multi-root workspaces
### Environment
- VS Code: 1.136.1
- GitHub Copilot extension: 0.64.1
- OS: Windows
- `chat.useCustomizationsInParentRepositories`: `true`
- Workspace: large multi-root workspace with many sibling folders under one trusted Git repository
All paths below are synthetic and anonymized.
### Reproduction
1. Create a trusted Git repository at `C:\git-root`.
3. Add many sibling folders below a common directory, for example `C:\git-root\modules\component-a` and `C:\git-root\modules\component-b` and so on.
4. Add those sibling folders as workspace folders in a multi-root workspace. Ensure that the first workspace folder is nested below the repository root so like modules\component-b.
5. Enable `chat.useCustomizationsInParentRepositories`.
6. Trigger automatic instruction collection, for example by starting an Agent request.
### Observed behavior
A trace message is emitted for each later sibling workspace folder, for example:
`[AutomaticInstructionsCollector] No repository root found for folder file:///C%3A/git-root/modules/component-b.`
The repository root does exist and was already discovered while processing the first workspace folder. The message is repeated for many sibling folders during a single collection pass.
### Technical cause
In `AgentInstructionsLocator.getWorkspaceFolderRoots`, one `ResourceSet` is shared across the sequential workspace-folder walks. In `findParentRepoFolders`, the walk stops when `seen.has(parent)` is true, but the method then unconditionally logs `No repository root found for folder ...`.
Therefore, reaching an already processed parent is reported as if no repository root existed, even though that root is already present in the final root set.
Relevant source:
- https://github.com/microsoft/vscode/blob/1.136.1/extensions/copilot/src/platform/promptFiles/vscode-node/agentInstructionsLocator.ts
- https://github.com/microsoft/vscode/blob/1.136.1/extensions/copilot/src/platform/promptFiles/node/automaticInstructionsCollector.ts
### Expected behavior
Stopping because an ancestor has already been processed should not emit a misleading "No repository root found" message. Possible alternatives:
- do not log in the `seen.has(parent)` case; or
- emit a distinct trace message such as "Repository-root search stopped at an already processed parent"; or
- deduplicate the diagnostic to at most once per collection pass.
A "No repository root found" message should be reserved for a walk that actually reaches the filesystem/user-home boundary without finding a repository root, or for a genuine access failure.
### Impact
This is primarily diagnostic noise, but it can produce a large number of trace entries and unnecessary repeated filesystem checks in large multi-root workspaces. The customizations themselves appear to remain discoverable because the previously found repository root is retained in the shared root set.
Think of a code-workspace file with 300+ folders wich all trace down to git root and throw this trace log.
Contributor guide
Assessment
This issue has not been assessed yet.