Skip to content

fix: scope PR content lookup to its repository - #9190

Open
Alex Castillo González (pcbeingused333) wants to merge 3 commits into
microsoft:mainfrom
pcbeingused333:fix/c2810-multi-repo-pr-content
Open

Alex Castillo González (pcbeingused333) wants to merge 3 commits into
microsoft:mainfrom
pcbeingused333:fix/c2810-multi-repo-pr-content

Conversation

@pcbeingused333

@pcbeingused333 Alex Castillo González (pcbeingused333) commented Nov 12, 2026 •

Copy link
Copy Markdown

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

Copilot AI balanced review requested due to automatic review settings November 12, 2026 19:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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

Comment thread src/view/inMemPRContentProvider.ts Resolved
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);
@pcbeingused333

Copy link
Copy Markdown
Author

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.
Copilot AI balanced review requested due to automatic review settings November 29, 2026 04:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the repository-selection and content-provider isolation changes.

1 open issue
1 resolved since last review

Review effort: Balanced

@pcbeingused333

Copy link
Copy Markdown
Author

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.

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.

Multi-root workspace: PRs resolved by number + remote name only, so "Open Changes" loads the wrong repo's PR (empty diffs)

2 participants