Derive the /accounts empty state from the declared connections

Merged
JA
2d ago
+49-9

Summary

Provider kit Track A, A9 (the last derived list): the /accounts empty state is decided by AccountsController#accounts_index_empty?, from the declared connections, instead of a hand-kept chain of 29 .empty? checks in accounts/index.html.erb.

Part of #5003

Stacked on #5085 (A8), in Track A's native stack on #5005.

Fork pre-flight: jaysbeekay/sure#694 (same commits, against a mirror of upstream main; its CI, Gatekeeper and review history live there).

What changed

  • accounts_index_empty? (private, exposed with helper_method): no manual accounts, no Apple Wallet accounts, and no visible connections for any INDEX_CONNECTIONS provider. The view calls it; the logic leaves the ERB.
  • The provider:family generator no longer gsubs the new provider into the old chain. Its pattern (@coinstats_items.empty? %>) had already stopped matching, so generated providers were missing from the empty check; they are now counted through their declaration. The generator still adds the provider's section.
  • Diff: non-test +11 / −9.

No visible change.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Old vs new (Rails runner evaluating the removed ERB condition against the new method): 30 cases (everything empty; each of the 29 lists non-empty alone), 0 differences, the same 29 lists on both sides.
  • Fail-first: "the index is empty only when no account or connection is listed" failed before the change (no predicate). "index shows the empty state for a family with nothing to list, and not once it has a connection" clears the empty fixture family's IBKR, Indexa Capital and SnapTrade connections first, then adds one Brex connection.
  • Mutations, each caught: drop the Apple Wallet check; drop the manual-accounts check; any? instead of all?; ignore connections; negate the view condition.
  • bin/rails test (full): 15,885 runs, 0 failures; 8 errors in ReleaseNotesWorkflowTest from node missing in the test image. After rebasing the stack onto upstream main (dbeebf14c), the full suite at the top of the stack (A9): 16,246 runs, 0 failures, the same 8 environment errors.
  • bin/rubocop and erb_lint on changed files: no offenses. bin/brakeman: no warnings.

Blast radius

  • Only AccountsController#index renders accounts/index, after setting every variable the method reads; the item controllers' turbo streams render accounts/index/manual_accounts, which does not use the condition.
  • The generator's "already has" check now matches only the provider's section, which is what it should detect.
  • Track A's derived lists are complete with this slice; the Family includes and the /accounts index sections stay hand-kept until Track B.

Screenshots

Fixture family empty with every connection and account removed, so /accounts shows its empty state. Base is #5085's head; both render the same empty state, as expected for a change that only moves the condition out of the view.

LightDark
Before (#5085 head)before-lightbefore-dark
After (this PR)after-lightafter-dark

Summary by cubic

The /accounts empty state is now derived from Provider::Factory connection declarations via AccountsController#accounts_index_empty?, replacing a hand-kept chain of 29 .empty? checks in the view.

  • The predicate treats the index as empty only when there are no manual accounts, no FinanceKit accounts, and no visible connections for any INDEX_CONNECTIONS provider.
  • The provider:family generator no longer gsubs new providers into the old chain, whose pattern had stopped matching; generated providers are now counted through their declaration, and the generator still adds the provider's section.
  • Tests pin the predicate to the exact 29 lists the view checked and cover the view from empty to having a connection.

No visible change.

Summary by CodeRabbit

  • Bug Fixes
    • The accounts page now displays its empty state only when there are no manual accounts, FinanceKit accounts, or visible accounts from connected providers.
    • Families with no listed accounts or connections see the empty-state message until they connect a provider. Once a provider connection is added, the page reflects the connection’s visible accounts when determining whether to show the empty state.