Skip to content

✨ Fuzzy search for command palette + Cmd+P project switcher (#34, #35)#38

Merged
vaayne merged 5 commits intomainfrom
feat/fuzzy-search-and-project-switcher
Apr 2, 2026
Merged

✨ Fuzzy search for command palette + Cmd+P project switcher (#34, #35)#38
vaayne merged 5 commits intomainfrom
feat/fuzzy-search-and-project-switcher

Conversation

@vaayne
Copy link
Copy Markdown
Owner

@vaayne vaayne commented Apr 2, 2026

Summary

Implements two related features:

🐛 Fix: Command palette fuzzy matching (#35)

  • Rewrote FuzzyMatcher from prefix/substring-only to true non-contiguous character matching with graduated scoring
  • Queries like opr now match Open Project, cw matches Create Worktree
  • Scoring rewards: prefix matches, word boundary matches, consecutive matches
  • Scoring penalizes: gaps between matched characters
  • Uses O(qLen × cLen) DP approach — no exponential worst-case

✨ Feature: Quick project switching with Cmd+P (#34)

  • Cmd+P opens the command palette filtered to projects only with a "Switch project..." placeholder
  • Cmd+Shift+P continues to open the full palette (unchanged)
  • Reuses existing palette infrastructure via a filter-based approach — no new controllers

Other improvements

  • Fixed duplicate "Set Worktree Status" block in CommandPaletteDataSource.allItems()
  • Added itemFilter property to CommandPaletteDataSource for extensible filtered modes
  • Extracted presentPalette() helper to deduplicate show() / showProjectsOnly()
  • Added localization strings (en + zh-Hans)

Testing

  • All 742 assertions pass (mise run test)
  • Release builds pass for both Mori and mori CLI
  • Added 2 new test functions: testFuzzyMatcherNonContiguous, testFuzzyMatcherNonContiguousNoMatch
  • Updated existing tests to use relative ordering assertions (appropriate for graduated scoring)

Closes #34, closes #35

vaayne added 3 commits April 2, 2026 15:55
Replace prefix/substring-only FuzzyMatcher with non-contiguous character
matching. Scoring rewards consecutive matches, word boundary matches, and
prefix matches while penalizing gaps.

Also fix duplicate 'Set Worktree Status' block in CommandPaletteDataSource
and add itemFilter support for filtered palette modes.
Add showProjectsOnly() to CommandPaletteController that opens the palette
filtered to projects only with a 'Switch project...' placeholder.
Bind Cmd+P in AppDelegate key monitor.

Reuses existing palette infrastructure with a filter-based approach
rather than a separate controller.
- Replace recursive FuzzyMatcher with O(qLen*cLen) DP approach to
  eliminate exponential worst-case
- Clamp scores to >= 1 (never return negative for valid matches)
- Cap consecutive bonus at 5 to prevent unbounded growth
- Extract presentPalette() helper to deduplicate show/showProjectsOnly
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65b0ead691

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +85 to +87
if prevRow[c - 1].score > bestPrevScore {
bestPrevScore = prevRow[c - 1].score
bestPrevIndex = c - 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Consider gap penalty when choosing predecessor state

The DP optimization keeps only the maximum previous score (bestPrevScore) and reuses its index for option A, but option A’s transition cost includes a gap-dependent penalty, so the best predecessor is actually argmax(prevScore - gapPenalty) for each c, not simply argmax(prevScore). This can produce suboptimal fuzzy scores and mis-rank results (e.g., a closer match can score lower than a farther one when the farther path had a slightly higher prior score), which directly affects command palette ordering.

Useful? React with 👍 / 👎.

vaayne added 2 commits April 2, 2026 16:19
Track far predecessors (gap >= maxGap, constant penalty) separately
and check near predecessors individually, since the optimal predecessor
depends on both score and distance — not just max score.

Addresses Codex review comment on PR #38.
When the project-only palette (Cmd+P) is visible and user presses
Cmd+Shift+P, switch to full palette instead of dismissing.
Also fix stale comment referencing removed variable name.
@vaayne vaayne merged commit a967a64 into main Apr 2, 2026
5 checks passed
@vaayne vaayne deleted the feat/fuzzy-search-and-project-switcher branch April 2, 2026 08:57
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.

Bug: Command palette search lacks fuzzy matching Feature: Quick project switching with Cmd+P

1 participant