diff --git a/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts b/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts index 8982dc62b..1b49a57d1 100644 --- a/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts +++ b/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts @@ -1262,13 +1262,13 @@ export class CopilotCLIChatSessionParticipant extends Disposable { } } - private static readonly _PR_DETECTION_RETRY_COUNT = 3; + private static readonly _PR_DETECTION_RETRY_COUNT = 5; private static readonly _PR_DETECTION_INITIAL_DELAY_MS = 2_000; private async handlePullRequestCreated(session: ICopilotCLISession): Promise { const sessionId = session.sessionId; let prUrl = session.createdPullRequestUrl; - let prState = 'open'; + let prState = ''; this.logService.debug(`[CopilotCLIChatSessionParticipant] handlePullRequestCreated for ${sessionId}: createdPullRequestUrl=${prUrl ?? 'none'}`); @@ -1285,7 +1285,7 @@ export class CopilotCLIChatSessionParticipant extends Disposable { this.logService.debug(`[CopilotCLIChatSessionParticipant] No PR URL from session, attempting retry detection for ${sessionId}, branch=${worktreeProperties.branchName}`); const prResult = await this.detectPullRequestWithRetry(sessionId); prUrl = prResult?.url; - prState = prResult?.state ?? 'open'; + prState = prResult?.state ?? prResult?.url ? 'open' : ''; } else { this.logService.debug(`[CopilotCLIChatSessionParticipant] Skipping retry detection for ${sessionId}: branch=${worktreeProperties.branchName ?? 'none'}, repoPath=${!!worktreeProperties.repositoryPath}`); } diff --git a/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts b/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts index c5d84c0c3..04a025c07 100644 --- a/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts +++ b/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts @@ -1535,13 +1535,13 @@ export class CopilotCLIChatSessionParticipant extends Disposable { } } - private static readonly _PR_DETECTION_RETRY_COUNT = 3; + private static readonly _PR_DETECTION_RETRY_COUNT = 5; private static readonly _PR_DETECTION_INITIAL_DELAY_MS = 2_000; private async handlePullRequestCreated(session: ICopilotCLISession): Promise { const sessionId = session.sessionId; let prUrl = session.createdPullRequestUrl; - let prState = 'open'; + let prState = ''; this.logService.debug(`[CopilotCLIChatSessionParticipant] handlePullRequestCreated for ${sessionId}: createdPullRequestUrl=${prUrl ?? 'none'}`); @@ -1559,7 +1559,7 @@ export class CopilotCLIChatSessionParticipant extends Disposable { this.logService.debug(`[CopilotCLIChatSessionParticipant] No PR URL from session, attempting retry detection for ${sessionId}, branch=${worktreeProperties.branchName}`); const prResult = await this.detectPullRequestWithRetry(sessionId); prUrl = prResult?.url; - prState = prResult?.state ?? 'open'; + prState = prResult?.state ?? prUrl ? 'open' : ''; } else { this.logService.debug(`[CopilotCLIChatSessionParticipant] Skipping retry detection for ${sessionId}: branch=${worktreeProperties.branchName ?? 'none'}, repoPath=${!!worktreeProperties.repositoryPath}`); } diff --git a/src/extension/chatSessions/vscode-node/test/copilotCLIChatSessionParticipant.spec.ts b/src/extension/chatSessions/vscode-node/test/copilotCLIChatSessionParticipant.spec.ts index 9aa15e597..d684a64ec 100644 --- a/src/extension/chatSessions/vscode-node/test/copilotCLIChatSessionParticipant.spec.ts +++ b/src/extension/chatSessions/vscode-node/test/copilotCLIChatSessionParticipant.spec.ts @@ -2097,8 +2097,8 @@ describe('CopilotCLIChatSessionParticipant.handleRequest', () => { await vi.runAllTimersAsync(); await handlerPromise; - // 3 attempts total (after 2s, 4s, and 8s delays) - expect(findPr).toHaveBeenCalledTimes(3); + // 5 attempts total (after 2s, 4s, 8s, 16s, and 32s delays) + expect(findPr).toHaveBeenCalledTimes(5); // Should NOT have persisted any PR URL since all attempts failed const setPropsCallsWithPrUrl = (worktree.setWorktreeProperties as ReturnType).mock.calls .filter((args: unknown[]) => (args[1] as { pullRequestUrl?: string })?.pullRequestUrl !== undefined);