Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Copilot CLI session pull request (PR) detection/persistence logic to better handle delayed GitHub indexing and avoid persisting incorrect PR metadata in worktree properties.
Changes:
- Increased PR detection retry count from 3 to 5 (exponential backoff).
- Changed initial persisted PR state handling (no longer defaulting to
'open'immediately). - Updated fallback logic for deriving a PR state when only a URL is available.
Show a summary per file
| File | Description |
|---|---|
| src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts | Updates PR retry count and PR state fallback when persisting worktree PR metadata. |
| src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts | Mirrors the PR retry/state persistence changes in the non-contribution implementation. |
Copilot's findings
Comments suppressed due to low confidence (4)
src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts:1289
prState = prResult?.state ?? prResult?.url ? 'open' : ''is parsed as(prResult?.state ?? prResult?.url) ? 'open' : ''due to operator precedence, which will override real states like 'closed'/'merged'/'draft' to 'open' wheneverprResult.stateis present (it always is fordetectPullRequestWithRetry). Add parentheses (or rewrite with an if) so the fallback to 'open' only happens whenstateis missing but a URL was found.
const prResult = await this.detectPullRequestWithRetry(sessionId);
prUrl = prResult?.url;
prState = prResult?.state ?? prResult?.url ? 'open' : '';
} else {
src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts:1563
prState = prResult?.state ?? prUrl ? 'open' : ''has the same precedence issue asa ?? b ? c : d, which evaluates as(a ?? b) ? c : dand will coerce any non-emptyprResult.stateinto'open'. Add parentheses / rewrite so that'open'is only used as a fallback when state is missing but a PR URL was detected.
const prResult = await this.detectPullRequestWithRetry(sessionId);
prUrl = prResult?.url;
prState = prResult?.state ?? prUrl ? 'open' : '';
} else {
src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts:1266
_PR_DETECTION_RETRY_COUNTis now 5 but the doc comment ondetectPullRequestWithRetrybelow still describes only 3 attempts (2s/4s/8s). Update the comment (or the retry strategy) so the documentation matches the actual backoff behavior.
private static readonly _PR_DETECTION_RETRY_COUNT = 5;
private static readonly _PR_DETECTION_INITIAL_DELAY_MS = 2_000;
src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts:1539
_PR_DETECTION_RETRY_COUNTis now 5 butdetectPullRequestWithRetry's comment still lists only three attempts (2s/4s/8s). Please update the comment so it reflects the current retry/backoff behavior.
private static readonly _PR_DETECTION_RETRY_COUNT = 5;
private static readonly _PR_DETECTION_INITIAL_DELAY_MS = 2_000;
- Files reviewed: 2/2 changed files
- Comments generated: 2
src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts
Show resolved
Hide resolved
roblourens
approved these changes
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.