Skip to content

CmdPal: Update the shell provider to be run#47642

Merged
zadjii-msft merged 28 commits into
mainfrom
dev/migrie/run-to-cmdpal
May 18, 2026
Merged

CmdPal: Update the shell provider to be run#47642
zadjii-msft merged 28 commits into
mainfrom
dev/migrie/run-to-cmdpal

Conversation

@zadjii-msft
Copy link
Copy Markdown
Member

This PR updates the shell command provider to work (almost) exactly like run. The current shell provider is close, but not technically correct. It does enumerate files. Sure. But as it turns out, it doesn't enumerate things exactly correctly. It doesn't handle network paths super well. It doesn't handle NTFS file paths. Basically, there's a lot of weird edge cases in the way the run dialog enumerates file paths for suggestions. And the only way to match that is to just use the code from the old run dialog.

This is code that is taken pretty verbatim from the new run dialog. Instead of trying to enumerate paths manually and shellexecuting command lines, We're using the actual APIs that the original run dialog used, more or less. They've been pretty much ported to C#.

This should make us feel just as correct as the original run dialog did. And exactly the same as the new Run dialog.

The one major change is the introduction of a static item at the top of the list for running the command that the user typed. This command is used to just immediately take whatever is in the search box and fire it off as the command the user typed. This is essentially what happens with the run dialog. When you press the button, we run the command in the text box.

See: The new Run dialog: faster, cleaner, and more capable - Windows Command Line

Honestly, most of this PR is just deleting the files we no longer need from the shell list provider and adding the tests from the OS side here.

I also had to update CsWinRT for this.

@zadjii-msft zadjii-msft added Product-Command Palette Refers to the Command Palette utility CmdPal - Shell Issues related to the Shell (run) built-in extension labels May 4, 2026
@zadjii-msft zadjii-msft changed the title what if we were run? we'd need cswinrt 2.3 I guess CmdPal: Update the shell provider to be run May 4, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reworks the CmdPal Shell command provider to use a C# port of the Run dialog’s native parsing and suggestion APIs (including STA/OLE + IACListISF), aiming to match Run’s edge-case behavior for path enumeration (UNC, NT paths, etc.). It also introduces a dedicated “run what you typed” item and ports/expands unit tests to validate the new behavior.

Changes:

  • Replace the previous ShellListPage implementation with RunListPage, using shell autocomplete APIs (STA/OLE) for filesystem suggestions and using Run-style command parsing/execution helpers.
  • Extend IRunHistoryService/telemetry plumbing to support Run-style parsing/qualification/execution and add strongly-typed telemetry events.
  • Remove old shell-page tests and add a large set of Run-focused unit tests (ported from OS-side tests) covering path formats, env vars, caching, filtering, and tilde expansion.

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Shell.UnitTests/ScopeExit.cs Adds a small disposable helper used by new unit tests.
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Shell.UnitTests/RunPageTests.cs Adds comprehensive tests for RunListPage path enumeration and filtering behavior.
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Shell.UnitTests/QueryTests.cs Removes tests tied to the deleted ShellListPage behavior.
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Shell.UnitTests/QualifyCommandLineDirectoryTests.cs Adds tests validating RunHistory.QualifyCommandLineDirectory parity.
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Shell.UnitTests/ParseCommandlineTests.cs Adds tests validating RunHistory.ParseCommandline parity (including NT paths/URLs).
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Shell.UnitTests/IntegratedCommandExecutionTests.cs Adds integrated parse+qualify workflow tests mirroring ShellExec behavior.
src/modules/cmdpal/Microsoft.CmdPal.UI/RunHistoryService.cs Implements new IRunHistoryService methods by delegating to RunHistory.
src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs Updates icon extraction to newer CsWin32-friendly overloads.
src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TelemetryForwarder.cs Adds a generic LogEvent entry point and maps known event names to typed telemetry.
src/modules/cmdpal/Microsoft.CmdPal.UI/Events/RunEvents.cs Adds new typed telemetry event classes for RunListPage diagnostics.
src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs Adjusts collection-expression usage for compatibility with new build settings.
src/modules/cmdpal/Microsoft.CmdPal.Common/Services/Sanitizer/ErrorReportSanitizer.cs Adjusts collection-expression usage and removes BOM.
src/modules/cmdpal/Microsoft.CmdPal.Common/Services/IRunHistoryService.cs Extends the interface with Run-style parsing/execution APIs and adds ParseCommandlineResult.
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Utilities.cs Fixes a variable used in GetCurrentPackageId call under updated interop settings.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/WinGetStatics.cs Adjusts collection-expression usage and removes BOM.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/HistoryStore.cs Adjusts collection-expression usage.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/ShellCommandsProvider.cs Switches provider to RunListPage, updates fallback wiring, and disposes the new page.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/StaHelperService.cs Adds a persistent OLE-initialized STA worker for shell autocomplete calls.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/RunListPage.cs Introduces the new Run-aligned list page (history + filesystem suggestions + typed-command item).
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/RunHistory.cs Adds C# port of Run parsing/qualification/execution logic.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/RunExeItem.cs Adds Run items and the typed-command item command implementation/context menu.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/RunDialogHelpers.cs Adds helpers to create list items from parsed command strings/results with telemetry.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/FileItem.cs Adds async/lazy icon-loading base item for file-backed list items.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/AsyncDynamicListPage.cs Adds an async/cancellable dynamic list page base used by RunListPage.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Properties/Resources.resx Adds new Run-related localized strings for names/commands/placeholder text.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Pages/ShellListPage.cs Deletes the old shell page implementation now replaced by RunListPage.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Pages/RunExeItem.cs Deletes the old RunExeItem implementation (superseded by Run/ versions).
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Pages/PathListItem.cs Deletes the old path list item implementation (superseded by Run/ versions).
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/NativeMethods.txt Expands CsWin32 native method list for new COM/OLE/shell APIs.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/NativeMethods.json Updates CsWin32 settings (marshaling, safe handles, friendly overloads) for new interop usage.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Microsoft.CmdPal.Ext.Shell.csproj Enables CsWin32 build task and disables runtime marshalling for the project.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Icons.cs Adds icons needed by the new Run behavior (history/open URL).
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Helpers/ShellListPageHelpers.cs Removes old history-item building logic tied to deleted pages and adjusts BOM.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Helpers/CommandLineNormalizer.cs Updates SearchPath callsite to match new CsWin32 overloads.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/FallbackExecuteItem.cs Reworks fallback execution item to use Run-style parsing and Run/ items for icon/commands.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Helpers/ClipboardHelper.cs Adjusts collection-expression usage and removes BOM.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/CommandLauncher.cs Removes BOM (no functional change).
Directory.Packages.props Updates Microsoft.Windows.CsWin32 version used by the repo.
.github/actions/spell-check/allow/code.txt Adds allowlist terms for new Run/Shell API symbols and HRESULT names.

Comment thread src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/FileItem.cs Outdated
Comment thread src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/FileItem.cs
Comment thread src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/RunHistory.cs Outdated
Comment thread src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/RunExeItem.cs
Comment thread src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs Outdated
Comment thread src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Run/RunHistory.cs Outdated
Copy link
Copy Markdown
Contributor

@michaeljolley michaeljolley left a comment

Choose a reason for hiding this comment

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

Other than the // TODO that may or not be a TODO, looks good to me.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@niels9001 niels9001 enabled auto-merge (squash) May 18, 2026 17:11
@niels9001 niels9001 disabled auto-merge May 18, 2026 17:11
@zadjii-msft zadjii-msft merged commit b02e53d into main May 18, 2026
15 checks passed
@LegendaryBlair LegendaryBlair added this to the PowerToys 0.100 milestone May 19, 2026
@zadjii-msft zadjii-msft deleted the dev/migrie/run-to-cmdpal branch May 20, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.100 CmdPal - Shell Issues related to the Shell (run) built-in extension Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants