Skip to content

agents: fix duplicate workspace created tasks firing#319078

Merged
connor4312 merged 1 commit into
mainfrom
connor4312/fix-duplicate-worktree-created-tasks
May 30, 2026
Merged

agents: fix duplicate workspace created tasks firing#319078
connor4312 merged 1 commit into
mainfrom
connor4312/fix-duplicate-worktree-created-tasks

Conversation

@connor4312
Copy link
Copy Markdown
Member

agents: fix duplicate workspace created tasks firing

The autorun in WorktreeCreatedTaskDispatcher previously disposed its own store via _sessionDisposables.deleteAndDispose, which could synchronously remove the entry while the autorun was still mid-run and allow a re-entrant _trackSession call to install a fresh autorun that fires again.

  • Switch to reader.dispose() so the autorun tears itself down cleanly without racing _sessionDisposables bookkeeping, preventing the worktreeCreated tasks from being dispatched more than once per session.

(Commit message generated by Copilot)

The autorun in WorktreeCreatedTaskDispatcher previously disposed its own store via _sessionDisposables.deleteAndDispose, which could synchronously remove the entry while the autorun was still mid-run and allow a re-entrant _trackSession call to install a fresh autorun that fires again.

- Switch to reader.dispose() so the autorun tears itself down cleanly without racing _sessionDisposables bookkeeping, preventing the worktreeCreated tasks from being dispatched more than once per session.

(Commit message generated by Copilot)
Copilot AI review requested due to automatic review settings May 30, 2026 00:34
@connor4312 connor4312 enabled auto-merge (squash) May 30, 2026 00:34
Copy link
Copy Markdown
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 duplicate dispatch of worktreeCreated tasks by switching from _sessionDisposables.deleteAndDispose to reader.dispose() inside the registerAutorunSelfDisposable callback. The prior approach could synchronously remove the per-session disposable entry mid-autorun, allowing a re-entrant _trackSession to install a fresh autorun and fire tasks again.

Changes:

  • Use reader.dispose() to cleanly tear down the autorun without racing _sessionDisposables bookkeeping.
  • Remove the now-stale comment block above the autorun.
Show a summary per file
File Description
src/vs/sessions/contrib/chat/browser/worktreeCreatedTaskDispatcher.ts Switch self-disposal mechanism to reader.dispose(); drop obsolete comment.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@connor4312 connor4312 merged commit 98f3db9 into main May 30, 2026
40 of 41 checks passed
@connor4312 connor4312 deleted the connor4312/fix-duplicate-worktree-created-tasks branch May 30, 2026 18:41
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 30, 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