Skip to content

Sessions - simplify workspace tracking#4698

Merged
lszomoru merged 4 commits intomainfrom
lszomoru/innocent-barnacle
Mar 26, 2026
Merged

Sessions - simplify workspace tracking#4698
lszomoru merged 4 commits intomainfrom
lszomoru/innocent-barnacle

Conversation

@lszomoru
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings March 25, 2026 21:18
@lszomoru lszomoru enabled auto-merge March 25, 2026 21:18
@lszomoru lszomoru self-assigned this Mar 25, 2026
@lszomoru lszomoru added this to the 1.114.0 milestone Mar 25, 2026
Copy link
Contributor

Copilot AI left a 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 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 a Sequencer and factor shared logic into a private _getRepository.
  • Remove ChatSessionRepositoryTracker injection/usage from CopilotCLIChatSessionParticipant and update unit tests accordingly.
  • Refactor ChatSessionRepositoryTracker to 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;

@lszomoru lszomoru force-pushed the lszomoru/innocent-barnacle branch from e45fa77 to 2afa17a Compare March 25, 2026 21:31
@lszomoru lszomoru added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit 09499c7 Mar 26, 2026
22 of 23 checks passed
@lszomoru lszomoru deleted the lszomoru/innocent-barnacle branch March 26, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants