command: Add a Command palette component (#2765)
Adds a shadcn-style `Command` palette built on GPUI's virtual list, with local search, groups, disabled and checked items, Action keybinding hints, custom rows, different row heights, loading/empty states, headers, footers, and keyboard navigation. `Command` owns the render-time model and callbacks; `CommandState` keeps only interaction state such as query, selection, focus, loading, and scrolling. `CommandItem` is treated as a render element rather than a business-data container. Applications retain their own model and resolve `on_select` / `on_confirm` through `IndexPath`. `IndexPath` uses stable input-model coordinates. Items supplied through `.items(...)` occupy section 0 and retain their original input position in `row`, even after local filtering. Explicit groups use group/item coordinates. This matches `ListState` conventions and avoids mapping a filtered selection to the wrong business object. The Story app demonstrates grouped commands, custom rows, asynchronous stock search, Theme preview/confirmation with Escape rollback, headers, footers, Kbd hints, empty content, and a component palette opened with `ctrl-shift-p`. The selected border radius is also persisted across restarts. ## Real-world validation in the Longbridge Pro app The API was integrated into three production command flows in the Longbridge Pro app in [longbridge-gpui#3564](https://github.com/longbridge/longbridge-gpui/pull/3564): - application Command Palette: custom ranking, localized search terms, GPUI Actions and keybinding hints, plus close-before-dispatch behavior - Theme Picker: initial selection, keyboard preview, mouse/keyboard confirmation, Escape rollback, and protection from deferred preview callbacks after close - stock search: asynchronous owner-managed results, loading state, complex rows with different heights, history/filtering, modal and embedded use, new-tab confirmation, and AI-focus selection clear/restore This integration exposed two API design gaps that were fixed here: - owners can explicitly set or clear selection with `CommandState::set_selected_index` - ungrouped `.items(...)` callbacks now return the intuitive original item position in `IndexPath.row`, rather than encoding each item as a section Verification: - gpui-component Command tests: 32 passed - `cargo check -p gpui-component-story` - longbridge-gpui: `cargo check -p action_bar -p command_palette -p counter_search` - the Longbridge Pro app was launched and all three migrated production flows were manually exercised Docs: `website/docs/components/command.md` and `website/zh-CN/docs/components/command.md`. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
J
Jason Lee committed
cc89092fedc61acc839b4c113eb4778eee12b605
Parent: 9e3a29d
Committed by GitHub <noreply@github.com>
on 8/19/2026, 8:57:41 AM