Repository navigation
fix: scope PR content lookup to its repository - #9190
Alex Castillo González (pcbeingused333) wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Provider lookup can fail after remote URL normalization or select the wrong repository for nested paths, producing empty or unrelated PR diffs.
2 open issues
What changed in this PR
This PR addresses #9179 by making “Open Changes” resolve PR content within the correct repository in multi-root workspaces. Reload restoration and the approve/resolve behavior in #8969 remain outside its scope.
Changes:
- Select repository folders by PR document path rather than shared remote names.
- Key content providers by remote URL and PR number, with registration-scoped disposal.
- Add multi-root regression coverage and adapt existing provider registrations.
| File | Description |
|---|---|
src/view/treeNodes/pullRequestNode.ts |
Pass the PR model when registering content providers. |
src/view/reviewManager.ts |
Update review content registration to pass the PR model. |
src/view/inMemPRContentProvider.ts |
Scope provider keys and lookup by repository; guard disposal. |
src/test/view/submoduleChanges.test.ts |
Adapt fixtures and registrations to the new signature. |
src/test/view/inMemPRContentProvider.test.ts |
Test independent reads and disposal for equal PR numbers. |
src/test/github/repositoriesManager.test.ts |
Test path-based selection with shared or missing remote names. |
src/github/repositoriesManager.ts |
Remove remote-name-first selection for PR documents. |
Review effort: Balanced
| private async readFileWithProvider(uri: vscode.Uri, prNumber: number): Promise<Uint8Array | undefined> { | ||
| const provider = this._prFileChangeContentProviders[prNumber]; | ||
| private async readFileWithProvider(uri: vscode.Uri, params: PRUriParams): Promise<Uint8Array | undefined> { | ||
| const repo = this.reposManagers.getManagerForFile(uri)?.findRepo(repo => repo.remote.remoteName === params.remoteName); |
|
Friendly ping: could someone take a look at this when there's time? I'm happy to adjust anything. Thanks! |
Include the repository root in PR URIs so a nested repository no longer claims files of its parent's pull request, and key content providers by root and remote name so a rewritten remote URL cannot orphan them.
|
Both cases are addressed in 45db4a5: provider keys no longer depend on the remote URL, and PR URIs carry the originating repository root so a nested repository cannot claim the parent's files. Each has a regression test. This comment was drafted with Claude Code. |

Fixes #9179 (Open Changes in multi-root workspaces).
PR document lookup selected the first folder with a matching remote name, even when the file belonged to another folder. Content providers were also cached only by PR number, so identically numbered PRs in separate repositories overwrote each other.
PR URIs now carry the root of the repository the pull request was opened from, and that repository is used to resolve the document. This keeps a repository nested inside the parent (for example under a vendored directory) from claiming files of the parent's pull request. When the URI names no open repository, lookup falls back to the document path, preserving it when the named remote is absent.
Content providers are keyed by repository root, remote name and PR number. The remote URL is left out on purpose, since it can be rewritten after a provider is registered (SSH to HTTPS), which would orphan the registration and show empty diffs.
Regression coverage exercises two folders whose remotes are both named
origin, a sibling path with the same prefix, a missing remote name, independent reads and disposal for the same PR number in two repositories, a remote URL normalized after registration, and a nested repository inside the parent.This addresses Open Changes using the existing PR URI path. Persisted selection and restoration during window reload remain outside this change. Related: #8969; its approve/resolve behavior is outside this change.
Testing
Webpack compilation and TypeScript test compilation pass, and the full extension test suite passes (1374 passing). The nested-repository and URL-normalization regressions fail without the production changes.
This change was prepared with assistance from AI coding agents (OpenAI Codex and Claude Code).
🤖 Generated with Claude Code