Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We never hooked up the extension change event #370

Closed
zadjii-msft opened this issue Jan 26, 2025 · 1 comment · Fixed by #375
Closed

We never hooked up the extension change event #370

zadjii-msft opened this issue Jan 26, 2025 · 1 comment · Fixed by #375
Labels
Area-HostUX UX elements of the host CmdPal application Issue-Bug Something isn't working

Comments

@zadjii-msft
Copy link
Owner

IExtensionService.OnExtensionsChanged needs to be listened to in TopLevelCommandManager, to reload the list of commands as apps get installed

@zadjii-msft zadjii-msft added Area-HostUX UX elements of the host CmdPal application Issue-Bug Something isn't working labels Jan 26, 2025
zadjii-msft added a commit that referenced this issue Jan 27, 2025
Tested with the `command-line` tag, because there's no extensions in winget until microsoft/winget-pkgs#216685 merges

Also adds a link to search in the Store, though I think that won't be as useful. 

Lastly - also actually fixes the tag search 😅

Builds on #356
Closes #89
Probably needs #370 to feel right
@zadjii-msft
Copy link
Owner Author

Oh actually this is not trivial.

The DevHome code was very imprecise about this stuff. It just raised a generic OnPackageChange for an install, update, or uninstall. We can't just wire that into "Reload extensions", because we don't want an install terminating all the other extensions.

uhg.

zadjii-msft added a commit that referenced this issue Jan 28, 2025
Closes #370 

The DevHome code was great for "I need something that can lookup extensions and enumerate all of them".

However, the DevHome code is a very blunt hammer when it comes to extensions. The only thing it tracks is "packages changed", and if it gets one of those, it just blows away all the extensions and rebuilds them. Yikes. 

This PR changes `ExtensionService` to be a scalpel. We'll keep `_installedExtensions` fresh. When we get a package install, we'll add only that package's extension to our cache, and let the `TopLevelCommandManager` know. Similarly for updates and uninstalls. 

That way, we can exactly change the top-level list as needed, rather than bluntly forcing all the extensions to reload. 

In the middle of all this, I fixed a bug where uninstalling an extension, then reloading would just fail to load extensions. This is because the old code would clear out the **whole** list of extensions when _one_ was uninstalled. That created a race where we'd be parsing the new list of all the extensions (from the reload), get an uninstall event, clear the list, then InvalidOperation as the list of extensions was modified during enumeration. 

There's a bunch more locking in here. This might drive-by #324 but hard to be sure. 

Related to #89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-HostUX UX elements of the host CmdPal application Issue-Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant