Skip to content

feat(command-palette): add useOpenCommandPalette hook#384

Merged
IzumiSy merged 6 commits into
mainfrom
feat/open-command-palette-api
Jul 16, 2026
Merged

feat(command-palette): add useOpenCommandPalette hook#384
IzumiSy merged 6 commits into
mainfrom
feat/open-command-palette-api

Conversation

@IzumiSy

@IzumiSy IzumiSy commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Motivation

The built-in CommandPalette could only be opened via Cmd/Ctrl+K or 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 new AppShell prop.

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 pass PO: alice to open directly into a prefix-based search source without adding a separate source/query API.

Summary

  • add useOpenCommandPalette() and export OpenCommandPaletteOptions
  • support openCommandPalette({ search }) to prefill the input on open
  • reuse existing prefix parsing so programmatic open can start directly in search-source mode
  • add tests for the new hook and prefilled search behavior

@IzumiSy
IzumiSy requested a review from a team as a code owner July 15, 2026 07:17
@IzumiSy
IzumiSy marked this pull request as draft July 15, 2026 07:20
@IzumiSy IzumiSy self-assigned this Jul 15, 2026
@IzumiSy
IzumiSy marked this pull request as ready for review July 15, 2026 07:30
@IzumiSy

IzumiSy commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

API Design Review completed successfully!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generated by API Design Review for issue #384 · 46 AIC · ⌖ 6 AIC · ⊞ 5.8K
Comment /review to run again

Comment thread packages/core/src/components/command-palette.tsx Outdated
@IzumiSy
IzumiSy merged commit 2497a2d into main Jul 16, 2026
4 checks passed
@IzumiSy
IzumiSy deleted the feat/open-command-palette-api branch July 16, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants