Fix Disconnect and saves in Bank sync connection rows

Merged
GA
2mo ago
+1296-1149

Problem

Each row under Your connections on Bank sync rendered its provider panel inside <turbo-frame id="<key>-providers-panel"> with no target. Every form and link in the panel was therefore a frame request.

  • Disconnect showed "Content missing".
    • Mercury, Brex and Wise redirect destroy to Accounts. Kraken, CoinSpot and others redirect to Bank sync, which has no row once the last connection goes.
    • Neither response contains the frame, so the row broke and no flash appeared. The item was still unlinked and scheduled for deletion.
    • Links to Accounts, SnapTrade's OAuth link and Wise's profile step failed the same way.
  • The second save left the row (Codex on #3834).
    • 15 panel roots share the frame's <key>-providers-panel id.
    • turbo_stream.replace resolves that id with getElementById, which returned the frame. The first save therefore swapped the frame for the bare panel.
    • The next save was no longer a frame request. For Mercury, Brex, IBKR, Trading 212, Lunch Flow, Wise and Sophtron, that fallback redirected to Accounts. For the other panels it reloaded Bank sync, and the morph refresh collapsed the open row.

The drawer's frame has target="_top", so its forms already post from the page and take that fallback. The fallback was broken in eight controllers.

Change

Seven commits. The first three fix the rows. The last four are follow-ups: one shared helper for the panel renders, the generator's Bank sync wiring, SimpleFIN's errors, and Sync inside an open row.

Keep page-level provider panel saves on the Bank sync page

  • Silent errors. Akahu, Coinbase, CoinStats, Enable Banking and Indexa Capital redirected errors with a 422. fetch doesn't follow a 422 Location and the body is empty, so Turbo showed nothing.
    • They now use a 303, as the other panels do, so the alert shows.
    • The provider generator's controller template had the same line and gets the same fix.
  • 500s. Mercury (create, update), Lunch Flow (update) and Sophtron rendered new/edit templates that don't exist.
    • They now redirect back with the alert.
    • Lunch Flow's update mirrors the fix its create got in #2724.
    • Sophtron's error helper drops the view_name it only used to pick the template.
  • Updates left the page. Updating a Mercury, Brex, IBKR, Trading 212, Lunch Flow or Wise connection, or generating Wise's SCA key, redirected to Accounts.
    • When Turbo asks for a stream, these now re-render their panel in place.
    • They use Trade Republic's turbo_panel_request? (turbo_frame_request? || request.format.turbo_stream?), moved to ApplicationController.
    • Wise and Brex share their error helper with create, so a failed connect in the drawer now shows its error in the drawer.
    • A successful Brex create still moves on to Accounts.
    • Lunch Flow's panel root gets the id its stream replaces.

Render connection row panels without a frame of their own

  • The panel renders straight into the row, so its forms post from the page, as the drawer's do.
    • Nothing else on the page is a frame, so a target="_top" frame would do nothing.
    • Rows get a <key>-connection id for tests.
  • Enable Banking's panel root gets enable_banking-providers-panel. EnableBankingItem::SyncCompleteEvent broadcasts a replace of that id, and only the frame carried it.

Keep the remaining provider panel saves in place on Bank sync

  • Every panel keeps its saves and errors in place.
    • Akahu, CoinSpot, CoinStats, Enable Banking, Fio, Indexa Capital, Kraken, Monobank, On-chain, Questrade, Redbark, Up and Sophtron: updates, and create or update errors, now answer turbo_panel_request? and replace the panel root.
    • The create errors for Mercury, IBKR, Trading 212, Lunch Flow, Coinbase and Binance do the same, so a failed connect keeps the drawer open with its error.
  • A successful create still reloads, which moves the new connection under Your connections. Where create shared its success helper with update, it now redirects directly.
  • Dead branches removed.
    • No panel create or update path checks turbo_frame_request? any more, since nothing sends the header to them. The checks that remain are in modal flows, which do send it.
    • Binance and Coinbase have no edit form, so their update just redirects.
  • Panel roots.
    • CoinStats, Indexa Capital, Questrade, Sophtron and Binance get the root id their streams target.
    • CoinSpot, Kraken and On-chain replace their panel instead of update, which nested a second copy inside it.
  • Generator.
    • rails g provider:family adds a FAMILY_PANELS entry instead of injecting a settings_section with a frame into show.html.erb.
    • It drops the reject condition that FAMILY_PANEL_KEYS already covers.
    • Its controller and panel templates follow the rules above.
    • The guide lists what a generated provider still needs to show under Your connections: a provider_summary case and the sync-health entries.
  • Redundant targets. Questrade's Disconnect and the Wallet account link drop a data-turbo-frame="_top" that no frame needs.
  • Tests. The PR's panel tests use as: :turbo_stream and assert_turbo_stream.

Render provider panel saves through one shared helper

  • ApplicationController#render_provider_panel(key, notice:, alert:, fallback_path:, **locals) replaces the hand-written replace-or-redirect in all 22 panel controllers and in the generator's controller template.
    • It finds the panel's turbo_id and partial through its FAMILY_PANELS key, which covers Trade Republic's trade-republic id.
    • An alert renders in the panel with a 422. A notice goes to the flash.
  • The per-controller helpers are gone. That includes a private render_provider_panel(flash_type, …) in Akahu, Up, Monobank and Fio, which would have shadowed the shared one. Wise keeps two one-line wrappers.
  • Locals that the panels never read, or that repeat their own default query, are dropped. CoinSpot's panel gets the default query Kraken's has.
  • The update notices lose English default:s that contradicted en.yml.
  • Two fallbacks change:
    • Lunch Flow's non-Turbo errors now go to Bank sync directly. They redirected back, which lands on Bank sync whenever the browser sends a Referer.
    • Questrade's error redirects are 303s.

List a generated family provider under Your connections

  • rails g provider:family now also adds the provider's provider_summary case and its PANEL_SYNCABLE_TYPES and family_panel_items entries. A connected provider then moves under Your connections, with a sync status and a working Sync button.
  • The guide and the generator's "Next steps" no longer list these as manual edits.

Show SimpleFIN's connection errors where the form was

  • The panel form sends source=panel, and its errors replace the panel, which now carries simplefin-providers-panel.
  • The new-connection modal sends the same Turbo request without the marker, so it still renders new with its error.
  • The edit modal showed no error at all. Its frame request got a stream aimed at a panel that the Accounts page doesn't have. It now gets the edit template.

Keep the open connection row open after its panel's Sync

  • 15 panels have a Sync button inside the open row. Their sync actions redirected back to Bank sync, and the morph refresh collapsed the row.
  • The panel buttons now send source=panel and re-render the panel in place with a "Sync started." toast. Trade Republic replaces only its card, as its login steps do.
  • The Accounts page's Sync buttons post to the same actions without the marker, and still redirect back.
  • Enable Banking's Sync drops data-turbo=false, which it had copied from Reconnect.

Screenshots

Disconnect from a connection row, before (left) and after (right). Before, the row shows "Content missing" and no flash. After, the page follows the redirect to Accounts and shows the flash.

Disconnect from a connection row, before and after

The rows themselves look the same, so the other changes only show after a click:

BeforeAfter
Disconnect"Content missing" in the row, no flashLands on its redirect target with the flash
Second saveLands on Accounts, or reloads Bank sync and closes the rowStays open in the row
Failed connect in the drawerNothing happens, or the drawer closes with an alertThe error shows in the drawer
Sync inside an open rowReloads Bank sync and closes the rowStays open, with a "Sync started." toast
Bad SimpleFIN token in the rowReplaces Bank sync with the new-connection modal pageThe error shows in the panel

Disconnect, the second save and Sync are system tests. Controller tests cover the drawer error (see Validation).

Validation

  • System tests (test/system/settings/providers_test.rb). Each fails on main's code:
    • Disconnect from the Mercury row lands on Accounts with the success flash.
    • Two saves from the Mercury row both stay on Bank sync. The second fails on main exactly as Codex described: expected "/accounts" to equal "/settings/providers".
    • Sync from the open Mercury row keeps the row open. With the old behaviour, every row collapses and no toast shows.
  • Controller tests, all red first:
    • 12 page-level error paths (422 or MissingTemplate).
    • In-place saves for the six providers and Wise's SCA key. The stream carries both the target and the root id, so a second save still finds it.
    • Rows contain no frame, and every -providers-panel id appears once.
    • Every streamed panel renders the root its streams and the Enable Banking broadcast replace (checked through the drawer for all of them).
    • Third commit: in-place saves for the 13 panels above; in-place create or update errors in 19 controllers; and creates that still redirect where they shared a helper with update.
    • Generator: the controller template renders valid Ruby with no turbo_frame_request?. The FAMILY_PANELS insertion works against the real controller. Both were red against the old generator.
    • Follow-ups, red first:
      • Panel Sync for all 15 panels.
      • SimpleFIN's panel error and its edit-modal error.
      • The three new generator insertions, run against the real helper and controller.
    • Guards that stayed green: Sync from the Accounts page still redirects back where no test covered it, and SimpleFIN's new modal still renders new.
  • Audit. Every control in the 25 panels was checked as a page-level submission. It found nothing beyond what this PR fixes.
  • bin/rails test: 10,261 runs, 0 failures, 0 errors, 33 skips.
  • bin/rails test:system for the first three commits: 171 runs, 0 failures, 1 error. The error is the date-dependent RecordNotFound in declare_and_pay_bill_test.rb, which fails on main too. For the follow-ups I ran the providers, on-chain wallet, accounts, sync UI and settings system tests: 39 runs, 0 failures.
  • RuboCop, erb_lint, Biome and Brakeman are clean.
  • git merge-tree against the 24 open PRs that touch these files finds these new conflicts:
    • #2906 (last updated 2026-09-12), in enable_banking_items_controller_test.rb. Every spot in that 66-line file overlaps a hunk from one of five open PRs.
    • #3548: both PRs add test/controllers/up_items_controller_test.rb.
    • #3511 and #3512: the CoinSpot and Fio controllers and their tests.
    • #3821: redbark_items_controller.rb.
    • #1832 (last updated 2026-09-12): sophtron_items_controller.rb.
  • git merge-tree for the follow-ups finds these new conflicts:
    • #3821: the six panel Sync buttons it turns into DS::Buttons. Keep its DS::Button, add source: "panel" to the href, and drop Enable Banking's turbo: false.
    • #3511 and #3512: the CoinSpot and Fio panels, which they add from an old base.
    • #3240 (last updated 2026-09-04): _ibkr_panel.html.erb.

Summary by CodeRabbit

  • Bug Fixes
    • Failed provider connection submissions now show validation alerts in the provider panel or return users to provider settings, depending on how they submitted the form.
    • Provider updates refresh the panel and display success or validation feedback.
  • Updates
    • Syncs started from provider panels now show an in-progress notice while keeping users on the page.
    • After creating a connection, users are redirected to the relevant settings or Accounts page.