Skip to content

Command palette: search entities, open page dialogs, shortcut sheet - #192

Merged
fylorn merged 2 commits into
devfrom
ui/palette
Sep 24, 2026
Merged

fylorn merged 2 commits into
devfrom
ui/palette

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Part of the UI upgrade (after #187). Replaces the foundation's minimal CommandPalette with a real command palette, adds a keyboard shortcut sheet, and shows each page's ⌘n in the sidebar tooltips. Rebased onto the Routing (#191) and Upstreams (#193) pages.

What it does

⌘K palette (src/palette/, cmdk via the new src/ui/command.tsx)

  • Pages in sidebar order with their ⌘1–⌘9 caps.
  • Actions: new upstream / key / route, inference test, connection test, routing dry run, search traffic, switch connection, refresh, collapse sidebar, config file, version history, check for updates, open notices, keyboard shortcuts. Search-only: new group / proxy / price sheet, add remote connection. Actions that write config are hidden while a remote core is unreachable (read-only); actions that need upstreams are hidden until there is one; without a core only Settings, connections and non-core actions remain.
  • Search over data already on hand: upstreams (name, base URL; status on the right), keys (name, bound client), routes, groups, clients (same clients cache as the Clients and Keys pages), connections, Settings sections, and Traffic's loaded requests — by model (one row per model, the most recent) or by id (#50431, prefixes; an id outside the loaded rows still gets an "Open request #…" row).
  • Recent (last five used) above Pages and Actions; frequent use gives a small ranking boost that never lifts a weak match over a strong one. Names outrank aliases (the other language, synonyms, URLs), so 试算 puts "Routing dry run…" above the Routing page.
  • Switch connection is a second level (lead chip in the input; Esc or Backspace goes back; the current connection is listed but not selectable).
  • Footer: shortcut sheet on the left, ↑↓ / ↵ + verb (Open / Run / Switch) on the right; the hints disappear when nothing is selectable.
  • Motion: scales 0.97→1 and fades in from the top (200ms ease-out, 150ms out); the list height follows the results. Reduced motion keeps the fade only.

The palette only navigates — dialogs stay in their pages. Every item is nav.open(page, params); the page opens its own dialog in useNavParams exactly like its button or row click. New NavParams: upstreams {edit, create: upstream|proxy|sheet, test: speed|link}, keys {edit, create}, routing {editRoute, editGroup, create: route|group, dryRun}, clients {detail, setup}. settings {section} is handled by the Settings page itself (Config.tsx calls revealSection, which waits for the section to render). src/palette/wiring.test.ts parses every nav.open the palette sends and fails if no page reads that param — so a page rewrite cannot silently drop the receiving end.

Keyboard

  • ? (outside text fields) or the palette footer opens a shortcut sheet: General, Pages (⌘1–⌘9, ⌘,), Traffic (⌘F, ↑↓, ↵, →←, Esc), Command palette (↑↓, ⌥↑↓, ↵, ⌫, Esc). Press ? again to close.
  • Caps are rendered from one table (palette/keys.tsx: COMBOS, pageCombo, Keys) in the palette, the sheet, the sidebar tooltips and the toolbar tooltips. macOS shows one cap per combo (⌘⌥S), Windows/Linux one cap per key (Ctrl B).
  • Sidebar items show "Name ⌘n" in a tooltip, also when the sidebar is expanded.
  • Global shortcuts (⌘K, ⌘1–⌘9, ⌘F, ⌘,) do nothing while a form dialog is open (a half-edited form is never unmounted). The palette and the sheet are data-passive: ⌘4 read off the sheet works, and closes it.
  • ⌘R / "Refresh data" now also refetches every mounted useResource (new invalidateAll in lib/resource.ts), not only the shell's status and overview — before, the page in front (key usage, client list, upstream stats…) did not refresh.

For the pages still in flight

  • Settings: when the page is restructured, keep a useNavParams("settings", …) handler that scrolls to p.section, and update palette/sections.ts (one entry per setting a user would search for — language, appearance, port… — each pointing at the section that now holds it; its titles come from each section's own i18n, so a moved or deleted i18n file shows up as a compile error there).
  • Traffic: the sheet's Traffic rows mirror the row keys in TrafficPage; change both together.

Decisions (made without asking, per the brief)

  • Actions keep a fixed order (muscle memory); recency lives in the Recent group, frequency only nudges search ranking.
  • Requests match by model or id only. Matching by upstream / key name flooded results with hundreds of near-identical rows; that is what Traffic's filters are for.
  • Selection and list scroll are computed during render together with the results. cmdk (with shouldFilter={false}) scrolled to the previously selected row when it was still in the new results, hiding the top of the list.
  • Focus on close goes back only to a text field that had it; never to a button (WebKit would draw a focus ring on a script-focused button).
  • "Check for updates" reports the result in a toast (notify.promise), because nothing on screen changes when there is no update; when there is one, Rust opens the update window as in Settings.
  • Section scrolling belongs to the Settings page, not the shell: a second scroller in App.tsx would fight the page's own once Settings gets its section index.
  • The dialog overlay stays the app-wide one for consistency.

Core

No core change needed. Possible follow-up: a core request search (by model / key over the whole history) would let the palette find requests older than the rows Traffic has loaded; today only ids outside that window are reachable.

Checks

pnpm typecheck, pnpm test (38 files / 320 tests, incl. palette tests for ranking, arrangement, usage, items gating and the wiring guard), pnpm build. Checked in the full-app preview harness after each rebase: light/dark, zh/en, 1100×720 and 820×560, empty install, core not running, remote read-only, Windows key caps; every action and entity opens the right page dialog (new route / dry run / group edit on the new Routing page, upstream edit on the new Upstreams page, key edit, client setup, Settings sections), and ⌘R refetches the Keys page's data.

🤖 Generated with Claude Code

fylorn and others added 2 commits September 25, 2026 07:35
- ⌘K palette on cmdk (src/ui/command.tsx, src/palette/): pages with
  ⌘1-⌘9, actions (new upstream / key / route / group / proxy / price
  sheet, inference and connection tests, routing dry run, search traffic,
  switch connection, add a remote connection, refresh, sidebar, config
  file, version history, check for updates, notices, shortcuts), and
  search over data already on hand: upstreams, keys, routes, groups,
  clients, connections, Settings sections and Traffic's loaded requests
  (by model, one row per model, or by id).
- The palette only navigates. Each item is nav.open(page, params) and the
  page opens its own dialog in useNavParams, exactly as its button or row
  click would; NavParams gains create / edit / test / dryRun / detail /
  setup / section. A source test checks every param the palette sends is
  read somewhere.
- Recent (last five used) above Pages and Actions; frequent use nudges
  search ranking. Names outrank aliases (other language, synonyms, URL).
- Switch connection is a second level (Esc / Backspace goes back); the
  current connection is listed but not selectable.
- ? (outside text fields) or the palette footer opens a shortcut sheet
  generated from the same key table as the palette caps and the sidebar
  tooltips (palette/keys.tsx). Sidebar items show their ⌘n in a tooltip.
- Global shortcuts do nothing while a form dialog is open; the palette
  and the sheet are passive, so ⌘4 read off the sheet works.
- Palette scales and fades in from the top; list height follows the
  results; selection and scroll are computed with the results so typing
  never scrolls to a stale row.
- Settings sections scroll into view when opened from the palette.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Cmd+R and the palette's "Refresh data" also refetch every mounted
  useResource (new invalidateAll in lib/resource.ts), not only the shell's
  status and overview, so the page in front actually refreshes.
- The Settings page handles nav.open("settings", { section }) in its own
  useNavParams (Config.tsx) instead of the shell scrolling for it; a
  restructured Settings page replaces that handler without a second
  scroller left behind in App.tsx. NavParams.settings.section is a plain
  string again; the palette's section ids live in palette/sections.ts,
  with a note on keeping them in step with the page.
- Rebased onto the Upstreams page (#193): the palette's dialog params are
  merged into the page's existing useNavParams handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant