Skip to content

Refresh Package Manager UI when it becomes visible again (2nd try)#7430

Merged
martinrrm merged 2 commits into
devfrom
dev-mruizmares-fixPmuiRefreshOnActivated
Jun 3, 2026
Merged

Refresh Package Manager UI when it becomes visible again (2nd try)#7430
martinrrm merged 2 commits into
devfrom
dev-mruizmares-fixPmuiRefreshOnActivated

Conversation

@martinrrm
Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#14761

Description

The Package Manager UI only refreshes its package lists while the control is visible. When it is hidden, change notifications (NuGet cache updates, project changes, and executed project actions) were dropped — the handlers emitted a no-op and relied on the WPF Loaded event to refresh on return. Loaded only fires on the first load and does not re-fire when a hidden document window is re-activated, so the deferred refresh never happened and the UI stayed stale.

This is hit by the "Fix with GitHub Copilot" flow: Copilot opens the .csproj on top of the Package Manager UI (hiding it) and edits it to remediate the vulnerability. The restore that updates the project completes while the UI is hidden, so when the user switches back the Installed/Browse/Updates tabs still show the old state.

This change makes the "refresh when the control becomes visible again" behavior actually work: when a relevant change is observed while the control is hidden, a pending refresh is recorded, and it is applied when the control becomes visible again (deferring as usual if a package action is in progress). The pending refresh preserves the existing per-project applicability filtering so a hidden project-level UI does not refresh for unrelated projects.

This deliberately avoids subscribing to restore-finished events (the approach in #7209, reverted in #7294), which fired in addition to the existing action-completion refresh and caused a double refresh on every install/uninstall.

PR Checklist

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

@martinrrm martinrrm requested a review from a team as a code owner May 29, 2026 17:38
nkolev92
nkolev92 previously approved these changes May 29, 2026
Copy link
Copy Markdown
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

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

I'd change the name, but seems fine other than that.

Comment thread src/NuGet.Clients/NuGet.PackageManagement.UI/Xamls/PackageManagerControl.xaml.cs Outdated
@martinrrm martinrrm requested a review from donnie-msft June 2, 2026 23:26
Copy link
Copy Markdown
Contributor

@donnie-msft donnie-msft left a comment

Choose a reason for hiding this comment

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

Seems safe to me, and here's my thinking:

  • we can monitor any potential impact to ensure it doesn't cause additional unexpected refreshes
  • Everything is on the UI thread
  • At most 1 refresh regardless of number of projects, etc.

@martinrrm martinrrm merged commit 3984256 into dev Jun 3, 2026
17 of 18 checks passed
@martinrrm martinrrm deleted the dev-mruizmares-fixPmuiRefreshOnActivated branch June 3, 2026 00:19
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][Unstable] The ‘Installed’ tab was not refreshed after fixing the NuGet package vulnerabilities with GitHub Copilot

3 participants