CmdPal: Update the shell provider to be run#47642
Merged
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
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
ShellListPageimplementation withRunListPage, 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. |
michaeljolley
approved these changes
May 14, 2026
Contributor
michaeljolley
left a comment
There was a problem hiding this comment.
Other than the // TODO that may or not be a TODO, looks good to me.
This comment has been minimized.
This comment has been minimized.
niels9001
approved these changes
May 18, 2026
This comment has been minimized.
This comment has been minimized.
niels9001
approved these changes
May 18, 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.
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.