Skip to content

[AI] Improve autocomplete sorting with tiered ranking#6972

Merged
matt-fidd merged 2 commits intoactualbudget:masterfrom
J-LCRX:tiered-autocomplete-sorting
Mar 23, 2026
Merged

[AI] Improve autocomplete sorting with tiered ranking#6972
matt-fidd merged 2 commits intoactualbudget:masterfrom
J-LCRX:tiered-autocomplete-sorting

Conversation

@J-LCRX
Copy link
Copy Markdown

@J-LCRX J-LCRX commented Feb 14, 2026

Summary

  • Replace binary match/no-match sorting in payee and category autocomplete dropdowns with a 4-tier ranking system: exact match, prefix match, word-boundary match, and substring match
  • Surfaces the most relevant results first (e.g. typing "me" shows "Me" before "Memory Express" before "French Meadow" before "Framework")
  • Extracts ranking logic into a shared, tested utility used by both PayeeAutocomplete and CategoryAutocomplete

Changes

  • New file: autocompleteRanking.ts
    • Shared rankAutocompleteMatch(name, input) function that returns a tiered rank:
      • exact (-4)
      • prefix (-3)
      • word-boundary (-2)
      • contains (-1)
      • no match (0)
    • Uses getNormalisedString for case/diacritic-insensitive comparison. Word boundaries are split on whitespace and hyphens.
  • PayeeAutocomplete.tsx
    • customSort now delegates to rankAutocompleteMatch instead of a simple includes check.
    • The "Create payee" option stays pinned first at rank -5.
  • CategoryAutocomplete.tsx
    • customSort now uses tiered ranking for category names, with group name matching as a
      fallback tier between name matches and no-match.
    • The "Split transaction" option stays pinned first at rank -6.
  • New file: autocompleteRanking.test.ts
    • 11 unit tests covering all tiers, case insensitivity, hyphenated boundaries

Test plan

  • New unit tests for rankAutocompleteMatch (11 tests covering all tiers, diacritics, case insensitivity, edge cases)
  • Existing PayeeAutocomplete tests pass (4/4)
  • yarn typecheck passes
  • yarn lint passes
  • Manual testing: type partial payee/category names and verify ordering matches expected tiers

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 28 14.78 MB → 14.78 MB (+484 B) +0.00%
loot-core 1 5.86 MB 0%
api 1 4.4 MB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
28 14.78 MB → 14.78 MB (+484 B) +0.00%
Changeset
File Δ Size
src/components/autocomplete/autocompleteRanking.ts 🆕 +507 B 0 B → 507 B
src/components/autocomplete/CategoryAutocomplete.tsx 📈 +35 B (+0.20%) 17.34 kB → 17.37 kB
src/components/autocomplete/PayeeAutocomplete.tsx 📉 -58 B (-0.33%) 16.94 kB → 16.89 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 9.51 MB → 9.52 MB (+484 B) +0.00%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 12.94 kB 0%
static/js/workbox-window.prod.es5.js 5.64 kB 0%
static/js/ca.js 96.92 kB 0%
static/js/da.js 106.62 kB 0%
static/js/de.js 180.44 kB 0%
static/js/en-GB.js 7.18 kB 0%
static/js/en.js 165.58 kB 0%
static/js/es.js 173.83 kB 0%
static/js/fr.js 179.97 kB 0%
static/js/it.js 171.44 kB 0%
static/js/nb-NO.js 157.23 kB 0%
static/js/nl.js 106.65 kB 0%
static/js/pl.js 88.64 kB 0%
static/js/pt-BR.js 154.57 kB 0%
static/js/sv.js 78.2 kB 0%
static/js/th.js 182.35 kB 0%
static/js/uk.js 215.11 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 120.54 kB 0%
static/js/ReportRouter.js 1.13 MB 0%
static/js/narrow.js 638.75 kB 0%
static/js/TransactionList.js 106.13 kB 0%
static/js/wide.js 165.25 kB 0%
static/js/AppliedFilters.js 9.71 kB 0%
static/js/usePayeeRuleCounts.js 10.05 kB 0%
static/js/useTransactionBatchActions.js 13.23 kB 0%
static/js/FormulaEditor.js 1.04 MB 0%

loot-core

Total

Files count Total bundle size % Changed
1 5.86 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.B2ZGg82M.js 5.86 MB 0%

api

Total

Files count Total bundle size % Changed
1 4.4 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
bundle.api.js 4.4 MB 0%

Replace binary match/no-match sorting in payee and category dropdowns
with a 4-tier ranking: exact match, prefix match, word-boundary match,
and substring match. This surfaces the most relevant results first
(e.g. typing "me" shows "Me" before "Memory Express" before "Framework").

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@actual-github-bot actual-github-bot Bot changed the title [AI] Improve autocomplete sorting with tiered ranking [WIP] [AI] Improve autocomplete sorting with tiered ranking Feb 14, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 14, 2026

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit b5407cc
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/6990a957ecc6f30008dbe06f
😎 Deploy Preview https://deploy-preview-6972.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Hello contributor!

We would love to review your PR! Before we can do that, please make sure:

  • ✅ All CI checks pass
  • ✅ The PR is moved from draft to open (if applicable)
  • ✅ The "[WIP]" prefix is removed from the PR title
  • ✅ All CodeRabbit code review comments are resolved (if you disagree with anything - reply to the bot with your reasoning so we can read through it). The bot will eventually approve the PR.

We do this to reduce the TOIL the core contributor team has to go through for each PR and to allow for speedy reviews and merges.

For more information, please see our Contributing Guide.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new ranking function for autocomplete matching and integrates it into category and payee autocomplete components. The rankAutocompleteMatch function assigns scores based on match quality (exact: -4, prefix: -3, word-boundary: -2, contains: -1, no match: 0) and normalizes strings for consistent comparison. Category and payee autocomplete components now use this function for improved dropdown sorting.

Changes

Cohort / File(s) Summary
Autocomplete Ranking Logic
autocompleteRanking.ts, autocompleteRanking.test.ts
New ranking module that exports rankAutocompleteMatch function scoring match quality across exact, prefix, word-boundary, and contains patterns. Comprehensive test suite validates ranking behavior across diacritics, case-insensitivity, and real-world payee scenarios.
Component Integration
CategoryAutocomplete.tsx, PayeeAutocomplete.tsx
Updated customSort functions to use rankAutocompleteMatch instead of simple boolean checks. Category component adjusts split item rank from -2 to -6; payee component changes new item rank from -2 to -5. Both now delegate sorting to the ranking function.
Release Documentation
upcoming-release-notes/6972.md
Added release note documenting the enhancement to autocomplete sorting with tiered ranking for payee and category dropdowns.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

suspect ai generated

Poem

🐰 Hops with glee through autocomplete delight,
Ranking matches from wrong to right,
Exact then prefix, boundaries in between,
The finest sorting we've ever seen!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (30 files):

⚔️ packages/desktop-client/e2e/transactions.test.ts (content)
⚔️ packages/desktop-client/e2e/transactions.test.ts-snapshots/Transactions-filters-transactions-by-category-1-chromium-linux.png (content)
⚔️ packages/desktop-client/e2e/transactions.test.ts-snapshots/Transactions-filters-transactions-by-category-2-chromium-linux.png (content)
⚔️ packages/desktop-client/e2e/transactions.test.ts-snapshots/Transactions-filters-transactions-by-category-3-chromium-linux.png (content)
⚔️ packages/desktop-client/e2e/transactions.test.ts-snapshots/Transactions-filters-transactions-by-category-7-chromium-linux.png (content)
⚔️ packages/desktop-client/e2e/transactions.test.ts-snapshots/Transactions-filters-transactions-by-category-8-chromium-linux.png (content)
⚔️ packages/desktop-client/e2e/transactions.test.ts-snapshots/Transactions-filters-transactions-by-category-9-chromium-linux.png (content)
⚔️ packages/desktop-client/src/components/AnimatedRefresh.tsx (content)
⚔️ packages/desktop-client/src/components/FinancesApp.tsx (content)
⚔️ packages/desktop-client/src/components/Modals.tsx (content)
⚔️ packages/desktop-client/src/components/Notes.tsx (content)
⚔️ packages/desktop-client/src/components/Notifications.tsx (content)
⚔️ packages/desktop-client/src/components/alerts.tsx (content)
⚔️ packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx (content)
⚔️ packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx (content)
⚔️ packages/desktop-client/src/components/filters/FiltersMenu.tsx (content)
⚔️ packages/desktop-client/src/components/reports/reports/CustomReport.tsx (content)
⚔️ packages/desktop-client/src/components/rules/RuleEditor.tsx (content)
⚔️ packages/desktop-client/src/components/rules/Value.tsx (content)
⚔️ packages/desktop-client/src/components/util/GenericInput.tsx (content)
⚔️ packages/desktop-client/src/hooks/useScrollListener.tsx (content)
⚔️ packages/desktop-client/src/index.tsx (content)
⚔️ packages/desktop-client/src/modals/modalsSlice.ts (content)
⚔️ packages/desktop-client/src/sync-events.ts (content)
⚔️ packages/loot-core/src/server/aql/compiler.ts (content)
⚔️ packages/loot-core/src/server/budget/category-template-context.ts (content)
⚔️ packages/loot-core/src/server/transactions/export/export-to-csv.ts (content)
⚔️ packages/loot-core/src/server/transactions/transaction-rules.ts (content)
⚔️ packages/loot-core/src/shared/rules.ts (content)
⚔️ packages/loot-core/src/types/models/rule.ts (content)

These conflicts must be resolved before merging into master.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change—implementing tiered ranking for autocomplete sorting across multiple components.
Description check ✅ Passed The PR description comprehensively explains the 4-tier ranking system, new shared utility, and specific changes to PayeeAutocomplete and CategoryAutocomplete components, directly matching the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch tiered-autocomplete-sorting
  • Post resolved changes as copyable diffs in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@J-LCRX J-LCRX changed the title [WIP] [AI] Improve autocomplete sorting with tiered ranking [AI] Improve autocomplete sorting with tiered ranking Feb 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions Bot added the Stale label Mar 17, 2026
@jfdoming jfdoming removed the Stale label Mar 17, 2026
Copy link
Copy Markdown
Member

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

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

Brilliant! Thanks for this, it's much more granular and seems to make searching in my budget file better

@matt-fidd matt-fidd added this pull request to the merge queue Mar 23, 2026
Merged via the queue into actualbudget:master with commit 429b189 Mar 23, 2026
37 checks passed
@J-LCRX
Copy link
Copy Markdown
Author

J-LCRX commented Mar 23, 2026

Happy to see this merged. Thanks for the positive comments Matt.

matt-fidd pushed a commit to matt-fidd/actual that referenced this pull request Mar 25, 2026
)

Replace binary match/no-match sorting in payee and category dropdowns
with a 4-tier ranking: exact match, prefix match, word-boundary match,
and substring match. This surfaces the most relevant results first
(e.g. typing "me" shows "Me" before "Memory Express" before "Framework").

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@Juulz Juulz mentioned this pull request May 4, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants