Agents - use pathspec file when adding files to the temporary index to help with performance#309593
Merged
Agents - use pathspec file when adding files to the temporary index to help with performance#309593
Conversation
…o help with performance
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
Improves performance of Agent Sessions’ “temp index” workflows by staging only the set of uncommitted files (via a generated pathspec file) instead of staging the entire working directory when computing diffs/snapshots.
Changes:
- Added
getUncommittedFilePaths()helper to derive a deduped list of repo-relative changed paths. - Updated worktree/workspace diff collection to use
git add -A --pathspec-from-file=...when untracked files are present. - Updated checkpoint creation to stage via a pathspec file rather than
git add -A -- ..
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/git/vscode-node/utils.ts | Adds helper to compute repo-relative uncommitted paths for use in pathspec files. |
| extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorktreeServiceImpl.ts | Uses the helper + pathspec file when staging into the temp index for diff stats in worktree isolation mode. |
| extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorktreeCheckpointServiceImpl.ts | Uses the helper + pathspec file when staging into the temp index for checkpoint snapshot creation. |
| extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorkspaceFolderServiceImpl.ts | Uses the helper + pathspec file when staging into the temp index for diff stats in workspace isolation mode. |
Copilot's findings
Comments suppressed due to low confidence (1)
extensions/copilot/src/platform/git/vscode-node/utils.ts:121
- The paths returned here are later passed to
git addvia--pathspec-from-file. Git pathspecs treat*,?, and[]as glob characters by default, so a file name containing those characters can match unintended paths. Consider emitting literal pathspecs (e.g. prefix each entry with:(literal)), or otherwise ensure the entries are interpreted literally when written to the pathspec file.
const relativePaths = coalesce(Array.from(resources)
.map(uri => relativePath(repository.rootUri, uri)));
// Git expects forward slashes even on Windows
return relativePaths.map(p => p.replace(/\\/g, '/'));
- Files reviewed: 4/4 changed files
- Comments generated: 3
roblourens
approved these changes
Apr 13, 2026
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.
No description provided.