Skip to content

Fix PR created on GitHub website not linked to local branch#8665

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-pr-branch-recognition
Draft

Fix PR created on GitHub website not linked to local branch#8665
Copilot wants to merge 2 commits intomainfrom
copilot/fix-pr-branch-recognition

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

When a PR is created on the GitHub website (not via VS Code UI), the local branch is not recognized under "Local Pull Request Branches" — it only appears under "Created by me". This prevents applying suggestions and viewing inline comments on the local copy.

Root cause: getLocalPullRequests() only checks git config metadata (branch.<name>.github-pr-owner-number), which is only written when the PR is created or checked out through the extension. ReviewManager.validateState() does discover the PR via GitHub API and writes the metadata via associateBranchWithPullRequest(), but the local PR tree cache in PrsTreeModel is never invalidated afterward, so the tree never picks up the newly-associated branch.

Planned changes (analysis complete, implementation not yet landed)

  • PrsTreeModel cache invalidation: In the onDidChangeActivePullRequest handler, detect when the new active PR is absent from the local PR cache, clear the PRType.LocalPullRequest cache entry, and fire onDidChangeData(manager) to trigger a full category refresh via refreshRepo() instead of the narrow refreshPullRequests() path
  • FolderRepositoryManager.getLocalPullRequests() fallback: For the current HEAD branch, if it has an upstream but no PR metadata, query GitHub via getPullRequestForBranch() and associate on hit — this is a single API call that makes the tree immediately correct without waiting for validateState() to complete

Note: This PR contains the analysis and plan only. The code changes described above still need to be implemented.

Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/bb36d2e5-e24d-4ab1-a80a-db9e9f8744f0

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with PR not linking to existing branch Fix PR created on GitHub website not linked to local branch Apr 14, 2026
Copilot AI requested a review from alexr00 April 14, 2026 11:03
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.

PR made without the UI is not linked to the existing branch

2 participants