Background - add repository state to the metadata#309034
Merged
Conversation
Contributor
jrieken
previously approved these changes
Apr 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Git repository “state” signals (incoming/outgoing/uncommitted changes + GitHub remote presence) into Copilot CLI session/worktree metadata so consumers can reason about repository status when rendering/backgrounding sessions.
Changes:
- Extend
RepoContextto exposeHEADahead/behind counts and surface them from the VS Code Git extension state. - Compute and persist repository-state booleans into session/worktree properties and include them in session item metadata payloads.
- Adjust change-computation helpers to return richer “properties + changes” bundles so computed state can be stored alongside diffs.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/git/vscode-node/gitServiceImpl.ts | Exposes HEAD.ahead/behind via RepoContextImpl. |
| extensions/copilot/src/platform/git/common/gitService.ts | Extends RepoContext with incoming/outgoing counts and exports GitHub remote helper used by session services. |
| extensions/copilot/src/extension/chatSessions/vscode-node/folderRepositoryManagerImpl.ts | Computes repository-state booleans for repository properties used during session initialization. |
| extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts | Adds repo-state fields to session item metadata (worktree + workspace). |
| extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts | Adds repo-state fields to worktree metadata and reorders change/metadata building. |
| extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorktreeServiceImpl.ts | Computes repo-state booleans and stores them into v2 worktree properties when computing changes. |
| extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorkspaceFolderServiceImpl.ts | Computes repo-state booleans for workspace sessions and persists them to metadata store. |
| extensions/copilot/src/extension/chatSessions/common/chatSessionWorktreeService.ts | Extends v2 worktree properties schema with repo-state fields. |
| extensions/copilot/src/extension/chatSessions/common/chatSessionMetadataStore.ts | Extends persisted RepositoryProperties schema with repo-state fields. |
Copilot's findings
Comments suppressed due to low confidence (2)
extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorktreeServiceImpl.ts:805
- Repository state computation for
hasUncommittedChangesignoresmergeChanges, which are also uncommitted. This can causehasUncommittedChangesto be false during merge conflict resolution. IncludeworktreeRepository.changes?.mergeChanges.lengthin the check.
hasIncomingChanges: (worktreeRepository.headIncomingChanges ?? 0) > 0,
hasOutgoingChanges: (worktreeRepository.headOutgoingChanges ?? 0) > 0,
hasUncommittedChanges: (worktreeRepository.changes?.indexChanges.length ?? 0) > 0 ||
(worktreeRepository.changes?.workingTree.length ?? 0) > 0 ||
(worktreeRepository.changes?.untrackedChanges.length ?? 0) > 0
extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorkspaceFolderServiceImpl.ts:253
hasUncommittedChangesignoresmergeChanges. Merge conflict changes are uncommitted and should be included in this state calculation to avoid false negatives.
hasIncomingChanges: (repository.headIncomingChanges ?? 0) > 0,
hasOutgoingChanges: (repository.headOutgoingChanges ?? 0) > 0,
hasUncommittedChanges: (repository.changes?.indexChanges.length ?? 0) > 0 ||
(repository.changes?.workingTree.length ?? 0) > 0 ||
(repository.changes?.untrackedChanges.length ?? 0) > 0
- Files reviewed: 11/11 changed files
- Comments generated: 6
jrieken
previously approved these changes
Apr 10, 2026
joaomoreno
approved these changes
Apr 10, 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.