Skip to content

Fix stale Browse tab details pane after installing a package with Package Source Mapping enabled#7441

Open
martinrrm wants to merge 1 commit into
devfrom
dev-mruizmares-fixPmuiRefresh
Open

Fix stale Browse tab details pane after installing a package with Package Source Mapping enabled#7441
martinrrm wants to merge 1 commit into
devfrom
dev-mruizmares-fixPmuiRefresh

Conversation

@martinrrm
Copy link
Copy Markdown
Contributor

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:

  1. ConfigureNewPackageSourceMappings(...) saves the mapping, which raises
    ISettings.SettingsChanged synchronously — before the install runs.
  2. ExecuteActionsAsync(...) actually installs the package.
  3. RaiseProjectActionsExecuted(...) triggers the normal post-install refresh.

PR #7022 ("Audit Sources Changed event triggers Package Manager UI to refresh") changed Settings_SettingsChanged to kick off a fire-and-forget package search via RefreshAfterSettingsChanged. 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 = true instead of starting an immediate search. The ExecuteAction completion path already performs a full RefreshAsync(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 / _isRefreshRequired deferral pattern already used by the other refresh paths.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • [ ] Added tests PM UI change, hard to test
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

…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>
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.

[Bug Bash] The status of the new installed package which doesn’t match the package pattern was shown incorrectly in ‘Browse’ tab

3 participants