Refresh Package Manager UI when it becomes visible again (2nd try)#7430
Merged
Conversation
nkolev92
previously approved these changes
May 29, 2026
Member
nkolev92
left a comment
There was a problem hiding this comment.
I'd change the name, but seems fine other than that.
nkolev92
approved these changes
Jun 2, 2026
donnie-msft
reviewed
Jun 2, 2026
donnie-msft
approved these changes
Jun 3, 2026
Contributor
donnie-msft
left a comment
There was a problem hiding this comment.
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.
This was referenced Jun 3, 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#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
Loadedevent to refresh on return.Loadedonly 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
.csprojon 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