Skip to content

Add command palette (Ctrl/Cmd+P) with action search and fuzzy file search - #1415

Open
magnusrodseth wants to merge 1 commit into
CyberTimon:mainfrom
magnusrodseth:feat/command-palette
Open

Add command palette (Ctrl/Cmd+P) with action search and fuzzy file search#1415
magnusrodseth wants to merge 1 commit into
CyberTimon:mainfrom
magnusrodseth:feat/command-palette

Conversation

@magnusrodseth

Copy link
Copy Markdown
Contributor

Description

Implements the command palette proposed in #1414. Ctrl+P (Cmd+P on macOS) opens an overlay with two levels. The root level lists every keybindable action that applies in the current context, showing each action's current combo. A pinned entry, "Search files...", drills into a fuzzy file search over the current folder. The two-level design keeps the root palette uncluttered instead of mixing dozens of filenames into the action list on the first keystroke.

Design choices, following the plan in the issue since the questions there are still open:

  • The palette reads KEYBIND_DEFINITIONS plus the user's remaps, so labels and combos stay in sync with Settings > Keybinds automatically, and open_command_palette itself is a regular rebindable action that shows up there like any other.
  • Actions are filtered by the same shouldFire guards the keyboard hub uses, so in the library you only see library-applicable actions and in the editor the editor ones. Execution reuses the exact handler map from useKeyboardShortcuts through a small runner registered in the UI store (same pattern as customEscapeHandler), so palette execution and keybind execution cannot drift apart.
  • Matching is a small hand-rolled fzf-style subsequence scorer (src/utils/fuzzyMatch.ts, under 50 lines) with bonuses for consecutive and word-start matches, in keeping with how computeSortedLibrary hand-rolls its matching today. No new dependencies.
  • File results are ranked and capped at 100, so no virtualization is needed. Matched characters are highlighted, and file rows show the image thumbnail when one is already generated.
  • The UI follows ConfirmModal (overlay, mount/show transitions, theme variables) and Dropdown (list styling). Escape backs out one level (files, then root, then closed), Backspace on an empty query in file mode also goes back, arrows navigate with wraparound, Enter executes.

Opening as a draft while the design questions in #1414 are unanswered. Happy to adjust scope or details, or drop it entirely if a palette is not wanted.

Closes #1414

Type of Change

  • New feature

Changes Made

  • src/utils/keyboardUtils.ts: new open_command_palette definition (Ctrl+P, library section)
  • src/utils/fuzzyMatch.ts (new): subsequence scorer returning a score plus matched character positions
  • src/store/useUIStore.ts: isCommandPaletteOpen flag and a keybindActionRunner slot
  • src/hooks/useKeyboardShortcuts.ts: handler for the new action, palette flag added to the modal guard, runner registration exposing canRun/run over the existing handler map
  • src/components/modals/CommandPaletteModal.tsx (new): the palette itself
  • src/components/modals/AppModals.tsx: palette registration, wired to handleImageSelect
  • src/i18n/locales/*.json: 7 new keys in all 12 locales

Screenshots/Videos

Screenshots of the root palette, fuzzy action filtering, and file search mode to follow.

Testing

  • I have tested these changes locally and confirmed that they work as expected without issues

Verified in the macOS dev build:

  • Ctrl+P opens the palette from both library and editor views, and respects the existing modal and input-focus guards
  • The root palette filters as you type and executes actions through the real handlers (verified with toggle_presets, which is correctly only offered while an image is open)
  • "Search files..." enters file mode. Queries narrow live over the folder's image list, the empty result state renders, and Enter opens the selected image in the editor
  • Arrow keys move the selection with wraparound and Enter executes the highlighted row
  • Escape steps back from file mode to the root palette and closes it from the root. Query and mode reset between opens
  • npm run build and prettier --check pass on the changed files. tsc, eslint and i18n:check outputs were diffed against main and show no new issues (all three already fail on current main)

Test Configuration:

  • OS: macOS 26.5 (Tahoe)
  • Hardware: Apple M3 Max

Checklist

  • My code follows the project's code style
  • I haven't added unnecessary AI-generated code comments
  • My changes generate no new warnings or errors

Additional Notes

Ctrl+P is currently unbound (toggle_presets is bare P, and the combo system distinguishes modifiers), so there is no conflict. Android behavior is unchanged since the palette only opens via the keybind. Related groundwork lives in #1413, which touches the same registry; if both land, the later one needs a trivial rebase in useKeyboardShortcuts.ts and the locale files.

AI Disclaimer:

Please state the involvement of AI in this PR:

  • This PR is entirely AI-generated
  • This PR is AI-generated but guided by a human
  • This PR was handwritten with AI assistance (spell check, logic suggestions, error resolving)
  • This PR contains only blood, sweat, and coffee (AI-free)

@magnusrodseth
magnusrodseth force-pushed the feat/command-palette branch from 5842d3e to 6e8777c Compare July 25, 2026 14:18
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.

FEATURE: Command palette (Ctrl/Cmd+P) with fuzzy any-file search

1 participant