Skip to content

Command palette: Ctrl+K / / search-everything #78

Description

@ApocDev

Add a global command palette for jumping anywhere in the app from the keyboard. Late-game Py has thousands of goods and dozens of factory blocks, and today every lookup goes through the sidebar or the browse page's own search box.

Behavior

  • Ctrl+K / Cmd+K opens the palette from any page. / opens it too, but only when focus is not in a text field (inputs, textareas, contenteditable), so typing rates or chat messages is never interrupted.
  • One search box, grouped results:
    • Pages — factory, browse, whatif, coherence, turd, tasks, assistant, settings. Ctrl+K → "coh" → Enter replaces a sidebar click.
    • Blocks — factory blocks by name / pinned output → jump to the block page.
    • Goods — items and fluids by localized name, with icon chips → jump to their browse view.
    • Recipes — by localized name → browse/recipe detail.
    • Possibly tasks as a cheap extra, since they live in the same store.
  • Empty query shows recent selections (and the page list) instead of nothing.
  • Esc closes; arrow keys + Enter navigate, as usual for a palette.

Implementation notes

  • UI: cmdk inside a shadcn dialog — the standard palette building block, plays well with the existing Radix/Tailwind stack. Results render localized display names with the existing Icon component (internal names are keys only, per the repo convention).
  • Hotkeys: react-hotkeys-hook mounted once in the root layout. Its mod+k binding maps to Cmd on macOS and Ctrl elsewhere, it ignores form fields by default (exactly what / needs), and it matches by produced key value so / works on layouts where it's a shifted key. Evaluated TanStack Hotkeys as the on-stack alternative, but it's too new — sticking with the stable option; we need exactly two bindings and no sequences, so swapping later is trivial.
  • Goods/recipes search must filter server-side against SQLite (a debounced server function reusing the existing search queries) rather than shipping the whole goods table to the client. Blocks and pages are small enough to search client-side. Ranking can reuse @tanstack/match-sorter-utils, already a dependency.
  • Avoid combos that collide with browser or Tauri-webview reserved shortcuts (Ctrl+W, Ctrl+T, Ctrl+number). Ctrl+K and / are safe in both environments.
  • Docs: add the shortcuts to README's UI section when this ships.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: webWeb UI (React/TanStack/vite-plus)enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions