-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Copilot CLI - do not open repository to compute worktree statistics #2461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR optimizes the Copilot CLI worktree statistics computation by adding an option to avoid unnecessarily opening git repositories. The getRepository() method now accepts an optional forceOpen parameter (defaulting to true for backward compatibility) to control whether repositories should be opened if not already discovered. The worktree statistics computation uses forceOpen: false to avoid the overhead of opening repositories that may not yet be discovered.
Key changes:
- Add optional
forceOpenparameter toIGitService.getRepository()with default value oftrue - Ensure
getRepository()waits for initial repository discovery to complete before checking opened repositories - Refactor worktree statistics computation to use the git service method instead of directly accessing the git extension API
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/platform/git/common/gitService.ts | Add optional forceOpen parameter to getRepository() interface |
| src/platform/git/vscode/gitServiceImpl.ts | Implement forceOpen parameter logic and ensure initialization is complete before querying repositories |
| src/platform/test/node/simulationWorkspaceServices.ts | Update test mock signature to match new interface |
| src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts | Use forceOpen: false when computing worktree statistics and refactor to use git service methods |
| const details: vscode.ChatSessionChangedFile[] = []; | ||
| for (const change of [...repository.changes.indexChanges, ...repository.changes.workingTree]) { | ||
| try { | ||
| const fileStats = await this.gitService.diffIndexWithHEADShortStats(change.uri); |
Copilot
AI
Dec 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diffIndexWithHEADShortStats method is being called with change.uri, but the implementation in gitServiceImpl.ts (line 220-227) doesn't pass the file path to the underlying repository method. The repository's diffIndexWithHEADShortStats(path?: string) method expects an optional path parameter (a string), but the service implementation calls it without any arguments.
This means the method will return stats for the entire repository instead of per-file stats. You should either:
- Update the service method signature to accept a URI and extract
uri.fsPathto pass to the repository method, or - Call the method differently to get per-file statistics.
The old code called gitRepository.diffIndexWithHEADShortStats(change.uri.fsPath) directly, which was correct.
| const fileStats = await this.gitService.diffIndexWithHEADShortStats(change.uri); | |
| const fileStats = await this.gitService.diffIndexWithHEADShortStats(change.uri.fsPath); |
getRepository()waits until the initial repository discovery is completegetRepository()now takes an option to open the repository if is not found