mirror of
https://github.com/we-promise/sure.git
synced 2026-12-03 10:49:07 +08:00
## Summary
Brex, Lunch Flow, and Mercury each maintained their own connection
setup, account linking, and sync lifecycle. This PR moves those three
providers onto shared Rails models, controllers, and view components.
Account-provider adapters declare their connections in one place, which
supplies the lists used by Bank Sync, the Accounts page, and the
connection-status API. The `provider:family` generator now builds on the
same kit.
This brings the 56 reviewed changes from [stack
#5268](https://github.com/we-promise/sure/stack/5268) onto `main`, in
their original order. Refs #5003.
## Behavior to review
- Brex, Lunch Flow, and Mercury share the account-selection and setup
flows. Account cards and post-setup Turbo updates respect the viewer’s
account access, including for family admins.
- Editing a Lunch Flow connection keeps its stored API key out of the
rendered form. A blank secret on edit preserves the existing credential.
- Mercury validates every transaction page before saving the account’s
fetch. Malformed pages, repeated full pages, and page limits leave the
stored transactions intact and retain the retry date. A successful
explicit window that starts later also preserves the earlier retry date.
Both Lunch Flow and Mercury honor an explicit sync start date.
- Linking an existing account requires ownership or a full-control
share. Link submissions recheck the upstream account list, and rotating
credentials isolates in-flight discovery results. Settings panels show
connection-wide counts only when the admin can see all linked accounts.
- Stored accounts remain available during a setup refresh outage.
Generated investment providers offer Crypto with wallet and exchange
subtypes. Each subtype picker has its own accessible label, and its
blank choice is keyboard-selectable.
- Sync statistics count linked and unlinked accounts in a single query.
Lunch Flow reports balance-refresh failures separately from
transaction-fetch failures.
- `GET /api/v1/provider_connections` lists providers alphabetically by
key. Connections within a provider retain their order.
## Database migration
Apply
`20261201120000_add_transactions_sync_start_date_to_mercury_accounts`
during deployment. This adds one nullable date to each Mercury account.
The importer initializes it on the next fetch from that account’s
previous sync history, so deployment requires no backfill.
## Screenshots
The Brex account-setup prompt from
[#5232](https://github.com/we-promise/sure/pull/5232) illustrates the
shared card. The [Lunch Flow credential
form](https://github.com/we-promise/sure/pull/5257) and [Mercury setup
dialogs](https://github.com/we-promise/sure/pull/5261) have additional
comparisons.
| Before | After |
| --- | --- |
| 
| 
|
## Validation
- Verified that all 56 rebased commits preserve the reviewed stack order
and that each commit’s files match the corresponding changes applied to
`main` at `5f31a17f5`.
- After the review fixes, `bin/rails test` completed with 20,204 tests,
121,912 assertions, nine skips, and zero failures or errors.
- The full browser suite passed on the rebased stack (532 tests). The
provider account setup browser test also passed after the review fixes,
including keyboard clearing and submitting the selected subtype.
- RuboCop, ERB lint, Biome, Brakeman, and the dependency audit passed.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Unifies the connection lifecycle for Brex, Lunch Flow, and Mercury on
shared provider-kit infrastructure: models, controllers, account flows,
syncers, and view components. Connection declarations on each provider
adapter now drive the provider lists in Bank Sync, the Accounts page,
and the connection-status API; the `provider:family` generator emits the
same kit. No database migration is needed.
**Behavior changes**
- Mercury now pages through transactions instead of importing only the
first page; Lunch Flow and Mercury honor an explicit sync start date.
- An open redirect via protocol-relative `return_to` paths is closed for
Lunch Flow and Mercury.
- Lunch Flow's panel no longer renders the stored API key into the page
HTML; a blank secret on edit preserves the stored credential.
- Linking several accounts is transactional, unsupported account types
are refused, and setup accepts subtypes only for the chosen account
type.
- Failed syncs are reported once to Sentry, tagged with both connection
and sync ids; swallowed Brex import failures now appear in the debug
log.
- `GET /api/v1/provider_connections` lists providers alphabetically by
key.
<sup>Written for commit c41bdd95d5.
Summary will update on new commits.</sup>
<a
href="https://cubic.dev/pr/we-promise/sure/pull/6049?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/we-promise/sure/6049?returnTo=https%3A%2F%2Fgithub.com%2Fwe-promise%2Fsure%2Fpull%2F6049&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
- **New Features**
- Added guided account selection and setup for provider connections,
including account-type and subtype choices.
- Lunch Flow and Mercury connections now support choosing a transaction
import start date.
- Added clearer connection status, sync summaries, and troubleshooting
details for provider errors.
- **Improvements**
- Provider settings and account lists now reflect connection details,
with account visibility respecting access.
- Blank connection names receive a localized default.
- Large Mercury transaction imports handle pagination and duplicate
records more reliably.
- **Bug Fixes**
- Unnamed provider accounts can’t be selected for linking.
- Keyboard selection now works for options with empty values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->