Skip to content

fix(wallet): match the Key column filter to what the column displays - #219

Merged
argszero merged 1 commit into
mainfrom
fix/transactions-key-filter-empty-name
Sep 13, 2026
Merged

argszero merged 1 commit into
mainfrom
fix/transactions-key-filter-empty-name

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

The transactions table's Key column and its Key column filter disagreed on what "the key's name" is.

  • The column renders key_name || key_label (JS || treats "" as absent), so a key whose api_keys.name is empty shows the fallback label — e.g. deepseek / deepseek-paygo (from the upstream key's note / provider / plan).
  • The server-side filter compared COALESCE(ak.name, <key_label>). COALESCE only falls back on NULL, but api_keys.name is TEXT NOT NULL DEFAULT '' — and the distribution key auto-created at login is exactly that (dao::get_or_create_api_key inserts with name = '').

Result: for the common case (user's auto-created key, never renamed), typing into the Key filter the text the table displays returned 0 rows.

Fix: normalise the empty name to NULL first (NULLIF(ak.name, '')) so the filter and the renderer share one definition. ASCII names and named keys are unchanged.

Related Issue

(none — self-discovered during recon; no matching open issue)

Changes

  • src/routes/wallet.rs — tx_where key_name branch: COALESCE(NULLIF(ak.name, ''), …), with the reasoning recorded in the comment.
  • New regression test transactions_key_filter_matches_the_displayed_fallback (seeds an empty-name distribution key, asserts the displayed fallback matches; named-key positive control; negative control after rename).

Tests

  • cargo test — 223 passed (was 222; +1 new test)
  • cargo fmt --check passes
  • cargo clippy --all-targets clean, no new warnings

A/B: reverting only the one-line fix makes exactly the new test fail (rejects the pre-change tree); 222 other tests stay green.

Checklist

  • Branch name follows convention (fix/…)
  • Commit message uses Conventional Commits
  • Single responsibility, minimal change

The transaction table's Key column renders `key_name || key_label` (JS `||`
treats the empty string as absent), but the server-side `key_name` column
filter compared `COALESCE(ak.name, <key_label>)` — and COALESCE only falls
back on NULL.

`api_keys.name` defaults to the empty string, not NULL (`name TEXT NOT NULL
DEFAULT ''` in db.rs), and the distribution key auto-created at login is
exactly that (`dao::get_or_create_api_key` inserts `''`). So for the common
case the column shows the fallback label ("deepseek / deepseek-paygo") while
filtering by that very text returned 0 rows.

Normalise the empty name to NULL before the COALESCE (`NULLIF(ak.name, '')`)
so the filter and the renderer share one definition of "the key's name".

Regression test seeds an empty-name distribution key and asserts filtering by
the displayed fallback matches it, plus a named-key positive control and a
negative control (after renaming, the old fallback no longer matches).
@argszero
argszero merged commit 0feae18 into main Sep 13, 2026
1 check passed
@argszero
argszero deleted the fix/transactions-key-filter-empty-name branch September 13, 2026 19:41
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.

1 participant