-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Add the Command Palette module #37908
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
Conversation
This adds a magic helper to load icons for us. Any time you want an icon, just do this:
```xaml
<Border Width="16"
Height="16"
Margin="4,4,4,4">
<Interactivity:Interaction.Behaviors>
<cmdpalUI:LoadIconBehavior Source="{x:Bind ViewModel.PrimaryAction.Icon, Mode=OneWay}"/>
</Interactivity:Interaction.Behaviors>
</Border>
```
And that'll magically give us a border filled with the icon, and updating with the binding.
I believe it'll also work with `IRandomAccessStreamReference`s, but I didn't actually test that with #151 yet.
I didn't actually implement the "caching" bit of this yet. That'll involve doing some locking per-key inside the factory and I didn't want to futz with that in this initial PR to restore icons
---------
Co-authored-by: Mike Griese <[email protected]>
…sions-on-close Ref #73. What it says on the tin. Terminate extensions when the main window closes.
…l object so even if we create a new wrapper we'll compare it against what it actually contains.
Just some minor clean-up/perf things I was trying, doesn't actually fix anything though, unfortunately (outside of maybe making startup a bit faster)... Does NOT fix #213 We were effectively getting called to load images twice in a few spots, and we were trying to load them everywhere at startup. This minimized that in a few places, but we can't use x:Phase in the DataTemplate for the List Items (as it needs a UIElement), so that caused some issues. I thought I had a fix for all the duplicate items loading on the home page, but alas no. Have to continue digging into that, but got side-tracked by the above.
This allows extension objects to write error messages specifically to the page that owns them. We don't need the `ShowExceptionMessage` anymore, because that just tossed the error at whatever page was open (even if it wasn't the page that had an error). I also made this a `IPageContext`, rather than `IErrorContext`, so we could pass the page's task scheduler to that object too. That lets us have one base `UpdateProperties` implementation for all extension objects. I think this sneakily also adds support for `Page.Title` (separate from `Page.Name`) Closes #203
…t rebuild every launch
…w an exception, that makes sense
Replaces PR #218 IconBox is a custom control that's a ContentControl, it's generic (toolkitable) and should be able to be styled and templated. It knows how to take an IconSource and create the underlying IconElement as its content. It can also take any general value as a `SourceKey` and via an implementation of the SourceRequested event, translate a bound general object into the `IconSource` required. This is how caching can be provided by an application as well, for instance (like we'll do here). This uses the deferred events pattern to await the call to the `SourceRequested` event which may need to load data asynchronously We create a static x:Bind helper `IconCacheProvider` to encapsulate our shared logic for our eventual Icon cache. Renamed IconCacheService.xaml.cs -> IconCacheService.cs Removed old broken behavior (believe ultimate issue was due to instability in loaded/unloaded events, i.e. issue microsoft/microsoft-ui-xaml#1900) XAML Styler also did its thing...
Fixes #213 Replaces PR #218 FYI @Ryken100 (thanks for the info and assist in debugging the issue and discussing possible avenues of resolution) Thanks @zadjii-msft for validating the end path in #218 Before: ```xml <Border x:Name="IconBorder" Grid.Column="0" Width="16" Height="16" Margin="0,0,0,0"> <!-- LoadIconBehavior will magically fill this border up with an icon --> <Interactivity:Interaction.Behaviors> <cmdpalUI:LoadIconBehavior Source="{x:Bind Icon, Mode=OneWay}"/> </Interactivity:Interaction.Behaviors> </Border> ``` After: ```xml <cpcontrols:IconBox Grid.Column="0" Width="16" Height="16" Margin="0,0,0,0" SourceKey="{x:Bind Icon, Mode=OneWay}" SourceRequested="{x:Bind help:IconCacheProvider.SourceRequested}" /> ``` The IconCacheProvider is the translation layer between having a light-weight control and our specific app's logic/desire for an icon cache, using the deferred event pattern: ```cs public static partial class IconCacheProvider { private static readonly IconCacheService IconService = new(Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread()); public static async void SourceRequested(IconBox sender, SourceRequestedEventArgs args) { if (args.Key == null) { return; } if (args.Key is IconDataType iconData) { var deferral = args.GetDeferral(); args.Value = await IconService.GetIconSource(iconData); deferral.Complete(); } } } ``` ## Details `IconBox` is a custom control that's a ContentControl, its generic (toolkitable) and should be able to be styled and templated (haven't tested, but no reason it shouldn't as a XAML `ContentControl`, should help @niels9001 a ton). It knows how to take an `IconSource` and create the underlying `IconElement` as its content. It can also take any general value as a `SourceKey` and via an implementation of the `SourceRequested` event, translate a bound general object into the `IconSource` required. This is how caching can be provided by an application as well, for instance (like we'll do here). This uses the deferred events pattern to await the call to the `SourceRequested` event which may need to load data asynchronously We create a static x:Bind helper `IconCacheProvider` to encapsulate our shared logic for our eventual Icon cache. Also: - Renamed IconCacheService.xaml.cs -> IconCacheService.cs - Removed old broken behavior (believe ultimate issue was due to instability in loaded/unloaded events, i.e. issue microsoft/microsoft-ui-xaml#1900) - XAML Styler also did its thing... (some conflict here in config from PowerToys to resolve later, imagine this is also a consequence of us not having CI setup in fork...)
* Localize CmdPal settings page * Xaml format * Fix it Follow up to #37908
Adds a command line arg to not show CmdPal on startup. When starting from PT Run, we won't immediately show the window. as noted in #37908
* [settings] Show CmdPal shortcut * show in dashboard as well   As noted in #37908
Related to #37908 Closes zadjii-msft#520 --------- Co-authored-by: Mike Griese <[email protected]>
Windows Command Palette ("CmdPal") is the next iteration of PowerToys Run. With extensibility at its core, the Command Palette is your one-stop launcher to start _anything_.
By default, CmdPal is bound to <kbd>Win+Alt+Space</kbd>.


----
This brings the current preview version of CmdPal into the upstream PowerToys repo. There are still lots of bugs to work out, but it's reached the state we're ready to start sharing it with the world. From here, we can further collaborate with the community on the features that are important, and ensuring that we've got a most robust API to enable developers to build whatever extensions they want.
Most of the built-in PT Run modules have already been ported to CmdPal's extension API. Those include:
* Installed apps
* Shell commands
* File search (powered by the indexer)
* Windows Registry search
* Web search
* Windows Terminal Profiles
* Windows Services
* Windows settings
There are a couple new extensions built-in
* You can now search for packages on `winget` and install them right from the palette. This also powers searching for extensions for the palette
* The calculator has an entirely new implementation. This is currently less feature complete than the original PT Run one - we're looking forward to updating it to be more complete for future ingestion in Windows
* "Bookmarks" allow you to save shortcuts to files, folders, and webpages as top-level commands in the palette.
We've got a bunch of other samples too, in this repo and elsewhere
CmdPal will eventually graduate out of PowerToys to live as its own application, which is why it's implemented just a little differently than most other modules. Enabling CmdPal will install its `msix` package.
The CI was minorly changed to support CmdPal version numbers independent of PowerToys itself. It doesn't make sense for us to start CmdPal at v0.90, and in the future, we want to be able to rev CmdPal independently of PT itself.
Closes microsoft#3200, closes microsoft#3600, closes microsoft#7770, closes microsoft#34273, closes microsoft#36471, closes microsoft#20976, closes microsoft#14495
-----
TODOs et al
**Blocking:**
- [ ] Images and descriptions in Settings and OOBE need to be properly defined, as mentioned before
- [ ] Niels is on it
- [x] Doesn't start properly from PowerToys unless the fix PR is merged.
- zadjii-msft#556 merged
- [x] I seem to lose focus a lot when I press on some limits, like between the search bar and the results.
- This is zadjii-msft#427
- [x] Turned off an extension like Calculator and it was still working.
- Need to get rid of that toggle, it doesn't do anything currently
- [x] `ListViewModel.<FetchItems>` crash
- Pretty confident that was fixed in zadjii-msft#553
**Not blocking / improvements:**
- Show the shortcut through settings, as mentioned before, or create a button that would open CmdPalette settings.
- When PowerToys starts, CmdPalette is always shown if enabled. That's weird when just starting PowerToys/ logging in to the computer with PowerToys auto-start activated. I think this should at least be a setting.
- Needing to double press a result for it to do the default action seems quirky. If one is already selected, I think just pressing should be enough for it to do the action.
- This is currently a setting, though we're thinking of changing the setting even more: zadjii-msft#392
- There's no URI extension. Was surprised when typing a URL that it only proposed a web search.
- [x] There's no System commands extension. Was expecting to be able to quickly restart the computer by typing restart but it wasn't there.
- This is in PR zadjii-msft#452
---------
Co-authored-by: joadoumie <[email protected]>
Co-authored-by: Jordi Adoumie <[email protected]>
Co-authored-by: Mike Griese <[email protected]>
Co-authored-by: Niels Laute <[email protected]>
Co-authored-by: Michael Hawker <[email protected]>
Co-authored-by: Stefan Markovic <[email protected]>
Co-authored-by: Seraphima <[email protected]>
Co-authored-by: Jaime Bernardo <[email protected]>
Co-authored-by: Kristen Schau <[email protected]>
Co-authored-by: Eric Johnson <[email protected]>
Co-authored-by: Ethan Fang <[email protected]>
Co-authored-by: Yu Leng (from Dev Box) <[email protected]>
Co-authored-by: Clint Rutkas <[email protected]>
* Localize CmdPal settings page * Xaml format * Fix it Follow up to microsoft#37908
Adds a command line arg to not show CmdPal on startup. When starting from PT Run, we won't immediately show the window. as noted in microsoft#37908
* [settings] Show CmdPal shortcut * show in dashboard as well   As noted in microsoft#37908
Related to microsoft#37908 Closes zadjii-msft#520 --------- Co-authored-by: Mike Griese <[email protected]>
|
is that |
|
oh my gawd i never pushed that anywhere I can push the code. I never shipped it because I think I still have a bug in it around how often it tried to refresh the status. But I can put the code out there. OSS is life |
|
that woold be awesome. hit me with the link when u push Also a question, Do u consider opening CmdPal Extension ecosystem to more codding or scripting languages like PowerShell or Typescript. Although that's maybe a lot of work at the moment. But a PowerShell or a TypeScript Extension will be Crushing and will Open a lot of capabilities and use case considering there large ecosystem and community. And the main reason for this request is that not every one can learn C# that easily considering it's not an easy lang or it's learning curve, and all the frameworks that may come with and limiting the need to a 20+GB to Run Visual Studio. But ps1 or ts on the other hand known to be easy to learn and work with, can be tested on the fly and can be codded on VScode more lightweight that VS. if this feature get added just forget the app, came after a week and u will find like a 1k new extensions added. That will get rid of any competitor outthere. |
|
For sure. There's much more envisioned here. #38273 has a bit of a diagram of my mental map here. Though, I think you're really looking for the rightmost entry on that diagram, which I apparently don't have filed anywhere good? We should also probably validate that these extensions can just be built with the dotnet CLI. I know that I've used that in the past to build them for release, but I haven't really worked much on the "inner loop" for them. That's certainly a lot lighter than all of big VS. |
I'm also interested in that extension, have you published it anywhere yet? That was one of the biggest reasons I started using the Command Palette, the first being the calculator. |
Windows Command Palette ("CmdPal") is the next iteration of PowerToys Run. With extensibility at its core, the Command Palette is your one-stop launcher to start _anything_.
By default, CmdPal is bound to <kbd>Win+Alt+Space</kbd>.


----
This brings the current preview version of CmdPal into the upstream PowerToys repo. There are still lots of bugs to work out, but it's reached the state we're ready to start sharing it with the world. From here, we can further collaborate with the community on the features that are important, and ensuring that we've got a most robust API to enable developers to build whatever extensions they want.
Most of the built-in PT Run modules have already been ported to CmdPal's extension API. Those include:
* Installed apps
* Shell commands
* File search (powered by the indexer)
* Windows Registry search
* Web search
* Windows Terminal Profiles
* Windows Services
* Windows settings
There are a couple new extensions built-in
* You can now search for packages on `winget` and install them right from the palette. This also powers searching for extensions for the palette
* The calculator has an entirely new implementation. This is currently less feature complete than the original PT Run one - we're looking forward to updating it to be more complete for future ingestion in Windows
* "Bookmarks" allow you to save shortcuts to files, folders, and webpages as top-level commands in the palette.
We've got a bunch of other samples too, in this repo and elsewhere
### PowerToys specific notes
CmdPal will eventually graduate out of PowerToys to live as its own application, which is why it's implemented just a little differently than most other modules. Enabling CmdPal will install its `msix` package.
The CI was minorly changed to support CmdPal version numbers independent of PowerToys itself. It doesn't make sense for us to start CmdPal at v0.90, and in the future, we want to be able to rev CmdPal independently of PT itself.
Closes microsoft#3200, closes microsoft#3600, closes microsoft#7770, closes microsoft#34273, closes microsoft#36471, closes microsoft#20976, closes microsoft#14495
-----
TODOs et al
**Blocking:**
- [ ] Images and descriptions in Settings and OOBE need to be properly defined, as mentioned before
- [ ] Niels is on it
- [x] Doesn't start properly from PowerToys unless the fix PR is merged.
- zadjii-msft#556 merged
- [x] I seem to lose focus a lot when I press on some limits, like between the search bar and the results.
- This is zadjii-msft#427
- [x] Turned off an extension like Calculator and it was still working.
- Need to get rid of that toggle, it doesn't do anything currently
- [x] `ListViewModel.<FetchItems>` crash
- Pretty confident that was fixed in zadjii-msft#553
**Not blocking / improvements:**
- Show the shortcut through settings, as mentioned before, or create a button that would open CmdPalette settings.
- When PowerToys starts, CmdPalette is always shown if enabled. That's weird when just starting PowerToys/ logging in to the computer with PowerToys auto-start activated. I think this should at least be a setting.
- Needing to double press a result for it to do the default action seems quirky. If one is already selected, I think just pressing should be enough for it to do the action.
- This is currently a setting, though we're thinking of changing the setting even more: zadjii-msft#392
- There's no URI extension. Was surprised when typing a URL that it only proposed a web search.
- [x] There's no System commands extension. Was expecting to be able to quickly restart the computer by typing restart but it wasn't there.
- This is in PR zadjii-msft#452
---------
Co-authored-by: joadoumie <[email protected]>
Co-authored-by: Jordi Adoumie <[email protected]>
Co-authored-by: Mike Griese <[email protected]>
Co-authored-by: Niels Laute <[email protected]>
Co-authored-by: Michael Hawker <[email protected]>
Co-authored-by: Stefan Markovic <[email protected]>
Co-authored-by: Seraphima <[email protected]>
Co-authored-by: Jaime Bernardo <[email protected]>
Co-authored-by: Kristen Schau <[email protected]>
Co-authored-by: Eric Johnson <[email protected]>
Co-authored-by: Ethan Fang <[email protected]>
Co-authored-by: Yu Leng (from Dev Box) <[email protected]>
Co-authored-by: Clint Rutkas <[email protected]>
* Localize CmdPal settings page * Xaml format * Fix it Follow up to microsoft#37908
Adds a command line arg to not show CmdPal on startup. When starting from PT Run, we won't immediately show the window. as noted in microsoft#37908
* [settings] Show CmdPal shortcut * show in dashboard as well   As noted in microsoft#37908
Related to microsoft#37908 Closes zadjii-msft#520 --------- Co-authored-by: Mike Griese <[email protected]>
@zadjii-msft Any chance you can push this somewhere? |
Is it this one? @Stevoni |
@yeelam-gordon I don't think so? I think the extension you linked is the "GitHub Extension" at the top of this screenshot and we're looking for the "Git for CmdPal" at the bottom |
unfortunately No! The |
|
Sorry for the delays @benzaria and @Stevoni. Personal life stuff got in the way. I pushed the source for the git extension over here: https://github.com/zadjii/GitForCmdPal It's really rough. It was a hackathon project, and I never quite got it ready to ship. But if people want to contribute and help polish it off, I'm more than willing to review PRs. |

Windows Command Palette ("CmdPal") is the next iteration of PowerToys Run. With extensibility at its core, the Command Palette is your one-stop launcher to start anything.
By default, CmdPal is bound to Win+Alt+Space.
This brings the current preview version of CmdPal into the upstream PowerToys repo. There are still lots of bugs to work out, but it's reached the state we're ready to start sharing it with the world. From here, we can further collaborate with the community on the features that are important, and ensuring that we've got a most robust API to enable developers to build whatever extensions they want.
Most of the built-in PT Run modules have already been ported to CmdPal's extension API. Those include:
There are a couple new extensions built-in
wingetand install them right from the palette. This also powers searching for extensions for the paletteWe've got a bunch of other samples too, in this repo and elsewhere
PowerToys specific notes
CmdPal will eventually graduate out of PowerToys to live as its own application, which is why it's implemented just a little differently than most other modules. Enabling CmdPal will install its
msixpackage.The CI was minorly changed to support CmdPal version numbers independent of PowerToys itself. It doesn't make sense for us to start CmdPal at v0.90, and in the future, we want to be able to rev CmdPal independently of PT itself.
Closes #3200, closes #3600, closes #7770, closes #34273, closes #36471, closes #20976, closes #14495
TODOs et al
Blocking:
ListViewModel.<FetchItems>crashNot blocking / improvements:
Co-authored-by: joadoumie [email protected]
Co-authored-by: Jordi Adoumie [email protected]
Co-authored-by: Mike Griese [email protected]
Co-authored-by: Niels Laute [email protected]
Co-authored-by: Michael Hawker [email protected]
Co-authored-by: Stefan Markovic [email protected]
Co-authored-by: Seraphima [email protected]
Co-authored-by: Jaime Bernardo [email protected]
Co-authored-by: Kristen Schau [email protected]
Co-authored-by: Eric Johnson [email protected]
Co-authored-by: Ethan Fang [email protected]
Co-authored-by: Clint Rutkas [email protected]