feat(transactions): create a category from the list's quick category picker

Merged
SC
2mo ago
+686-42

Summary

The quick category picker you open from a transaction row can only assign existing categories. To use a new one ("Amazon Purchase", say), you have to leave for Settings → Categories, create it, and come back. #3088 added inline creation to the transaction form and drawer, but not to this picker, which is the one used most when working through a transaction list.

When the search matches no existing category name, the picker now shows Create "<name>" (click it, or press Enter).

How it works

  • It creates the category through the same POST /categories.json endpoint as #3088's inline create.
  • It then assigns the category by submitting the picker's normal update form (PATCH /transactions/:id/category). So the row refreshes in place, category usage is recorded, and the "create a rule?" prompt still appears. Create category → assign → create rule works in one pass.
  • The option is hidden when the query exactly matches an existing name (case-insensitive).
  • Enter only creates when no row matches. Otherwise Enter still picks the highlighted row, as before.
  • A small new Stimulus controller (category-quick-create) sits alongside list-filter. list-filter is unchanged.

Tests

  • Controller tests: the create option and the assign form are rendered and wired to the right transaction, and existing names are passed through for the exact-match check.
  • System test: open the row picker, type a new name, click Create. The category exists, and the row shows it.
  • System test: an exact (case-insensitive) match hides the create option.
  • The existing transaction_category_select_test.rb still passes. rubocop, erb_lint and biome are clean. No new i18n keys are missing or unused (i18n-tasks).

Screenshots

Rendered from test fixtures.

Typing a new name: Create + Add as a subcategory (no contradictory "No categories found")

<img src="https://raw.githubusercontent.com/scragnog/sure/pr-screenshots/2026-09-28/3772-create-options.png" width="420" alt="Typing a new name: Create + Add as a subcategory (no contradictory "No categories found")">

Add as a subcategory… → pick a top-level parent

Add as a subcategory… → pick a top-level parent

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Create and assign a category directly from the transaction category picker, or create a subcategory under a top-level category.
    • Creation is available only when you can annotate the transaction’s account and the entered name doesn’t match an existing category, regardless of capitalization.
    • Press Enter to create when no matching results are visible.
  • Bug Fixes
    • Errors are shown when category creation or assignment fails. If assignment fails after creation, retrying with the same name and parent reuses the category instead of creating a duplicate.