feat(command-palette): add useOpenCommandPalette hook#384
Merged
Conversation
IzumiSy
marked this pull request as ready for review
July 15, 2026 07:30
Contributor
Author
|
/review |
Contributor
|
✅ API Design Review completed successfully! |
Contributor
There was a problem hiding this comment.
Generated by API Design Review for issue #384 · 46 AIC · ⌖ 6 AIC · ⊞ 5.8K
Comment /review to run again
interacsean
approved these changes
Jul 16, 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.
Motivation
The built-in
CommandPalettecould only be opened viaCmd/Ctrl+Kor the default sidebar entry. That made it awkward to wire palette entry points from page actions, empty states, or custom navigation UI.This change adds a small programmatic API for opening the existing palette, while also letting callers seed the initial input so the palette can open ready to search.
Design Decision
I kept the public surface narrow with
useOpenCommandPalette()instead of introducing a broader control object, ref API, or newAppShellprop.The hook accepts an optional
{ search }argument. That keeps plain open as the default case, and it reuses the palette's existing input parsing rules for mode switching. For example, callers can passPO: aliceto open directly into a prefix-based search source without adding a separatesource/queryAPI.Summary
useOpenCommandPalette()and exportOpenCommandPaletteOptionsopenCommandPalette({ search })to prefill the input on open