Fix PR created on GitHub website not linked to local branch#8665
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 <[email protected]>
When a PR is created on the GitHub website (not via VS Code UI), the ReviewManager discovers it via checkGitHubForPrBranch() and associates the local branch with the PR. However, the local PR tree cache in PrsTreeModel was never invalidated afterward, so the "Local Pull Request Branches" category never showed the newly-associated branch. Fix: In PrsTreeModel's onDidChangeActivePullRequest handler, when the new active PR is not already in the cached PR set, delete the LocalPullRequest cache entry and fire a full folder refresh (which triggers refreshRepo() in the tree data provider) instead of the narrow PR-level refresh (which only updates existing PR nodes via refreshPullRequests()). Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/a016c47c-ed2e-432f-b461-f678d8ab62c8 Co-authored-by: alexr00 <[email protected]>
Implemented the fix in commit a84a532. In |
Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/001ddef0-6d36-4dcc-96f7-ed3f3d2901e5 Co-authored-by: alexr00 <[email protected]>
When a PR is created on the GitHub website (not via VS Code UI), the local branch has no git config metadata (branch.<name>.github-pr-owner-number) since associateBranchWithPullRequest was never called. For the current HEAD branch, if it has an upstream but no PR metadata, query GitHub via getMatchingPullRequestMetadataFromGitHub() and write the git config metadata via associateBranchWithPullRequest(). This is a single API call that makes the local PR tree immediately correct. Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/001ddef0-6d36-4dcc-96f7-ed3f3d2901e5 Co-authored-by: alexr00 <[email protected]>
Reverted the PrsTreeModel cache approach and moved the fix to Now, for the current HEAD branch, if it has an upstream but no PR metadata in git config, we query GitHub via |
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. For branches where the PR was created on the GitHub website, this metadata is never written, so the branch is never included in the local PR list.Change
FolderRepositoryManager.getLocalPullRequests()fallback: After the main metadata-based loop, for the current HEAD branch, if it has an upstream but wasn't found in the results (no PR metadata in git config), query GitHub viagetMatchingPullRequestMetadataFromGitHub()to find an associated PR. On a match, write the git config metadata viaassociateBranchWithPullRequest()so subsequent calls find it directly, and include the PR in the returned results. This is a single API call that makes the local PR tree immediately correct.