Skip to content

Sessions: PR detection fixes#4971

Merged
osortega merged 2 commits intomainfrom
osortega/passing-aardvark
Apr 6, 2026
Merged

Sessions: PR detection fixes#4971
osortega merged 2 commits intomainfrom
osortega/passing-aardvark

Conversation

@osortega
Copy link
Copy Markdown
Contributor

@osortega osortega commented Apr 3, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 3, 2026 22:21
@osortega osortega self-assigned this Apr 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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' whenever prResult.state is present (it always is for detectPullRequestWithRetry). Add parentheses (or rewrite with an if) so the fallback to 'open' only happens when state is 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 as a ?? b ? c : d, which evaluates as (a ?? b) ? c : d and will coerce any non-empty prResult.state into '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_COUNT is now 5 but the doc comment on detectPullRequestWithRetry below 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_COUNT is now 5 but detectPullRequestWithRetry'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

@osortega osortega enabled auto-merge April 3, 2026 22:59
@osortega osortega added this pull request to the merge queue Apr 4, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 4, 2026
@osortega osortega added this pull request to the merge queue Apr 6, 2026
Merged via the queue into main with commit a956daf Apr 6, 2026
19 checks passed
@osortega osortega deleted the osortega/passing-aardvark branch April 6, 2026 22:55
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.

3 participants