zidane-ui/ palette
import { … } from 'zidane-ui/palette'ui/src/palette/index.ts
Components#
CommandPaletteComponent#
Renders the command palette: sources, levels and running from controller, the surface from PalettePanel.
function CommandPalette(props: CommandPaletteProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | CommandPaletteProps |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| busy? | boolean | Turns the header spinner while the app's own search is out. |
| controller | PaletteController | The palette's state, from |
| extraGroups? | readonly PaletteSection<PaletteItem>[] | Groups shown after the ranked ones, never reordering them. Keep the array stable. |
PaletteDialogComponent#
Renders the palette surface in the modal slot usePaletteModalSlot opened. Esc and the backdrop tell the palette;
the palette closing (Cmd+K again, an item ran) closes the slot.
function PaletteDialog(props: PaletteDialogProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | PaletteDialogProps |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| archive? | 'all' | 'active' | 'archived' | Which sessions |
| className? | string | Classes merged on the surface's root. |
| context | PaletteContext | The snapshot handed to every source. Keep it stable while nothing in it changed. |
| onInsert? | (text: string) => void | Receives an |
| onPrompt? | (text: string) => void | Receives a |
| rows? | PaletteRows | The app rows, from |
| sessions? | readonly PaletteSession[] | Every loaded session, for the matches inside conversations. Absent: no "In conversations" group. |
| style? | CSSProperties | Inline styles on the surface's root. |
PaletteProviderComponent#
Holds the palette's state (open, sources, recents) for the components below it.
function PaletteProvider(props: PaletteProviderProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | PaletteProviderProps | The |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The app's components. |
| createRankWorker? | () => Worker | Starts a worker running |
| host? | PaletteHost | The data the built-in sources read and where recents persist. Read once, at mount. |
| labels? | Partial<{ paletteActionTitles: Record<string, string>; paletteAppearanceMode: Record<'dark' | 'light' | 'system', string>; paletteAppearanceModeHint: string; paletteAppearanceSettings: string; paletteCloseSidePanel: string; paletteCodeCompletion: string; paletteCommandGone: string; paletteCommandsGroup: string; paletteCompactTranscript: string; paletteCompactTranscriptHint: string; paletteConversationsGroup: string; paletteDiagnostics: Record<'off' | 'lsp' | 'tools', string>; paletteDiagnosticsHint: string; paletteEditFiles: string; paletteEditorGroup: string; paletteEditorSettings: string; paletteFileCount: (count: number) => string; paletteFilesGroup: string; paletteFilesPlaceholder: string; paletteFilesTitle: string; paletteFilesTreeSide: Record<'right' | 'left', string>; paletteFilesTreeSideHint: string; paletteGoToFile: string; paletteHoverDocs: string; paletteImportRepo: string; paletteImportRepoHint: string; paletteMatchCount: (count: number) => string; paletteModelGroup: string; paletteNavigateGroup: string; paletteNeedsLsp: string; paletteNeedsSession: string; paletteOpenAndFind: string; paletteOpenFile: string; paletteOpenSidePanel: string; palettePanelAttention: (count: number, waiting: boolean) => string; palettePanelsGroup: string; palettePanelTitle: (label: string) => string; paletteReducedMotion: string; paletteSearchPlaceholder: string; paletteSessionActionsGroup: string; paletteSessionCurrent: string; paletteSessionsGroup: string; paletteSessionStatus: Record<'error' | 'attention' | 'running' | 'pending', string>; paletteSettingsGroup: string; paletteShowLegacyModels: string; paletteShowLegacyModelsHint: string; paletteSidebarRunDetails: string; paletteSidebarRunDetailsHint: string; paletteSwitchToSession: string; paletteUnavailable: string; paletteUntitledSession: string; paletteViewGroup: string; paletteWordWrap: string }> | Overrides for the palette area's strings. Keys you leave out keep the default English label. |
Functions#
createPaletteRowsFunction#
Builds the palette's app rows over what the app knows about its sessions. Call it once, at module scope: the hooks it is handed run inside the rows.
function createPaletteRows(options?: PaletteRowsOptions): PaletteRowsParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | PaletteRowsOptions | {} |
Returns
paletteVerbOfFunction#
What Enter does to a session, a conversation match or a file; the surface names the rest.
function paletteVerbOf(
row: PaletteRowData<PaletteItem>,
labels: { paletteActionTitles: Record<string, string>; paletteAppearanceMode: Record<'dark' | 'light' | 'system', string>; paletteAppearanceModeHint: string; paletteAppearanceSettings: string; paletteCloseSidePanel: string; paletteCodeCompletion: string; paletteCommandGone: string; paletteCommandsGroup: string; paletteCompactTranscript: string; paletteCompactTranscriptHint: string; paletteConversationsGroup: string; paletteDiagnostics: Record<'off' | 'lsp' | 'tools', string>; paletteDiagnosticsHint: string; paletteEditFiles: string; paletteEditorGroup: string; paletteEditorSettings: string; paletteFileCount: (count: number) => string; paletteFilesGroup: string; paletteFilesPlaceholder: string; paletteFilesTitle: string; paletteFilesTreeSide: Record<'right' | 'left', string>; paletteFilesTreeSideHint: string; paletteGoToFile: string; paletteHoverDocs: string; paletteImportRepo: string; paletteImportRepoHint: string; paletteMatchCount: (count: number) => string; paletteModelGroup: string; paletteNavigateGroup: string; paletteNeedsLsp: string; paletteNeedsSession: string; paletteOpenAndFind: string; paletteOpenFile: string; paletteOpenSidePanel: string; palettePanelAttention: (count: number, waiting: boolean) => string; palettePanelsGroup: string; palettePanelTitle: (label: string) => string; paletteReducedMotion: string; paletteSearchPlaceholder: string; paletteSessionActionsGroup: string; paletteSessionCurrent: string; paletteSessionsGroup: string; paletteSessionStatus: Record<'error' | 'attention' | 'running' | 'pending', string>; paletteSettingsGroup: string; paletteShowLegacyModels: string; paletteShowLegacyModelsHint: string; paletteSidebarRunDetails: string; paletteSidebarRunDetailsHint: string; paletteSwitchToSession: string; paletteUnavailable: string; paletteUntitledSession: string; paletteViewGroup: string; paletteWordWrap: string },
): string | undefinedParameters
| Name | Type | Description |
|---|---|---|
| row | PaletteRowData<PaletteItem> | The row under the cursor. |
| labels | { paletteActionTitles: Record<string, string>; paletteAppearanceMode: Record<'dark' | 'light' | 'system', string>; paletteAppearanceModeHint: string; paletteAppearanceSettings: string; paletteCloseSidePanel: string; paletteCodeCompletion: string; paletteCommandGone: string; paletteCommandsGroup: string; paletteCompactTranscript: string; paletteCompactTranscriptHint: string; paletteConversationsGroup: string; paletteDiagnostics: Record<'off' | 'lsp' | 'tools', string>; paletteDiagnosticsHint: string; paletteEditFiles: string; paletteEditorGroup: string; paletteEditorSettings: string; paletteFileCount: (count: number) => string; paletteFilesGroup: string; paletteFilesPlaceholder: string; paletteFilesTitle: string; paletteFilesTreeSide: Record<'right' | 'left', string>; paletteFilesTreeSideHint: string; paletteGoToFile: string; paletteHoverDocs: string; paletteImportRepo: string; paletteImportRepoHint: string; paletteMatchCount: (count: number) => string; paletteModelGroup: string; paletteNavigateGroup: string; paletteNeedsLsp: string; paletteNeedsSession: string; paletteOpenAndFind: string; paletteOpenFile: string; paletteOpenSidePanel: string; palettePanelAttention: (count: number, waiting: boolean) => string; palettePanelsGroup: string; palettePanelTitle: (label: string) => string; paletteReducedMotion: string; paletteSearchPlaceholder: string; paletteSessionActionsGroup: string; paletteSessionCurrent: string; paletteSessionsGroup: string; paletteSessionStatus: Record<'error' | 'attention' | 'running' | 'pending', string>; paletteSettingsGroup: string; paletteShowLegacyModels: string; paletteShowLegacyModelsHint: string; paletteSidebarRunDetails: string; paletteSidebarRunDetailsHint: string; paletteSwitchToSession: string; paletteUnavailable: string; paletteUntitledSession: string; paletteViewGroup: string; paletteWordWrap: string } | The palette labels. |
Returns
string | undefineduseActionsPaletteSourceFunction#
Registers the key command registry's actions as a palette source. Registers again only when the set of bound actions changes: the rows run the handlers in effect when picked.
function useActionsPaletteSource(): voiduseConversationHitFunction#
The content hit behind a palette row, if it is one.
function useConversationHit(itemId: string): PaletteConversationHit | undefinedParameters
| Name | Type | Description |
|---|---|---|
| itemId | string | The row's item id. |
Returns
PaletteConversationHit | undefineduseConversationSearchFunction#
Searches inside conversations as the query settles. Nothing (and no request) when the host leaves
searchConversations out.
function useConversationSearch(
query: string,
options: ConversationSearchOptions,
): ConversationSearchParameters
| Name | Type | Description |
|---|---|---|
| query | string | The palette's query as typed. |
| options | ConversationSearchOptions |
Returns
usePaletteFunction#
The palette's state and actions. Re-renders on every state change. Throws outside a PaletteProvider.
function usePalette(): PaletteApiReturns
usePaletteActionsFunction#
The palette's stable actions. Never re-renders its caller. Throws outside a PaletteProvider.
function usePaletteActions(): PaletteActionsReturns
usePaletteControllerFunction#
The command palette's state: gather, rank, levels and running. Call it inside a PaletteProvider.
function usePaletteController(options: PaletteControllerOptions): PaletteControllerParameters
| Name | Type | Description |
|---|---|---|
| options | PaletteControllerOptions | The context and where agent-bound results go. |
Returns
usePaletteHostFunction#
The PaletteHost given to the nearest PaletteProvider, if any.
function usePaletteHost(): PaletteHost | undefinedReturns
PaletteHost | undefinedusePaletteLabelsFunction#
The palette area's strings, with the provider's overrides.
function usePaletteLabels(): { paletteActionTitles: Record<string, string>; paletteAppearanceMode: Record<'dark' | 'light' | 'system', string>; paletteAppearanceModeHint: string; paletteAppearanceSettings: string; paletteCloseSidePanel: string; paletteCodeCompletion: string; paletteCommandGone: string; paletteCommandsGroup: string; paletteCompactTranscript: string; paletteCompactTranscriptHint: string; paletteConversationsGroup: string; paletteDiagnostics: Record<'off' | 'lsp' | 'tools', string>; paletteDiagnosticsHint: string; paletteEditFiles: string; paletteEditorGroup: string; paletteEditorSettings: string; paletteFileCount: (count: number) => string; paletteFilesGroup: string; paletteFilesPlaceholder: string; paletteFilesTitle: string; paletteFilesTreeSide: Record<'right' | 'left', string>; paletteFilesTreeSideHint: string; paletteGoToFile: string; paletteHoverDocs: string; paletteImportRepo: string; paletteImportRepoHint: string; paletteMatchCount: (count: number) => string; paletteModelGroup: string; paletteNavigateGroup: string; paletteNeedsLsp: string; paletteNeedsSession: string; paletteOpenAndFind: string; paletteOpenFile: string; paletteOpenSidePanel: string; palettePanelAttention: (count: number, waiting: boolean) => string; palettePanelsGroup: string; palettePanelTitle: (label: string) => string; paletteReducedMotion: string; paletteSearchPlaceholder: string; paletteSessionActionsGroup: string; paletteSessionCurrent: string; paletteSessionsGroup: string; paletteSessionStatus: Record<'error' | 'attention' | 'running' | 'pending', string>; paletteSettingsGroup: string; paletteShowLegacyModels: string; paletteShowLegacyModelsHint: string; paletteSidebarRunDetails: string; paletteSidebarRunDetailsHint: string; paletteSwitchToSession: string; paletteUnavailable: string; paletteUntitledSession: string; paletteViewGroup: string; paletteWordWrap: string }Returns
{ paletteActionTitles: Record<string, string>; paletteAppearanceMode: Record<'dark' | 'light' | 'system', string>; paletteAppearanceModeHint: string; paletteAppearanceSettings: string; paletteCloseSidePanel: string; paletteCodeCompletion: string; paletteCommandGone: string; paletteCommandsGroup: string; paletteCompactTranscript: string; paletteCompactTranscriptHint: string; paletteConversationsGroup: string; paletteDiagnostics: Record<'off' | 'lsp' | 'tools', string>; paletteDiagnosticsHint: string; paletteEditFiles: string; paletteEditorGroup: string; paletteEditorSettings: string; paletteFileCount: (count: number) => string; paletteFilesGroup: string; paletteFilesPlaceholder: string; paletteFilesTitle: string; paletteFilesTreeSide: Record<'right' | 'left', string>; paletteFilesTreeSideHint: string; paletteGoToFile: string; paletteHoverDocs: string; paletteImportRepo: string; paletteImportRepoHint: string; paletteMatchCount: (count: number) => string; paletteModelGroup: string; paletteNavigateGroup: string; paletteNeedsLsp: string; paletteNeedsSession: string; paletteOpenAndFind: string; paletteOpenFile: string; paletteOpenSidePanel: string; palettePanelAttention: (count: number, waiting: boolean) => string; palettePanelsGroup: string; palettePanelTitle: (label: string) => string; paletteReducedMotion: string; paletteSearchPlaceholder: string; paletteSessionActionsGroup: string; paletteSessionCurrent: string; paletteSessionsGroup: string; paletteSessionStatus: Record<'error' | 'attention' | 'running' | 'pending', string>; paletteSettingsGroup: string; paletteShowLegacyModels: string; paletteShowLegacyModelsHint: string; paletteSidebarRunDetails: string; paletteSidebarRunDetailsHint: string; paletteSwitchToSession: string; paletteUnavailable: string; paletteUntitledSession: string; paletteViewGroup: string; paletteWordWrap: string }usePaletteModalSlotFunction#
Opens the palette surface in the modal slot while the palette is open, and closes the palette when another modal
takes the slot. Mount it once, under ModalProvider and PaletteProvider.
function usePaletteModalSlot(options: PaletteModalSlotOptions): voidParameters
| Name | Type | Description |
|---|---|---|
| options | PaletteModalSlotOptions |
usePaletteSourceFunction#
Registers a source for the component's lifetime. source is read through
a ref, so callers can pass a fresh object every render without churning
the registry; it registers again only when its id changes. null
registers nothing.
function usePaletteSource(source: PaletteProvider | null): voidParameters
| Name | Type | Description |
|---|---|---|
| source | PaletteProvider | null | The source, or |
useRankedItemsFunction#
Ranks items for query, off the main thread for a big catalog when the provider has a rank worker.
function useRankedItems(
items: readonly PaletteItem[],
query: string,
recents: readonly string[],
): RankedItemsParameters
| Name | Type | Description |
|---|---|---|
| items | readonly PaletteItem[] | The catalog. |
| query | string | The query. |
| recents | readonly string[] | Recently run ids, for the empty-query order. |
Returns
useSessionRankFunction#
A session's palette rank: 0 when it needs the user (attention, a pending approval or question), 1 while it runs, else 2.
function useSessionRank(
peekRunning: (sessionId: string) => boolean,
): (sessionId: string) => SessionRankParameters
| Name | Type | Description |
|---|---|---|
| peekRunning | (sessionId: string) => boolean | Whether the app sees the session running now (read when ranking, not subscribed). |
Returns
(sessionId: string) => SessionRankConstants#
CONVERSATION_SEARCH_MIN_CHARSConstant#
Shorter queries match nearly every conversation: not worth a scan.
const CONVERSATION_SEARCH_MIN_CHARS = 2ConversationHitsContextConstant#
The hits of the rows on show, for the rows that render them.
const ConversationHitsContext: Context<ReadonlyMap<string, PaletteConversationHit>>PALETTE_MODAL_IDConstant#
The palette's modal-slot id (modal.open({ id })), shared by the slot bridge and the surface.
const PALETTE_MODAL_ID = 'palette'Interfaces#
ConversationSearchInterface#
What useConversationSearch returns.
interface ConversationSearchProperties
| Name | Type | Description |
|---|---|---|
| hits | ReadonlyMap<string, PaletteConversationHit> | Each row's hit, by item id (match count, age). |
| rows | readonly RankedPaletteItem[] | The "In conversations" rows, in the host's order. |
| searching | boolean | A scan for the current query is on its way. |
ConversationSearchOptionsInterface#
Options of useConversationSearch.
interface ConversationSearchOptionsProperties
| Name | Type | Description |
|---|---|---|
| archive? | 'all' | 'active' | 'archived' | Which sessions |
| enabled | boolean | False in a nested picker: content search is a root-level thing. |
| listed | ReadonlySet<string> | Session ids the ranked rows already show. |
| sessions | readonly PaletteSession[] | Every loaded session. |
PaletteActionsInterface#
What never changes: callers that only open the palette or register a source never re-render with it.
interface PaletteActionsProperties
| Name | Type | Description |
|---|---|---|
| close | () => void | Closes the palette. |
| open | () => void | Opens the palette. |
| registerSource | (source: PaletteProvider) => () => void | Registers a source for as long as the caller wants it; returns the unregister. |
| toggle | () => void | Opens a closed palette, closes an open one (the Cmd+K entry point). |
PaletteApiInterface#
The palette's state and actions, from usePalette.
interface PaletteApi extends PaletteActions, PaletteStateProperties
| Name | Type | Description |
|---|---|---|
closefrom PaletteActions | () => void | Closes the palette. |
isOpenfrom PaletteState | boolean | Whether the palette is open. |
| markRecent | (id: string) => void | Puts an item id first in the recents. |
openfrom PaletteActions | () => void | Opens the palette. |
recentsfrom PaletteState | readonly string[] | Recently run item ids, most recent first. |
registerSourcefrom PaletteActions | (source: PaletteProvider) => () => void | Registers a source for as long as the caller wants it; returns the unregister. |
sourcesfrom PaletteState | readonly PaletteProvider[] | Every registered source, in registration order. |
togglefrom PaletteActions | () => void | Opens a closed palette, closes an open one (the Cmd+K entry point). |
versionfrom PaletteState | number | Bumps whenever an open palette's source signalled a change through |
PaletteContextInterface#
JSON-safe snapshot of the host handed to providers. Never holds functions.
interface PaletteContextProperties
| Name | Type | Description |
|---|---|---|
| busy? | boolean | A run is in flight on the active session. |
| cwd? | string | Working directory of the active session. |
| host | PaletteHost | Which app is asking. |
| sessionId? | string | Id of the active session. |
PaletteControllerInterface#
The palette's state and handlers, for CommandPalette.
interface PaletteControllerProperties
| Name | Type | Description |
|---|---|---|
| back | () => void | Leaves the nested level. Stable. |
| clearScope | () => void | Searches every section again. Stable. |
| close | () => void | Closes the palette. |
| cursor | number | The highlighted row's index. |
| cycleScope | () => void | Scopes the root search to the next section; after the last, back to every section. Stable while |
| inputRef | RefObject<HTMLInputElement | null> | The query field (focused again when a level opens). |
| loading | boolean | The root items have not landed yet. |
| nested | boolean | Whether a picker's level is shown. |
| notice | PaletteNotice | null | The notice line (a |
| placeholder | string | undefined | The query field's placeholder. |
| query | string | The query typed. |
| ranked | readonly RankedPaletteItem[] | The ranked rows of the current level. |
| run | (row: PaletteRowData<PaletteItem>) => void | Runs a row. Stable. |
| running | boolean | A row is running. |
| scope | string | null | The section the root search is scoped to; |
| scopes | readonly string[] | The sections a scope can be: the root items' groups in order, then |
| sections | readonly PaletteGroup[] |
|
| setCursor | (index: number) => void | Moves the highlight. |
| setQuery | (query: string) => void | Sets the query. |
| settled | boolean | The rows are for the query typed. |
| title | string | undefined | The nested level's title. |
PaletteControllerOptionsInterface#
Options of usePaletteController.
interface PaletteControllerOptionsProperties
| Name | Type | Description |
|---|---|---|
| context | PaletteContext | The snapshot handed to every source. Keep it stable while nothing in it changed. |
| extraScopes? | readonly string[] | Sections the app lists itself (its own groups), offered as scopes after the root items' groups. Keep it stable. |
| onInsert? | (text: string) => void | Receives an |
| onPrompt? | (text: string) => void | Receives a |
| recentIdOf? | (item: PaletteItem) => string | The id Recent remembers for a run root item. Default: the item's own id. |
PaletteDialogPropsInterface#
Props for PaletteDialog.
interface PaletteDialogPropsProperties
| Name | Type | Description |
|---|---|---|
| archive? | 'all' | 'active' | 'archived' | Which sessions |
| className? | string | Classes merged on the surface's root. |
| context | PaletteContext | The snapshot handed to every source. Keep it stable while nothing in it changed. |
| onInsert? | (text: string) => void | Receives an |
| onPrompt? | (text: string) => void | Receives a |
| rows? | PaletteRows | The app rows, from |
| sessions? | readonly PaletteSession[] | Every loaded session, for the matches inside conversations. Absent: no "In conversations" group. |
| style? | CSSProperties | Inline styles on the surface's root. |
PaletteItemInterface#
An entry in the command palette.
interface PaletteItemProperties
| Name | Type | Description |
|---|---|---|
| checked? | boolean | For |
| description? | string | Secondary text shown beside the title. |
| disabled? | string | Reason the item cannot run right now; it stays listed, muted. |
| group | string | Section header. Hosts order groups by first appearance after |
| icon? | PanelIcon | Icon for each renderer. |
| id | string | Stable, unique across providers: |
| keybinding? | string | Resolved chord spec ( |
| keywords? | readonly string[] | Extra search terms not shown in the row. |
| kind? | PaletteItemKind | How the item behaves. Treated as |
| searchOnly? | boolean | Only appears once the query matches it: bulk catalogs (every file in the project) stay out of the empty-query listing but are one keystroke away. |
| source | string | Provider that owns |
| title | string | Text shown in the row. |
PaletteModalSlotOptionsInterface#
Options of usePaletteModalSlot.
interface PaletteModalSlotOptionsProperties
| Name | Type | Description |
|---|---|---|
| context | PaletteContext | The snapshot the surface opens with (reopening picks up a new one). |
| cwd? | string | The project folder: the extension providers' live updates stay on for it while open. |
| render | (context: PaletteContext) => ReactNode | The surface, usually a |
PaletteProviderPropsInterface#
Props for PaletteProvider.
interface PaletteProviderPropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The app's components. |
| createRankWorker? | () => Worker | Starts a worker running |
| host? | PaletteHost | The data the built-in sources read and where recents persist. Read once, at mount. |
| labels? | Partial<{ paletteActionTitles: Record<string, string>; paletteAppearanceMode: Record<'dark' | 'light' | 'system', string>; paletteAppearanceModeHint: string; paletteAppearanceSettings: string; paletteCloseSidePanel: string; paletteCodeCompletion: string; paletteCommandGone: string; paletteCommandsGroup: string; paletteCompactTranscript: string; paletteCompactTranscriptHint: string; paletteConversationsGroup: string; paletteDiagnostics: Record<'off' | 'lsp' | 'tools', string>; paletteDiagnosticsHint: string; paletteEditFiles: string; paletteEditorGroup: string; paletteEditorSettings: string; paletteFileCount: (count: number) => string; paletteFilesGroup: string; paletteFilesPlaceholder: string; paletteFilesTitle: string; paletteFilesTreeSide: Record<'right' | 'left', string>; paletteFilesTreeSideHint: string; paletteGoToFile: string; paletteHoverDocs: string; paletteImportRepo: string; paletteImportRepoHint: string; paletteMatchCount: (count: number) => string; paletteModelGroup: string; paletteNavigateGroup: string; paletteNeedsLsp: string; paletteNeedsSession: string; paletteOpenAndFind: string; paletteOpenFile: string; paletteOpenSidePanel: string; palettePanelAttention: (count: number, waiting: boolean) => string; palettePanelsGroup: string; palettePanelTitle: (label: string) => string; paletteReducedMotion: string; paletteSearchPlaceholder: string; paletteSessionActionsGroup: string; paletteSessionCurrent: string; paletteSessionsGroup: string; paletteSessionStatus: Record<'error' | 'attention' | 'running' | 'pending', string>; paletteSettingsGroup: string; paletteShowLegacyModels: string; paletteShowLegacyModelsHint: string; paletteSidebarRunDetails: string; paletteSidebarRunDetailsHint: string; paletteSwitchToSession: string; paletteUnavailable: string; paletteUntitledSession: string; paletteViewGroup: string; paletteWordWrap: string }> | Overrides for the palette area's strings. Keys you leave out keep the default English label. |
PaletteRowsInterface#
The renderers createPaletteRows returns, for CommandPalette.
interface PaletteRowsProperties
| Name | Type | Description |
|---|---|---|
| renderIcon | (row: PaletteRowData<PaletteItem>) => ReactNode | A file's type badge, else the item's own glyph. |
| renderKeys | PaletteKeys | Keycaps for binding specs that may list alternatives ( |
| renderRow | (props: PaletteRowProps<PaletteItem>) => ReactNode | A session or a conversation match; any other row is the surface's ( |
PaletteRowsOptionsInterface#
What the rows read from the app. Every member is optional.
interface PaletteRowsOptionsProperties
| Name | Type | Description |
|---|---|---|
| highlight? | (excerpt: string, query: string) => { ranges: readonly PaletteTextRange[]; text: string } | Cuts a conversation excerpt around its first match and marks the query's terms in it. Absent: plain excerpt. |
| StatusDot? | ComponentType<{ sessionId: string }> | A session's live status dot, in the row's icon slot. |
| useSession? | (sessionId: string) => { current: boolean; updatedAt: number } | undefined | A loaded session's last update and whether it is the one on show (a hook, called once per session row). |
| useSessionStatus? | (sessionId: string) => string | undefined | A session's live status (a hook, called once per session row). |
PaletteSourceInterface#
Source of palette items and the handler that runs them.
interface PaletteSourceProperties
| Name | Type | Description |
|---|---|---|
| id | string | Provider id, stamped on its items as |
| items | (ctx: PaletteContext) => readonly PaletteItem[] | Promise<readonly PaletteItem[]> | Items for the current context. Called on open, on |
| run | (itemId: string, ctx: PaletteContext) => PaletteRunResult | Promise<PaletteRunResult> | Runs the item with the given id. May return a follow-up result. |
| subscribe? | (emit: () => void) => () => void | Live updates while the palette is open, same contract as panels. |
RankedItemsInterface#
What useRankedItems returns.
interface RankedItemsProperties
| Name | Type | Description |
|---|---|---|
| rows | readonly RankedPaletteItem[] | The rows to show. |
| settled | boolean | The rows are for this query (Enter waits for that). |
Types#
CommandPalettePropsType#
Props for CommandPalette.
type CommandPaletteProps = Pick<PalettePanelProps<PaletteItem>, 'verb' | 'renderRow' | 'renderIcon' | 'renderKeys' | 'className' | 'style'> & { busy?: boolean; controller: PaletteController; extraGroups?: readonly PaletteSection<PaletteItem>[] }PaletteRunResultType#
What a provider's run may hand back. items opens a nested picker
(branches, environments); the host keeps a stack so Backspace on an
empty query goes back one level. prompt sends text to the chat,
insert puts it in the composer (a / command that takes arguments).
type PaletteRunResult =
| void
| undefined
| { items: readonly PaletteItem[]; kind: 'items'; placeholder?: string; title?: string }
| { kind: 'prompt'; text: string }
| { kind: 'insert'; text: string }
| { kind: 'notify'; text: string; tone?: 'info' | 'warn' | 'error' }PaletteSessionStatusType#
A session's status as its palette row words it; quiet states say nothing.
type PaletteSessionStatus = 'running' | 'pending' | 'attention' | 'error'PaletteTextRangeType#
A half-open [start, end) range of a text.
type PaletteTextRange = readonly [start: number, end: number]