Fix PR created on GitHub website not linked to local branch#8665
Draft
Fix PR created on GitHub website not linked to local branch#8665
Conversation
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
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.
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 viaassociateBranchWithPullRequest(), but the local PR tree cache inPrsTreeModelis never invalidated afterward, so the tree never picks up the newly-associated branch.Planned changes (analysis complete, implementation not yet landed)
PrsTreeModelcache invalidation: In theonDidChangeActivePullRequesthandler, detect when the new active PR is absent from the local PR cache, clear thePRType.LocalPullRequestcache entry, and fireonDidChangeData(manager)to trigger a full category refresh viarefreshRepo()instead of the narrowrefreshPullRequests()pathFolderRepositoryManager.getLocalPullRequests()fallback: For the current HEAD branch, if it has an upstream but no PR metadata, query GitHub viagetPullRequestForBranch()and associate on hit — this is a single API call that makes the tree immediately correct without waiting forvalidateState()to complete