Fix stale Browse tab details pane after installing a package with Package Source Mapping enabled#7441
Open
martinrrm wants to merge 1 commit into
Open
Fix stale Browse tab details pane after installing a package with Package Source Mapping enabled#7441martinrrm wants to merge 1 commit into
martinrrm wants to merge 1 commit into
Conversation
…kage Source Mapping enabled When Package Source Mapping is enabled and an installed package needs a new mapping, NuGet auto-creates one. That mapping is saved (raising SettingsChanged) before the package changes are applied. PR #7022 made Settings_SettingsChanged start a fire-and-forget refresh, which during install reads pre-install state and races the post-install refresh, leaving the details pane stale (Install dropdown still shown). Defer the settings-changed refresh while an action is executing; the action completion already performs a full refresh. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
nkolev92
approved these changes
Jun 2, 2026
Nigusu-Allehu
approved these changes
Jun 2, 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.
Bug
Fixes: NuGet/Home#14923
Description
When Package Source Mapping is enabled and you install a package in the Browse tab that does not match any existing mapping pattern, the details pane stays stale after the install completes: it keeps showing the Install version dropdown as if the package were not installed. The correct status only appears after a second package action ("delayed by one"). Without source mapping, the UI refreshes correctly.
Root cause (a regression)
Installing a package that needs a new mapping causes NuGet to auto-create one. In
UIActionEngine, that mapping is saved before the package changes are applied:ConfigureNewPackageSourceMappings(...)saves the mapping, which raisesISettings.SettingsChangedsynchronously — before the install runs.ExecuteActionsAsync(...)actually installs the package.RaiseProjectActionsExecuted(...)triggers the normal post-install refresh.PR #7022 ("Audit Sources Changed event triggers Package Manager UI to refresh") changed
Settings_SettingsChangedto kick off a fire-and-forget package search viaRefreshAfterSettingsChanged. As a side effect, during an install-with-auto-mapping that search now runs at step 1 — reading pre-install state — and, being async, can complete after the correct post-install refresh, overwriting it with the stale "not installed" state. This regressed behavior that worked in 6.14.3 (where the settings-changed handler did not search).Fix
In
Settings_SettingsChanged, when an action is already executing, defer the refresh by setting_isRefreshRequired = trueinstead of starting an immediate search. TheExecuteActioncompletion path already performs a fullRefreshAsync(clearCache: true)that refreshes both the package list and the details pane with the correct post-install state. Standalone settings changes (audit sources, user-toggled mappings) still refresh immediately because no action is executing — preserving the behavior added in #7022.The change is minimal, additive, and guarded, reusing the existing
_isExecutingAction/_isRefreshRequireddeferral pattern already used by the other refresh paths.PR Checklist
[ ] Added testsPM UI change, hard to test