Skip to content

sessions - fix wrong use of ahead/behind in sync action#298254

Merged
bpasero merged 1 commit intomainfrom
ben/copilot-worktree-2026-02-27T08-01-41
Feb 27, 2026
Merged

sessions - fix wrong use of ahead/behind in sync action#298254
bpasero merged 1 commit intomainfrom
ben/copilot-worktree-2026-02-27T08-01-41

Conversation

@bpasero
Copy link
Member

@bpasero bpasero commented Feb 27, 2026

No description provided.

@bpasero bpasero self-assigned this Feb 27, 2026
Copilot AI review requested due to automatic review settings February 27, 2026 14:15
@bpasero bpasero modified the milestones: February 2026, March 2026 Feb 27, 2026
@bpasero bpasero enabled auto-merge (squash) February 27, 2026 14:15
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

Fixes the ahead/behind values used to label the Git sync action in the Agent Sessions window, and hardens repository-observer lifecycle to avoid attaching observers for stale repositories.

Changes:

  • Ensure registerSyncAction receives (behind, ahead) rather than (ahead, behind).
  • Introduce a per-repository DisposableStore to prevent late openRepository resolutions from wiring observers after the session/worktree has changed.
Comments suppressed due to low confidence (1)

src/vs/sessions/contrib/gitSync/browser/gitSync.contribution.ts:55

  • When switching active sessions, _gitRepoDisposables.clear() disposes the previous repo autorun, but _syncActionDisposable and contextKey can remain in their previous state until the new openRepository resolves and the new autorun runs. This can leave a stale sync action/counts visible briefly (or longer if openRepository never resolves for the new worktree). Consider clearing _syncActionDisposable and setting contextKey to false before kicking off openRepository (or when repoDisposables.isDisposed is detected) so the UI doesn’t show outdated ahead/behind info.
			const repoDisposables = this._gitRepoDisposables.add(new DisposableStore());
			this.gitService.openRepository(worktreeUri).then(repository => {
				if (repoDisposables.isDisposed) {
					return;
				}

@bpasero bpasero merged commit 5e2614b into main Feb 27, 2026
24 checks passed
@bpasero bpasero deleted the ben/copilot-worktree-2026-02-27T08-01-41 branch February 27, 2026 15:11
DonJayamanne pushed a commit that referenced this pull request Mar 2, 2026
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