Set up Lunch Flow accounts through the provider kit's setup
Summary
Lunch Flow controller convergence, C1f: setting up imported accounts. Lunch Flow's setup_accounts and complete_account_setup now run through the provider kit's account setup (ProviderItem::AccountFlow::Setup) instead of their own code, so they behave as Brex's do. As the owner decided, the setup page now always fetches the connection's accounts. Before, it fetched only while the connection had none, so accounts added at Lunch Flow later never appeared.
Part of jaysbeekay/sure#670 (Track B, controller-layer convergence, option (b) and the setup decision, owner 2026-11-16). Stacked on C1e (jaysbeekay/sure#734) in fork stack #687.
Upstream draft PR: https://github.com/we-promise/sure/pull/5246 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.
Behaviour delta (Lunch Flow)
| Before | After | |
|---|---|---|
| Opening the setup page | fetched accounts only when the connection had none | always fetches; new accounts are imported, and an imported account is re-imported when the provider now reports it differently |
| The API fails while the page loads | accounts already imported were still listed | the page shows "Failed to Fetch Accounts" (the kit's behaviour) |
| An unexpected fetch error | "API error: " | "API error: An unexpected error occurred. Please try again later." |
| No API key | setup_accounts.no_api_key | setup_accounts.no_api_token, same text in every locale |
| Subtype labels a locale lacks | the app-wide translated subtype name | unchanged, through a new kit hook (subtype_label_default) Lunch Flow overrides |
| Completing with nothing to create | a notice, and a Turbo stream in a frame | an alert, redirect to /accounts, no stream (the kit's rule: success means at least one created and none failed) |
| All accounts skipped | notice "All accounts were skipped" | the same text as an alert |
| An account type Lunch Flow doesn't support | ignored, not counted | counted as skipped |
| A subtype not offered for any supported type | stored as submitted | dropped |
| Depository with no subtype chosen | no subtype | checking (the kit's default; CreditCard already defaulted) |
| One account fails validation | the whole setup rolled back with "Failed to create accounts: …" | the others are created; "Successfully created 1 account(s), but 1 account(s) failed." |
What changed
LunchflowItemsController#setup_accounts/#complete_account_setupcall the flow; Lunch Flow's own fetch, option building, setup loop and messages go. The kit controller's param sanitizers and Turbo-stream rebuild are copied in until the controller itself moves onto the kit.LunchflowItem::AccountFlow:provider_account_snapshot_changed?(the stored payload differs from the reported one) andsubtype_label_default(the app-wide translated name).ProviderItem::AccountFlow::Setup#translate_subtypes: the fallback label comes from a newsubtype_label_defaulthook, whose default is the kit's previous expression, so Brex is unchanged.- Locales (16):
setup_accounts.no_api_key→no_api_token, translations kept (ro.ymlalready usedno_api_token); English addspartial_success,partial_skippedandcreation_failed_count(other locales fall back to English for those).
Demo data
No demo data needed.
Migration notes
No migration.
Verification
- Tests (fail-first): new
LunchflowItemsSetupTest(10 tests): always fetching (a new account appears although the connection has some); re-importing a changed account; leaving an unchanged one alone; the translated unexpected error; no API key; nothing to create (alert, no stream); unsupported type counted as skipped; Depository defaulting tochecking; an unknown subtype dropped; one failing account not undoing the other. On the old code all 8 behaviour tests fail. - Existing tests changed, as the owner decided: "setup accounts renders German subtype options…" and "setup accounts preserves the English title…" pinned fetch-only-when-empty: with no API stub, the old page never called the API. They now stub the fetch to return no accounts, and their assertions are unedited. "complete_account_setup's stream lists only the manual accounts the viewer can access" posted empty params and relied on a stream for zero accounts; it now submits one account so the stream is rendered, and its assertions are unedited. The two German/English unexpected-error setup tests pass unedited.
- Mutations, each caught: Lunch Flow's subtype labels falling back to English (the German test); never re-importing a changed account; always re-importing; completing always streaming; subtypes not sanitized.
bin/rails test(full, at the C1f commit): 16,381 runs, 0 failures; the same 8ReleaseNotesWorkflowTesterrors (nonodein the test image).bin/rubocopon changed files: no offenses.bin/brakeman: no warnings. Every locale file parses.- Size: non-test +81 / -213.
- Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.
Blast radius
ProviderItem::AccountFlow::Setup#translate_subtypesalso serves Brex; its default label is unchanged (Brex's setup snapshot test passes unedited).- The setup page's view reads
@api_error,@lunchflow_accounts,@account_type_optionsand@subtype_options, all still set. - Siblings: Mercury converges in its own slices.
Review notes
A code review of the diff before commit raised ten points; all are the kit's existing behaviour, which this slice adopts by design, so none changed it. They are listed for the conversion and for follow-ups:
- an API outage now blocks setting up accounts already imported (the table above);
- per-account transactions: an unexpected non-validation error partway leaves earlier accounts created with no sync queued;
- "all skipped" and partial results are alerts;
- subtypes are checked against every supported type, not the chosen one. Before, any value was stored;
- the controller helpers copied from
ProviderItemsControllergo when the controller moves onto the kit (B7); - fixing the kit's subtype-label default for every provider would change Brex's labels, so it is a follow-up, not part of this convergence;
- the snapshot check compares the payload only. Before, existing accounts were never re-imported at all;
- the family-currency fallback can't apply:
LunchflowAccountvalidatescurrencypresence and its upsert always sets one; - the setup fetch doesn't use the 5-minute cache, as on the kit;
- the new English keys aren't translated, as in earlier convergence slices.