Skip to content

Serialize resolveCommentThread to fix race condition with rapid resolves#8651

Merged
alexr00 merged 3 commits intomainfrom
copilot/fix-resolved-comments-state
Apr 8, 2026
Merged

Serialize resolveCommentThread to fix race condition with rapid resolves#8651
alexr00 merged 3 commits intomainfrom
copilot/fix-resolved-comments-state

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Resolving multiple comment threads quickly in the PR webview causes resolved state to not persist. Each resolveCommentThread call runs a mutation then fetches the full timeline via _getTimeline(). When concurrent, the timeline re-fetch from an earlier call can return stale data (before a later mutation has propagated) and overwrite the webview state via updatePR({ events }).

  • Added a _resolveCommentThreadQueue promise chain to PullRequestOverviewPanel that serializes resolve/unresolve operations, ensuring each mutation + timeline fetch completes before the next begins
  • Optimistic UI updates in the webview React state still provide immediate visual feedback
private resolveCommentThread(message: IRequestMessage<...>) {
    this._resolveCommentThreadQueue = this._resolveCommentThreadQueue.then(async () => {
        // mutation + timeline fetch run sequentially per call
    });
}

When resolving multiple PR comments quickly in the webview, concurrent
resolveCommentThread handlers would race: each fetches the full timeline
after its mutation, and a stale response from an earlier call can
overwrite a newer one. Serialize these operations using a promise queue
so each mutation + timeline fetch completes before the next starts.

Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/cbcba014-095c-41d9-a8bd-d041f599c908

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix state not updating for resolved comments in PR Serialize resolveCommentThread to fix race condition with rapid resolves Apr 8, 2026
Copilot AI requested a review from alexr00 April 8, 2026 10:40
@alexr00 alexr00 marked this pull request as ready for review April 8, 2026 14:12
Copilot AI review requested due to automatic review settings April 8, 2026 14:12
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

This PR addresses a race condition in the Pull Request webview where rapidly resolving/unresolving multiple review threads could cause older timeline refreshes to overwrite newer resolved state.

Changes:

  • Introduces a _resolveCommentThreadQueue promise chain to serialize resolve/unresolve operations.
  • Updates resolveCommentThread to enqueue mutation + _getTimeline() refresh sequentially per request.
Show a summary per file
File Description
src/github/pullRequestOverview.ts Serializes review-thread resolve/unresolve operations to prevent stale timeline refreshes from overwriting newer state.

Copilot's findings

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

Comment thread src/github/pullRequestOverview.ts Outdated
Comment thread src/github/pullRequestOverview.ts Outdated
@alexr00 alexr00 merged commit dea21f8 into main Apr 8, 2026
6 checks passed
@alexr00 alexr00 deleted the copilot/fix-resolved-comments-state branch April 8, 2026 14:57
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.

Resolving comments doesn't seem to update state on server?

4 participants