Skip to content

Commit a956daf

Browse files
authored
Sessions: PR detection fixes (#4971)
* Sessions: PR detection fixes * Test update
1 parent 38c3483 commit a956daf

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,13 +1262,13 @@ export class CopilotCLIChatSessionParticipant extends Disposable {
12621262
}
12631263
}
12641264

1265-
private static readonly _PR_DETECTION_RETRY_COUNT = 3;
1265+
private static readonly _PR_DETECTION_RETRY_COUNT = 5;
12661266
private static readonly _PR_DETECTION_INITIAL_DELAY_MS = 2_000;
12671267

12681268
private async handlePullRequestCreated(session: ICopilotCLISession): Promise<void> {
12691269
const sessionId = session.sessionId;
12701270
let prUrl = session.createdPullRequestUrl;
1271-
let prState = 'open';
1271+
let prState = '';
12721272

12731273
this.logService.debug(`[CopilotCLIChatSessionParticipant] handlePullRequestCreated for ${sessionId}: createdPullRequestUrl=${prUrl ?? 'none'}`);
12741274

@@ -1285,7 +1285,7 @@ export class CopilotCLIChatSessionParticipant extends Disposable {
12851285
this.logService.debug(`[CopilotCLIChatSessionParticipant] No PR URL from session, attempting retry detection for ${sessionId}, branch=${worktreeProperties.branchName}`);
12861286
const prResult = await this.detectPullRequestWithRetry(sessionId);
12871287
prUrl = prResult?.url;
1288-
prState = prResult?.state ?? 'open';
1288+
prState = prResult?.state ?? prResult?.url ? 'open' : '';
12891289
} else {
12901290
this.logService.debug(`[CopilotCLIChatSessionParticipant] Skipping retry detection for ${sessionId}: branch=${worktreeProperties.branchName ?? 'none'}, repoPath=${!!worktreeProperties.repositoryPath}`);
12911291
}

src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,13 +1535,13 @@ export class CopilotCLIChatSessionParticipant extends Disposable {
15351535
}
15361536
}
15371537

1538-
private static readonly _PR_DETECTION_RETRY_COUNT = 3;
1538+
private static readonly _PR_DETECTION_RETRY_COUNT = 5;
15391539
private static readonly _PR_DETECTION_INITIAL_DELAY_MS = 2_000;
15401540

15411541
private async handlePullRequestCreated(session: ICopilotCLISession): Promise<void> {
15421542
const sessionId = session.sessionId;
15431543
let prUrl = session.createdPullRequestUrl;
1544-
let prState = 'open';
1544+
let prState = '';
15451545

15461546
this.logService.debug(`[CopilotCLIChatSessionParticipant] handlePullRequestCreated for ${sessionId}: createdPullRequestUrl=${prUrl ?? 'none'}`);
15471547

@@ -1559,7 +1559,7 @@ export class CopilotCLIChatSessionParticipant extends Disposable {
15591559
this.logService.debug(`[CopilotCLIChatSessionParticipant] No PR URL from session, attempting retry detection for ${sessionId}, branch=${worktreeProperties.branchName}`);
15601560
const prResult = await this.detectPullRequestWithRetry(sessionId);
15611561
prUrl = prResult?.url;
1562-
prState = prResult?.state ?? 'open';
1562+
prState = prResult?.state ?? prUrl ? 'open' : '';
15631563
} else {
15641564
this.logService.debug(`[CopilotCLIChatSessionParticipant] Skipping retry detection for ${sessionId}: branch=${worktreeProperties.branchName ?? 'none'}, repoPath=${!!worktreeProperties.repositoryPath}`);
15651565
}

src/extension/chatSessions/vscode-node/test/copilotCLIChatSessionParticipant.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,8 +2097,8 @@ describe('CopilotCLIChatSessionParticipant.handleRequest', () => {
20972097
await vi.runAllTimersAsync();
20982098
await handlerPromise;
20992099

2100-
// 3 attempts total (after 2s, 4s, and 8s delays)
2101-
expect(findPr).toHaveBeenCalledTimes(3);
2100+
// 5 attempts total (after 2s, 4s, 8s, 16s, and 32s delays)
2101+
expect(findPr).toHaveBeenCalledTimes(5);
21022102
// Should NOT have persisted any PR URL since all attempts failed
21032103
const setPropsCallsWithPrUrl = (worktree.setWorktreeProperties as ReturnType<typeof vi.fn>).mock.calls
21042104
.filter((args: unknown[]) => (args[1] as { pullRequestUrl?: string })?.pullRequestUrl !== undefined);

0 commit comments

Comments
 (0)