Consolidate fuzzy-scoring into shared core + remove wasted structuredClone (fixes #33)#38
Conversation
…Clone (#33) - Add src/search-ranking.ts with scoreNormalizedNonEmpty shared core - Rewrite scoreText in filtering.ts as wrapper (preserves empty→1) - Rewrite scoreNormalized in search-utils.ts as wrapper (preserves empty→0) - Remove discarded structuredClone(sorted) from search hot path - Add src/search-ranking.test.ts with 21 tests (core + both wrappers) - Update check-clone-safe-actions.cjs for clone removal - Rename debug span search.sort-prepare-clone → search.sort-prepare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughThis PR consolidates duplicated fuzzy-match scoring logic into a shared module and removes a wasteful Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Deduplicates the two copies of the fuzzy-match scoring algorithm into one shared module, and removes a wasted
structuredClonefrom the search hot path.Changes
src/search-ranking.ts(new) — SharedscoreNormalizedNonEmpty(text, query)core (100/80/50/20/0 bands)src/filtering.ts—scoreTextnow a thin wrapper (delegates to core, preserves empty→1)src/electron/search-utils.ts—scoreNormalizednow a thin wrapper (delegates to core, preserves empty→0, keepsnormalize)src/electron/main.ts— Removed discardedstructuredClone(sorted)(wasted cycles every keystroke); renamed debug spansrc/search-ranking.test.ts(new) — 21 tests covering core bands + both wrapper contractsscripts/check-clone-safe-actions.cjs— Updated regex guard for clone removalVerification
pnpm typecheck✅palette:debugranking output unchanged ✅Closes #33
Summary by CodeRabbit
Refactor
Tests