Documentation Index
Fetch the complete documentation index at: https://grantmaster.dev/llms.txt
Use this file to discover all available pages before exploring further.
Engineering reference: For service contracts, EventBus events, and data-layer details see src/features/command-palette/command-palette.md.
Command Palette
Overview
Thecommand-palette feature provides a global keyboard-triggered command palette (⌘K / Ctrl+K) that allows users to navigate, create entities, run contextual actions, and invoke AI assistance — all from a single search interface.
The palette operates in four modes driven by query prefix, and uses a static singleton ActionRegistry populated at module load time via side-effect imports.
Data Model
Firestore Collections
None. The command palette is a pure UI feature with no Firestore persistence. Recent items are stored inlocalStorage.
Key TypeScript Types
Key Behaviors
Mode Switching
The palette mode is determined by the current query value (usePaletteMode):
- default — empty query; shows recent items and top actions
- search — query entered; fuzzy-matches against action registry
- action — query starts with
>; shows only actions (not navigation) - ai — query starts with
?; routes to AI fallback (AIFallbackcomponent)
Action Registry
ActionRegistry is a static singleton Map<id, CommandAction>. Actions are registered at module load time via three action files imported as side effects in index.ts:
navigationActions.ts— page-level navigation (go to projects, grants, etc.)createActions.ts— create-new shortcuts (new expense, new project, etc.)contextActions.ts— context-sensitive actions based on current route
register(action)/registerMany(actions[])— add actionsunregister(id)— remove actions (used for dynamic context actions)getAll()— all registered actionsgetByGroup(group)— filter by groupsearch(query)— fuzzy match with scoring: exact label match (+100), label starts with (+80), label contains (+60), keyword match (+40), description match (+30)
RBAC Filtering
Actions with apermission field are hidden at render time from users who lack that permission. This is enforced in ActionList using the RBAC context.
Recent Items
useRecentItems reads from localStorage key grantmaster:recent-items. Items are written when the user navigates via the palette. The list is capped at 10 entries, deduplicated by path, and sorted by timestamp descending.
Context Boosting
When searching, actions whoserouteContext matches the current pathname receive a score bonus, surfacing route-relevant actions higher in results.
Service Contract
No service files. Logic is encapsulated in hooks and the registry.| Export | Owns | Description |
|---|---|---|
ActionRegistry | Global action store | Static class; singleton Map; fuzzy search |
useCommandPalette | Open/close/toggle state | Exposes isOpen, open, close, toggle |
usePaletteMode | Mode derivation | Derives PaletteMode from query string |
useRecentItems | localStorage persistence | Recent items read/write, deduplication |
Events
Emitted
None. The command palette is a pure UI feature.Consumed
None.Dependencies
Depends on:contexts/RBACContext— permission checks for action visibility- React Router —
navigate()for navigation actions localStorage— recent items persistence
- All features that register actions (via
navigationActions.ts,createActions.ts,contextActions.ts) - The app shell (
components/layout/) — rendersUnifiedCommandPalette