KEMBAR78
Implement exponential backoff for Copilot refresh after commenting on Padawan PRs by Copilot · Pull Request #7288 · microsoft/vscode-pull-request-github · GitHub
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 14, 2025

When commenting on Copilot-assigned PRs, the timeline refresh now uses exponential backoff with early exit detection to show newly launched Copilot sessions more responsively.

Problem

Previously, when a user commented on a Copilot-assigned PR, the extension would wait a fixed 1 second before refreshing the timeline to show the newly launched Copilot session. This caused delays since it takes time to determine and launch the session on GitHub.com.

Solution

Implemented exponential backoff with retry intervals of 500ms, 1s, 2s, and 5s that:

  • Captures initial timeline state before starting retries
  • Polls for new CopilotStarted events on each retry
  • Exits early when a new Copilot session is detected
  • Gracefully handles errors during timeline fetching
  • Falls back to single refresh if no new events are found

Key Benefits

  • Faster response when Copilot sessions start quickly (500ms vs 1s minimum)
  • Better user experience by showing sessions immediately when available
  • Server-friendly with reasonable retry intervals that avoid excessive load
  • Maintains reliability with fallback behavior
  • Backwards compatible with existing functionality

Implementation Details

The tryScheduleCopilotRefresh method in src/github/issueOverview.ts now:

// Before: Fixed 1-second wait
await new Promise(resolve => setTimeout(resolve, 1000));
if (!this._isDisposed) {
    this.refreshPanel();
}

// After: Exponential backoff with early exit
const delays = [500, 1000, 2000, 5000];
for (const delay of delays) {
    await new Promise(resolve => setTimeout(resolve, delay));
    
    const currentTimeline = await this._getTimeline();
    const currentCopilotStartedEvents = currentTimeline.filter(event => 
        event.event === EventType.CopilotStarted);
    
    if (currentCopilotStartedEvents.length > initialCopilotStartedEvents.length) {
        this.refreshPanel();
        return; // Early exit when new event found
    }
}

Testing

  • Added comprehensive unit tests covering edge cases
  • Verified exponential backoff timing and early exit logic
  • Confirmed backwards compatibility with existing behavior
  • All existing tests continue to pass

Fixes #7231.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits July 14, 2025 10:44
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Wait to get timeline after commenting on Padawan PRs Implement exponential backoff for Copilot refresh after commenting on Padawan PRs Jul 14, 2025
Copilot AI requested a review from alexr00 July 14, 2025 10:52
Copilot finished work on behalf of alexr00 July 14, 2025 10:52
@alexr00 alexr00 closed this Jul 14, 2025
@alexr00 alexr00 reopened this Jul 14, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't touch yarn.lock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted yarn.lock to original state as requested. ab9dabb

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot finished work on behalf of alexr00 July 14, 2025 16:01
Copilot AI requested a review from alexr00 July 14, 2025 16:01
@alexr00 alexr00 marked this pull request as ready for review July 14, 2025 16:34
@alexr00 alexr00 enabled auto-merge (squash) July 14, 2025 16:34
@vs-code-engineering vs-code-engineering bot added this to the July 2025 milestone Jul 14, 2025
@alexr00 alexr00 merged commit 8052cbe into main Jul 14, 2025
3 checks passed
@alexr00 alexr00 deleted the copilot/fix-7231 branch July 14, 2025 18:47
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.

Wait to get timeline after commenting on Padawan PRs

3 participants