Derive family panels from adapter panel declarations

JA
6d ago
+177-117

Summary

Provider kit Track A, A3: Settings::ProvidersController::FAMILY_PANELS is derived from a panel: argument on each adapter's declares_connection instead of hand-kept.

Part of jaysbeekay/sure#670. Stacked on jaysbeekay/sure#686 (A2); built on the fork first and sent upstream as part of Track A's native stack on top of we-promise/sure#5005.

Upstream: we-promise/sure#5080 (same commits), in Track A's native stack we-promise/sure#5087.

What changed

  • declares_connection(..., panel: { title:, turbo_id:, auto_open: }): turbo_id defaults to the key and the partial is always <key>_panel. Stored as panel_declaration, separate from the connection entry, so ProviderConnectionStatus::PROVIDERS is unchanged.
  • 26 adapters declare their panel with the exact title from the old list. Trade Republic declares turbo_id: "trade-republic", SnapTrade auto_open: "manage". Plaid and FinanceKit declare none.
  • Provider::Factory.panel_declarations; FAMILY_PANELS = Provider::Factory.panel_declarations.freeze.
  • Generator: no longer patches FAMILY_PANELS; the adapter template always declares panel: (--skip-view now skips only the item views: the adapter still declares its panel, the panel partial is written and the Bank sync wiring runs, so every account provider has a panel). When the generator did not write the adapter (it existed, or --skip-adapter), it prints the declaration to add, since the derived lists (this one, PANEL_SYNCABLE_TYPES, PROVIDERS) would otherwise leave the provider out. Docs updated.

No visible change. The list's internal order becomes key order; Bank sync sorts rows by title, and every other reader (connect_form, render_provider_panel, FAMILY_PANEL_KEYS) looks panels up by key.

Review fixes (2026-11-15)

  • --skip-view conflicted with the panel test (every account provider but Plaid and FinanceKit has a panel with its partial). The generator now always declares the panel, writes the panel partial and wires Bank sync; --skip-view skips only the item views. Tests: the adapter declares panel:, the partial is written and Bank sync is wired with and without --skip-view; mutations restoring either skip are caught.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Old vs new (Rails runner against the removed literal): 26 = 26, same set of hashes.
  • New tests: every account provider but Plaid and FinanceKit has a panel with an existing partial and a unique title; exact entries for Brex plus the Fio title, Trade Republic turbo_id and SnapTrade auto_open; the generated adapter declares panel:, and the panel partial and Bank sync wiring are generated, with and without --skip-view; panel_declared? recognises a declaring adapter and rejects one without a panel, without a declaration, or with a different key.
  • Fail-first: the derivation test failed before the change (no panel_declarations). The invariants test passed on the old list too; it is a regression guard.
  • Mutations, each caught: drop Trade Republic's turbo_id; drop SnapTrade's auto_open; drop Wise's panel; the template never declaring a panel; the wrong partial name; panel_declared? always true.
  • eager_load! then FAMILY_PANELS.size = 26.
  • bin/rails test (full): 15,868 runs, 0 failures; 8 errors in ReleaseNotesWorkflowTest from node missing in the test image.
  • bin/rubocop on changed files: no offenses. bin/brakeman: no warnings.

Blast radius

  • FAMILY_PANELS readers: connect_form (find), ApplicationController#render_provider_panel (FAMILY_PANELS_BY_KEY.fetch), FAMILY_PANEL_KEYS (include?/any?), build_provider_entries (sorted by title). None depends on order or hash key order.
  • PANEL_SYNCABLE_TYPES (A2) filters by FAMILY_PANEL_KEYS, now also derived; it is unchanged (its test still passes).