← 输入框|github.com|刷新
Skip to content

Clear cached PR file changes when the base branch changes - #9150

Draft
Alex Ross (alexr00) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-pr-file-list-base
Draft

Alex Ross (alexr00) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-pr-file-list-base

Conversation

Copilot AI commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

If a PR's base branch is changed outside VS Code (e.g. gh pr edit --base), Refresh still shows its files compared against the old base. Only a window reload fixes it.

Refresh updates the existing PullRequestModel in place through createOrUpdatePullRequestModel() → update(). doUpdate() stored the new base but kept _fileChanges and _rawFileChangesCache, which were computed against the old base. These callers reuse the cache whenever it's non-empty:

  • getChangeModels()
  • PRNode.resolveFileChangeNodes() for the checked-out PR
  • the PR overview and the LM context provider, through rawFileChanges ?? getRawFileChangesInfo()

Changes

  • PullRequestModel.doUpdate(): when the base ref or sha changes (the existing changes.base check), clear both caches so the next read fetches the files again against the new base. The showChangesSinceReview setter already clears _fileChanges the same way.

    if (this.base && item.base && (this.base.ref !== item.base.ref || this.base.sha !== item.base.sha)) {
    	changes.base = true;
    	// The cached file changes were compared against the old base.
    	this._fileChanges.clear();
    	this._rawFileChangesCache = undefined;
    }
  • Test (pullRequestModel.test.ts): loads a PR's files against the old base (old.ts deleted, new.ts added), updates the base, and asserts that getChangeModels() now returns a single rename and that mergeBase is the new base sha.

Not changed, for reviewers

  • Head changes don't clear the cache. The issue is only about the base, and an empty fileChanges changes reviewManager's focus behavior: when it's empty, the description opens instead of the changed files.
  • mergeBase isn't cleared. createReviewCommentThread needs it for the active PR, and getRawFileChangesInfo() recomputes it on every fetch.
  • createConflictResolutionModel / getUpdateBranchFiles read fileChanges without loading it first, which was already the case. If the cache is empty, update-branch fails with "no resolutions provided" and nothing is lost.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix PR file list keeps old base after branch change Clear cached PR file changes when the base branch changes Nov 2, 2026
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 file list keeps the old base after the base branch changes outside VS Code

2 participants