feat(transactions): suggest category from past transaction names

Merged
HO
1mo ago
+453-174

Summary

  • Typing a transaction's "Description" now shows an autocomplete of past transaction names that resemble it, via a new Transaction.name_suggestions_for query and a hotwire_combobox-backed field.
  • Picking a suggestion fills in both the name and the category most commonly used for that name; a manual category pick always wins over the suggestion.
  • Fixes a font-size regression on hotwire_combobox inputs, which didn't inherit form-field__input's text-sm like the rest of the form fields.

Test plan

  • bin/rails test test/models/transaction_test.rb test/controllers/transactions_controller_test.rb
  • bin/rubocop
  • bundle exec erb_lint ./app/**/*.erb -a
  • bin/brakeman --no-pager
  • Manually verified in a browser: typing a past transaction name shows matching suggestions with a category preview badge, selecting one fills name + category, and a manual category override is never clobbered by re-selecting a suggestion afterward.

Summary by CodeRabbit

  • New Features

    • Added transaction name suggestions while entering transactions.
    • Suggestions are ranked by frequency and may include the most-used category.
    • Selecting a suggested name can automatically apply its category.
    • Suggestions respect account access permissions and require at least three characters.
    • Added a free-text combobox for transaction names.
  • Bug Fixes

    • Existing or manually selected categories are preserved over automatic suggestions.
    • Improved handling of blank category selections.
  • Tests

    • Added coverage for suggestions, category metadata, result limits, access restrictions, and blank selections.