CmdPal: Add support for pages with parameters (redux)#47826
Conversation
michaeljolley
left a comment
There was a problem hiding this comment.
PR Review — ParametersPage
Overall the feature design is solid and the UX concept is great. A few issues to flag:
There was a problem hiding this comment.
Pull request overview
This PR introduces a new IParametersPage / ParametersPage experience for Command Palette so extensions can collect lightweight parameter inputs (labels + value runs) directly in the search bar before enabling a final “submit” command. It also adds initial “token search” (ZWSP-delimited) backspace behavior, expands SDK/toolkit surface area for parameter runs, and includes samples + documentation updates.
Changes:
- Add a new Parameters Page type end-to-end (SDK IDL + toolkit helper types + UI page + view models + navigation wiring).
- Update the SearchBar to render parameter “runs” (labels, string inputs, command buttons) instead of only a single TextBox.
- Add samples/docs and wire an optional Actions extension provider behind a feature flag.
Reviewed changes
Copilot reviewed 50 out of 52 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/cmdpal/Microsoft.CmdPal.UI/Styles/TextBox.xaml | Adds themed resources + a dedicated TextBox style for parameter inputs. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs | Routes ParametersPageViewModel navigation to the new ParametersPage. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj | Adds project reference for the Actions extension. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs | Adds a messenger recipient to provide the host HWND on request. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ParametersPage.xaml.cs | New ParametersPage code-behind and ViewModel hookup. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ParametersPage.xaml | New ParametersPage UI (shows selected command details when ready). |
| src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs | Adds parameter-run rendering, token delete behavior, and new focus plumbing. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml | Switches between classic search box vs parameter-runs bar UI. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ParameterRunTemplateSelector.xaml.cs | Template selector for rendering run types in the parameters bar. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs | Registers Actions commands provider when the feature flag is enabled. |
| src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ParametersViewModels.cs | New view models for parameter runs and ParametersPageViewModel. |
| src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/PageViewModel.cs | Treats IParametersPage as a page type with a search surface. |
| src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/FocusParamMessage.cs | New message to request focusing a particular parameter run. |
| src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs | Adds TokenSearch extended attribute support (IsTokenSearch). |
| src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandViewModel.cs | Attempts to refresh extended attributes when they change. |
| src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPalettePageViewModelFactory.cs | Adds factory support for IParametersPage → ParametersPageViewModel. |
| src/modules/cmdpal/Microsoft.CmdPal.Common/Messages/GetHwndMessage.cs | New message type for retrieving the host HWND. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions/Microsoft.CommandPalette.Extensions.idl | Adds SDK contracts for parameter runs + parameters page. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.resx | Adds localized placeholder text for the file picker parameter run. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.Designer.cs | Regenerates strongly-typed resources for new string. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/StringParameterRun.cs | Toolkit implementation for string parameter runs. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/StaticParameterList.cs | Toolkit helper list page for selecting a parameter value. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/SelectParameterCommand.cs | Toolkit invokable command used by StaticParameterList. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/ParameterValueRun.cs | Toolkit base type for value-accepting parameter runs. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/ParametersPage.cs | Toolkit base type for implementing IParametersPage. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/LabelRun.cs | Toolkit implementation for label runs. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/IRequiresHostHwnd.cs | Toolkit interface for commands needing the host HWND. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/FilePickerParameterRun.cs | Toolkit command-parameter implementation backed by FileOpenPicker. |
| src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/CommandParameterRun.cs | Toolkit implementation for command-backed parameter runs. |
| src/modules/cmdpal/ext/SamplePagesExtension/SamplesListPage.cs | Adds new sample entries for parameters pages and prefix suggestions. |
| src/modules/cmdpal/ext/SamplePagesExtension/SamplePagesExtension.csproj | Updates AOT/trim-related settings for the sample extension project. |
| src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleSuggestionsPage.cs | New sample demonstrating ZWSP token search behavior. |
| src/modules/cmdpal/ext/SamplePagesExtension/Pages/ParameterSamples.cs | New sample pages demonstrating parameter-run types. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Microsoft.CmdPal.Ext.Indexer.csproj | Excludes Actions icon from Indexer package (now owned by Actions ext). |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Actions/Pages/ActionsTestPage.cs | Adds an Actions catalog test page and action invocation parameterization. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Actions/Microsoft.CmdPal.Ext.Actions.csproj | New Actions extension project (resources + references). |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Actions/Icons.cs | Adds icon helpers for the Actions extension. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Actions/Assets/Actions.png | Adds Actions icon asset. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Actions/ActionsTest.cs | Adds an Actions extension entry point (test harness). |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Actions/ActionsCommandsProvider.cs | Adds a feature-flagged commands provider for Windows Actions Framework. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Actions/ActionRuntimeManager.cs | Adds lazy initialization/retry wrapper for ActionRuntime creation. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Actions/ActionRuntimeFactory.cs | Adds COM activation helper to create ActionRuntime. |
| src/modules/cmdpal/doc/initial-sdk-spec/drafts/RichSearchBox-draft-A.md | Adds draft notes for rich search exploration. |
| src/modules/cmdpal/doc/initial-sdk-spec/drafts/PrefixSearch-draft-B.md | Adds draft notes for prefix-based search exploration. |
| src/modules/cmdpal/doc/initial-sdk-spec/drafts/PlainRichSearch-draft-C.md | Adds draft notes for ZWSP-token based rich search exploration. |
| src/modules/cmdpal/doc/initial-sdk-spec/drafts/ParametersPage-draft-D.md | Adds draft notes for parameters page concept and API. |
| src/modules/cmdpal/doc/initial-sdk-spec/drafts/DraftB.cs | Adds draft sample code used in documentation exploration. |
| src/modules/cmdpal/CommandPalette.slnf | Adds Actions extension project to the CmdPal solution filter. |
| PowerToys.slnx | Adds Actions extension project to the main solution. |
| doc/devdocs/modules/cmdpal/initial-sdk-spec/initial-sdk-spec.md | Documents the new parameters page API and current token-search status. |
| doc/devdocs/modules/cmdpal/command-pal-anatomy/command-palette-anatomy.md | Minor doc cleanup in the markdown page interface snippet. |
| .github/actions/spell-check/allow/code.txt | Adds allowlisted terms used in new docs/samples. |
Files not reviewed (1)
- src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)
src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs:510
- Focus() synchronously blocks on FocusManager.TryFocusAsync(...).Wait() inside a DispatcherQueue callback. This risks deadlocking/freezing the UI thread because the async focus operation typically completes on the UI thread. Avoid blocking here (e.g., fire-and-forget the async operation, or enqueue an async continuation) and handle any failure without Wait().
private void Focus()
{
this.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
{
if (FocusManager.FindFirstFocusableElement(this) is DependencyObject focusable)
{
FocusManager.TryFocusAsync(focusable, FocusState.Keyboard).Wait();
}
});
src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ParametersViewModels.cs:407
- This PR adds a new ParametersPageViewModel and parameter-run view models with non-trivial behavior (ShowCommand gating via NeedsValue, item updates/cleanup, TrySubmit). There’s existing ViewModels unit test coverage in src/modules/cmdpal/Tests/Microsoft.CmdPal.UI.ViewModels.UnitTests; please add unit tests covering the new parameters-page behaviors (e.g., ShowCommand transitions when a parameter flips NeedsValue, and cleanup of removed runs).
public bool ShowCommand =>
IsInitialized &&
IsLoading == false &&
!NeedsAnyValues()
;
michaeljolley
left a comment
There was a problem hiding this comment.
Really digging this. Can't wait to use it
This PR is stacked on top of #47826 This augments the previous PR to add support for List parameters too. This allows extensions to add parameters where the "command" to select a value is just a `IListPage`. That lets the extension author specify a set of possible values, and let us handle the rendering of that list. The canonical example is the `CreateNoteParametersPage`, in `ParameterSamples.cs`. In that sample, there's a set of possible values for the folder param. The extension exposes that to us, and we can then let the user navigate that list just like any other list page. https://github.com/user-attachments/assets/ecafc5fc-ed43-4554-94ff-80ca96e8c83e Unfortunately, this kinda means that we need to refactor ListPage a bit. We need to slice it, so that we can have the list itself as it's own control, separate from the "page". This lets us easily add the `ListItemsView` to the parameters page too. All of that code should basically be copied verbatim. Sorry that github will have a hard time comparing the two.
These files were intentionally deleted on main by recent PRs but were resurrected when 7aae734 merged main with a bad conflict resolution: - HideWindowMessage.cs (deleted by #47826 CmdPal parameters) - BookmarkPlaceholderForm.cs (deleted by #47886 bookmarks-as-parameters) - NativeMethods.json/.txt + WindowsPackageManager.Interop/* (deleted by #46636 Extension Gallery) - Ext.Indexer/Assets/Actions.png (moved/deleted by #46636) - DdcCiValidationResult.cs (deleted by #47875 PowerDisplay max-compat) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(this PR is an updated version of #43784)
This PR adds a new type of page to Command Palette:
The
ParametersPage.This allows extensions to create commands that require a set of parameters
before invoking the command. Previously, extensions could create commands with a
form page to use an adaptive card for parameter input, but that was a relatively
heavyweight UX.
Instead, the
ParametersPageallows extensions to define a set of lightweightinputs, which allows for a more streamlined experience.
The parameters page is made up of a set of "runs". Each run represents a single element in the search box. Runs can be either:
IInvokableCommands become buttons in the search boxIListPages become a list input to pick from (these will be added in a follow-up PR)There are a ton of samples included.
I also added all my draft notes in the drafts folder, to see how we got here.
I'd skip reviewing those.
Furthermore, I added the "dumb" token support, where an extension can opt in to
having tokens in the search box, delimited by ZWSP characters.
The XAML styling was fixed by Niels a few months back
Closes #40948