CmdPal: Fix missing primary context command for late-bound items#46131
Merged
michaeljolley merged 1 commit intomainfrom Mar 24, 2026
Merged
Conversation
…d commands - Creates the default primary context-menu item lazily when Command or Command.Name becomes available after SlowInitializeProperties(). - Refreshes AllCommands, SecondaryCommand, and HasMoreCommands notifications for late command materialization and Show Details updates. - Keeps the snapshot-based context menu flow intact while ensuring the primary command participates in the context menu. - Adds a unit test for the issue.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a CmdPal context-menu bug where a CommandItem that initially has a null/empty primary command never gets a synthetic “primary” context-menu entry when the extension later supplies a real command.
Changes:
- Adds a lazy path to create the synthetic primary
CommandContextItemViewModelwhenCommand/Command.Namebecomes available afterSlowInitializeProperties(). - Ensures
SecondaryCommand/SecondaryCommandName/HasMoreCommandsnotifications are raised when “MoreCommands” is modified internally (e.g., Show Details injection) and after slow init. - Adds unit tests covering late primary command materialization and subtitle propagation behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandItemViewModel.cs |
Lazily creates the synthetic primary context item on late command/name updates and refreshes related property notifications during slow init. |
src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListItemViewModel.cs |
Raises SecondaryCommand* and HasMoreCommands notifications when Show Details is added/updated in the context menu. |
src/modules/cmdpal/Tests/Microsoft.CmdPal.UI.ViewModels.UnitTests/CommandItemViewModelTests.cs |
Adds regression tests for late primary command creation and subtitle propagation into the synthetic primary context item. |
zateutsch
added a commit
that referenced
this pull request
Mar 25, 2026
Cherry-picked commits: - Make KBM Editor pinnable (#46482) - CmdPal: Fix missing primary context command for late-bound items (#46131) - CmdPal: Ensure DockWindow property cleans up after itself (#46303) - CmdPal: Hotfix commonCallbacks array initial count to prevent negative number (#46215) - CmdPal: Fix missing app context menu actions on the main page (#46293) - CmdPal: Fix dock popup XamlRoot handling on DockControl (#46305) - CmdPal: Reduce DockWindow backdrop switching and visual artifacts (#46309) - Always On Top: The opacity should be able to configure the hotkey individually (#46410) - [OOBE] Ensure the Settings button on the SCOOBE page opens Home, not a blank page (#46203) - CmdPal: Fix scroller scrolling and down glyph (#46447) - [Settings] Decouple Settings.UI.Library from PowerDisplay.Lib to fix (#46325)
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 does fix a bug where an item that starts with a null or empty primary command never adds that primary action to the context menu after the extension later provides a real command.
CommandorCommand.Namebecomes available afterSlowInitializeProperties()AllCommands,SecondaryCommand, andHasMoreCommandsnotifications for late command materialization and Show Details updates.Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed