Sessions - simplify workspace tracking#4698
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies Copilot CLI session workspace/repository tracking by centralizing repository-change tracking in ChatSessionRepositoryTracker (rather than per-session request handling) and by serializing git repository resolution to avoid concurrent open/get races.
Changes:
- Serialize
IGitService.getRepository*resolution behind aSequencerand factor shared logic into a private_getRepository. - Remove
ChatSessionRepositoryTrackerinjection/usage fromCopilotCLIChatSessionParticipantand update unit tests accordingly. - Refactor
ChatSessionRepositoryTrackerto react to workspace-folder add/remove events and refresh session items when repository state changes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/platform/git/vscode-node/gitServiceImpl.ts | Adds a Sequencer and consolidates repository lookup/open logic into _getRepository. |
| src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts | Removes per-request repository tracking hookup from the participant. |
| src/extension/chatSessions/vscode-node/chatSessions.ts | Stops passing the tracker into the participant; registers the tracker as a disposable service instance. |
| src/extension/chatSessions/vscode-node/chatSessionRepositoryTracker.ts | Moves tracking to workspace-folder change events and makes tracking methods private. |
| src/extension/chatSessions/vscode-node/test/copilotCLIChatSessionParticipant.spec.ts | Updates tests for the participant constructor signature and removes tracker mocking. |
Comments suppressed due to low confidence (1)
src/extension/chatSessions/vscode-node/chatSessionRepositoryTracker.ts:84
- Within
trackRepositoryChanges, the repository listener that gets registered on the new tracker uses an async callback (worktreeRepositoryState.onDidChange(async () => …)). Since the event source won’t await it, any thrown error can become an unhandled rejection. When setting up/replacing trackers, please ensure the listener body catches/logs failures (e.g. fire-and-forget with.catch(...)) so repository refresh failures don’t destabilize the extension host.
if (this.trackers.has(worktreePath)) {
const trackedRepositoryState = this.trackerRepositoryStates.get(worktreePath);
// If the repository state is the same as the one we are already tracking,
// do nothing. But if a new repository state is detected, which can happen
// when the repository is reopened, we need to replace the tracker.
if (trackedRepositoryState === worktreeRepositoryState) {
this.logService.trace(`[ChatSessionRepositoryTracker][trackRepositoryChanges] Already tracking repository changes for session ${sessionId} and worktree ${worktreePath}.`);
return;
e45fa77 to
2afa17a
Compare
rzhao271
approved these changes
Mar 25, 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.