Claude session refresh repeatedly opens historical repositories and overloads file watching
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
@TylerLeonhardt I wasn't actively using the Claude harness, but the Claude EH code seems to be causing some background load. This seems similar to the file watcher issues that I fixed with the EH Copilot CLI. In that case, I just disabled the watchers entirely when the settings are set to prefer AH, in case the same thing makes sense here.
---
## Type of issue
Performance / file watching
## Summary
In an Agents window with Agent Host enabled, the extension-host Claude session provider repeatedly attempts to open repositories for every historical Claude session. This includes deleted worktrees and stale temporary test repositories. Repository open/close events trigger another full session refresh, which appears to amplify the work and create large bursts of Git repository discovery and file watcher activity.
Under load, the recursive Parcel/FSEvents watchers repeatedly report:
```text
ERR [File Watcher ('parcel')] Events were dropped by the FSEvents client. File system must be re-scanned. (path: )
```
The machine load makes the FSEvents drops easier to trigger, but the repeated repository work happens independently and should be fixed.
## Evidence from one Insiders run
Insiders: `1.132.0-insider` (`9e200810d9e54a5c66a50ba9538bd8b2545761b2`)
Across the current log run:
- 30,920 `[ClaudeWorkspaceFolderService] No repository found` warnings across 120 historical paths.
- 7,010 successful Git extension `openRepository` operations across 143 paths during the latest extension-host reload.
- One minute contained 1,774 repository opens and 738 failed Claude repository lookups.
- The Agents window's file watcher logged 784 FSEvents-drop errors. The same failures were also repeated in `renderer.log`.
- Many paths were deleted temporary Agent Host test repositories, yet each was retried hundreds of times.
## Suspected feedback loop
1. [`ClaudeChatSessionItemController`](https://github.com/microsoft/vscode/blob/08fe2b7a9717a31fe32dc56bd0282042054e702d/extensions/copilot/src/extension/chatSessions/vscode-node/claudeChatSessionContentProvider.ts#L460-L470) refreshes the complete Claude session list whenever any Git repository opens or closes.
2. Each session item eagerly calls [`getWorkspaceChanges`](https://github.com/microsoft/vscode/blob/08fe2b7a9717a31fe32dc56bd0282042054e702d/extensions/copilot/src/extension/chatSessions/vscode-node/claudeChatSessionContentProvider.ts#L852-L864).
3. [`ClaudeWorkspaceFolderService`](https://github.com/microsoft/vscode/blob/08fe2b7a9717a31fe32dc56bd0282042054e702d/extensions/copilot/src/extension/chatSessions/vscode-node/claudeWorkspaceFolderServiceImpl.ts#L104-L115) calls `IGitService.getRepository` for every historical working directory.
4. [`GitServiceImpl.getRepository`](https://github.com/microsoft/vscode/blob/08fe2b7a9717a31fe32dc56bd0282042054e702d/extensions/copilot/src/platform/git/vscode-node/gitServiceImpl.ts#L144-L182) defaults `forceOpen` to `true`, so a list refresh opens repositories instead of only consulting already-open repositories.
5. Failed repository lookups return `[]` without populating `_cache`, so deleted or unavailable repositories are retried on every refresh.
6. Successfully opening another repository emits `onDidOpenRepository`, causing another full refresh.
The earlier Agent Host fixes that disable the Copilot CLI JSONL watcher and `ChatSessionRepositoryTracker` do not cover this Claude provider path.
## Expected behavior
Populating the session list should not force-open every historical session repository or continuously retry unavailable paths. Git repository changes should not cause a full O(number of historical sessions) repository scan.
## Potential fixes
- Use a non-opening repository lookup when rendering historical session items.
- Cache unavailable/deleted repositories, with deliberate invalidation if needed.
- Avoid rebuilding every Claude session item for each repository open/close event.
- Consider suppressing the extension-host Claude session processing when Agent Host owns the relevant surface.
(Written by Copilot)
Contributor guide
Assessment
This issue has not been assessed yet.