Skip to content

Commit 47f3e96

Browse files
Copilotrebornix
andcommitted
Implement timeout-based polling for Copilot timeline events
- Replace do-while polling loop with timeout-based while loop - Add 1-minute timeout mechanism for waiting on timeline events - Wait for first Copilot event completion rather than indefinite polling - Maintain same 2-second polling interval for compatibility Co-authored-by: rebornix <876920+rebornix@users.noreply.github.com>
1 parent d3a9590 commit 47f3e96

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/github/pullRequestOverview.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,18 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
516516
// need to wait until we get the updated timeline events
517517
let events: TimelineEvent[] = [];
518518
if (result) {
519-
do {
519+
// Wait for the first copilot timeline event with timeout
520+
const maxWaitTime = 60 * 1000; // 1 minute timeout
521+
const pollInterval = 2000; // 2 seconds
522+
const startTime = Date.now();
523+
524+
while (Date.now() - startTime < maxWaitTime) {
520525
events = await this._getTimeline();
521-
} while (copilotEventToStatus(mostRecentCopilotEvent(events)) !== CopilotPRStatus.Completed && await new Promise<boolean>(c => setTimeout(() => c(true), 2000)));
526+
if (copilotEventToStatus(mostRecentCopilotEvent(events)) === CopilotPRStatus.Completed) {
527+
break;
528+
}
529+
await new Promise<void>(resolve => setTimeout(resolve, pollInterval));
530+
}
522531
}
523532
const reply: CancelCodingAgentReply = {
524533
events

0 commit comments

Comments
 (0)