Skip to content

Fix sorting of duplicate git configs#8764

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-prs-not-shown-in-panel
Open

Fix sorting of duplicate git configs#8764
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-prs-not-shown-in-panel

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 1, 2026

PRs disappear from the panel when the workspace folder is a manually-created git worktree (e.g. git worktree add -b feature-foo <path> origin/develop). Repo discovery is actually fine — VS Code's git extension follows the .git pointer → commondir chain correctly — but two bugs in PR matching cause the active PR to resolve to the wrong (closed) PR and clear the panel.

getUpstreamUrlAndName uses upstream name as PR head ref

git worktree add -b feature-foo <path> origin/develop sets:

branch.feature-foo.remote = origin
branch.feature-foo.merge  = refs/heads/develop

So branch.upstream.name === "develop", and the extension was querying GitHub with headRefName: "develop" — matching an unrelated closed PR rather than the open PR for feature-foo. The fix prefers the local branch name when it differs from the tracked upstream, since that is what git push uses by default and what GitHub's headRefName will be:

const upstreamBranchName = (branch.name && branch.upstream.name !== branch.name)
    ? branch.name
    : branch.upstream.name;

getMatchingPullRequestMetadataForBranch sort order

The duplicate-entry handling added in #8063 used (a, b) => b.value < a.value ? 1 : -1, which sorts ascending, so it always returned the oldest PR association instead of the most recent. Lexicographic comparison of owner#name#5 vs owner#name#42 is also wrong across digit counts. Now parses the trailing PR number and sorts numerically descending.

Other

  • Unit test in pullRequestGitHelper.test.ts covering the duplicate-config-entry case.
  • Replaced two pre-existing em-dashes in vscode.proposed.chatSessionsProvider.d.ts with hyphens to unblock the hygiene pre-commit hook.

Copilot AI and others added 2 commits June 1, 2026 13:27
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with PRs not shown in panel for manually-created worktree Fix wrong PR matched for worktree branches with cross-branch upstream Jun 1, 2026
Copilot AI requested a review from alexr00 June 1, 2026 13:33
@alexr00 alexr00 marked this pull request as ready for review June 3, 2026 12:59
Copilot AI review requested due to automatic review settings June 3, 2026 12:59
@alexr00 alexr00 enabled auto-merge (squash) June 3, 2026 12:59
@alexr00 alexr00 changed the title Fix wrong PR matched for worktree branches with cross-branch upstream Fix sorting of duplicate git configs Jun 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 addresses incorrect pull request association in certain Git configurations by improving how branch→PR metadata is selected when duplicate git config entries exist, and adds/updates tests and vendored proposed VS Code API typings.

Changes:

  • Fix getMatchingPullRequestMetadataForBranch to prefer the most recent PR association when multiple metadata entries exist for the same branch.
  • Add a unit test covering the duplicate-config-entry scenario.
  • Update proposed VS Code chat API .d.ts files (new properties/interfaces).
Show a summary per file
File Description
src/github/pullRequestGitHelper.ts Updates selection logic for branch-associated PR metadata when duplicate config entries exist.
src/test/github/pullRequestGitHelper.test.ts Adds a unit test ensuring the highest PR number is preferred when duplicates exist.
src/@types/vscode.proposed.chatSessionsProvider.d.ts Adds new proposed chat session option fields/interfaces.
src/@types/vscode.proposed.chatParticipantPrivate.d.ts Adds proposed quota snapshot types and a chat.updateQuotas API surface.

Copilot's findings

  • Files reviewed: 2/4 changed files
  • Comments generated: 1

Comment thread src/github/pullRequestGitHelper.ts
/**
* A snapshot of quota usage for a single category (chat, completions, premium chat).
*/
export interface ChatQuotaSnapshot {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

are these API changes supposed to be here?

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.

PRs not shown in panel when workspace folder is a manually-created git worktree

4 participants