Stop broadcasting provider cards to the whole family
Summary
When a provider connection finishes syncing, its SyncCompleteEvent re-renders the connection's card and broadcasts it on the family Turbo stream. Every signed-in family member subscribes to that stream. The broadcast is rendered in a job with no viewer, and the card lists every account on the connection. So a member who was shared only some of a connection's accounts receives the names and balances of the rest over the WebSocket, and their filtered card is replaced by the full one on screen. This PR removes those card broadcasts. The family sync toast, which already makes each browser re-fetch its own page on an authenticated request, carries the update instead.
Closes #3630
Fork pre-flight PR: jaysbeekay/sure#352 (same branch, same commit; its CI and review history are there).
Rebased onto main after #4044 merged (10 Oct). #4044 was squash-merged as 94e71a8c2, so this branch now sits directly on it and carries only its own two commits (131541c01, 1a7a9b770). The squash is identical to #4044's head (745b2a06c), and this PR's own diff is unchanged by the rebase.
What changed
- Provider events: the card
broadcast_replace_tois removed from the 21*_item/sync_complete_event.rbfiles that had one. Every one of them already ends withfamily.broadcast_sync_complete, except Kraken and CoinSpot, which now send it in place of the card. - On-chain wallet:
OnchainWalletItem::SyncCompleteEventbroadcast the settings wallet row (onchain_wallet_items/_onchain_wallet_item), which names every address on the wallet, to the family stream. It now sends the toast instead. An admin on Settings › Providers sees the new state through the toast's re-fetch. - SimpleFIN:
SimplefinItem::SyncerandSimplefinItem::BalancesOnlyJobrendered the card withApplicationController.renderand broadcast it. They already sendfamily.broadcast_refreshright after, so the card render is dropped. - Questrade and Indexa activity jobs:
broadcast_updatessends the toast instead of the card. - Generator:
lib/generators/provider/family/templates/activities_fetch_job.rb.ttfollows the same pattern, so a newly generated provider doesn't bring the broadcast back.
Deliberately not changed:
- What a card lists when it is rendered in a request. That part of #3630 is in #4048. The two are independent and touch different files. Each closes one route, and #3630 needs both. This PR carries the closing keyword, so it's best merged after, or together with, #4048.
Account::SyncCompleteEvent's per-account row broadcast and the controllers that rebuild#manual-accounts. These are the same pattern for other data, and they're tracked separately.EnableBankingItem::SyncCompleteEvent: #4044 (merged) removed its settings panel broadcast, and this PR removes its card broadcast. With both, the event sends only the sync toast. #4044's test asserts only the toast, so it holds with or without this PR.
Behaviour change
- Cards no longer update in place after a sync. They refresh through the sync toast: an idle page morph-refreshes, and a page with an open form shows the refresh button instead.
- Five more senders of the toast. Kraken, CoinSpot and on-chain wallets didn't send it before and now do, and so do the Questrade and Indexa activity jobs. The toast also schedules
RecurringTransaction.identify_patterns_for, which is debounced, so the extra calls are harmless. - Trading 212 now gets its toast. On
main, its card readsCurrent.user.accessible_accounts, which raises when the card is rendered from the broadcast (there is noCurrent.userin a job).Sync#perform_post_synconly logs that error, so Trading 212 never reachedfamily.broadcast_sync_complete. Removing the broadcast fixes it.
Scope
This PR closes the card route on the family stream. Account rows are still broadcast, with name and balance, by Account::SyncCompleteEvent, so a member still receives an unshared account's row until #4050 lands. #4048 closes the request side, where the card lists only the accounts the viewer can see. Each of the three closes a different route.
Demo data
No demo data needed.
Screenshots
No visual change. The card on /accounts looks the same; it updates through the existing sync toast instead of an in-place replace.
Migration notes
No migration.
Verification
Tests were written first and run against main (a92dec1e6):
ProviderItemSyncCompleteEventsTestruns every provider's event: the fixture-backed ones (binance, coinspot, fio, ibkr, indexa_capital, kraken, lunchflow, mercury, monobank, plaid, redbark, simplefin, snaptrade, trade_republic, trading212, wise), and akahu, coinbase, coinstats, sophtron and up built in the test. It also runs the Questrade and Indexa activity jobs. It asserts no stream targets the card'sdom_id, and thatsync-toastis sent. Onmain, all 23 fail (trading212 raises while rendering its card without a viewer).OnchainWalletItem::SyncCompleteEventTest: no stream targets the wallet row, none contains the truncated address, and the toast is sent. It fails onmain.PlaidItem,KrakenItemandIbkrItemSyncCompleteEventTest: each fails onmain.
With the change: 223 runs across every *_item/sync_complete_event test, test/models/simplefin_item and test/jobs, 0 failures.
Commands:
bin/rails teston1a7a9b770(rebased ontomain94e71a8c2): 11,072 runs, 47,021 assertions, 0 failures, 0 errors, 34 skips. Earlier, stacked on #4044 at778362d87: 10,871 runs, 0 failures.bin/rubocopon the changed Ruby files: no offenses.bin/brakeman --no-pager: 0 warnings.- No ERB or JavaScript changed.
Blast radius
*::SyncCompleteEvent#broadcastis only reached throughSyncable#broadcast_sync_complete, fromSync#perform_post_sync.- The toast it now relies on is
Family::SyncCompleteEvent, which rendersshared/notifications/sync_toastandaccounts/sync_controls. Neither contains account data. The recurring-pattern job it schedules is already debounced, so an extra toast is harmless. - Linked accounts still get
account.broadcast_sync_completefrom the item events, unchanged. - Siblings:
git grep broadcast_replace_tooverapp/models,app/jobsandlib/generatorsleaves:Family::SyncCompleteEvent: no account data.GenerateInsightsJob's badge: a count only.Account::SyncCompleteEvent: tracked separately.EnableBankingItem::SyncCompleteEvent's panel: removed by #4044 (merged).
Summary by CodeRabbit
- Bug Fixes
- Sync updates now refresh each browser through its own authenticated request instead of replacing shared connection cards. This prevents account details from appearing to viewers who may not be authorized to see them.
- Sync-complete notifications continue to appear for linked accounts and their families.