kyc(gate): consume wait:bridge NextAction + SEPA v2 ToS copy#2132
Conversation
…or SEPA v2
Two FE-side follow-ups to peanut-api-ts#906 (BE Bridge requirement vocabulary
fix). Neither feature is testable without the BE PR.
1. `waiting-on-provider` gate kind. The BE now emits
`{kind:'wait', key:'wait:bridge'}` when Bridge is doing internal review
(`kyc_approval`, `post_processing`, generic `stripe_database_lookup_*`).
Without a gate-side handler, the wait-only rail falls through to
`needs-enrollment` and the user sees a misleading "verify your identity"
CTA — exactly the loop the new `wait` kind was meant to prevent. Add a
branch in `deriveGate` between `pending` and `needs-identity` so:
- a usable rail (ready/pending) still wins (don't block the user from a rail they CAN use)
- the wait-only case shows the BE-supplied "we're checking with Bridge" copy
instead of a Sumsub bounce
Consumers treat `waiting-on-provider` like `loading` — silent no-op
instead of opening the KYC modal.
2. BridgeTosStep accepts a `reasonCode` prop. SEPA v2 (`bridge_tos_v2_required`)
gets SEPA-specific copy; base ToS (`bridge_tos_required`) keeps the
existing copy. Callsite plumbs `gate.reason?.code` from the new
`accept-tos` GateState `reason` field. The Bridge endpoint
(`/users/bridge-tos-link`) is opaque to endorsement — Bridge serves the
right ToS based on customer state — so this is copy-only.
3. Manteca `handleOnboardingError` gets an intentional-fallback comment.
The Manteca hosted widget is dead-by-design per the KYC 2.0 plan
(centralized on Sumsub → submitToManteca via API), but the error-recovery
redirect stays as a last-resort escape hatch until we root-cause and fix
the cases where users end up half-onboarded.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 45 minutes and 33 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR introduces a new ChangesProvider-review gate state and variant ToS copy
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Code-analysis diffPainscore total: 5811.62 → 5813.62 (+2) 🆕 New findings (48)
…and 28 more. ✅ Resolved (47)
…and 27 more. |
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/Kyc/BridgeTosStep.tsx (1)
24-25: ⚡ Quick winTighten
reasonCodetyping to avoid silent copy regressions.Use a typed reason-code contract instead of raw strings so backend-code typos get caught at compile time.
Proposed refactor
+import type { CapabilityReason } from '`@/types/capabilities`' + interface BridgeTosStepProps { @@ - reasonCode?: string + reasonCode?: CapabilityReason['code'] } @@ +const BRIDGE_TOS_V2_REQUIRED = 'bridge_tos_v2_required' as const @@ - const copy = reasonCode === 'bridge_tos_v2_required' ? TOS_COPY.sepa : TOS_COPY.base + const copy = reasonCode === BRIDGE_TOS_V2_REQUIRED ? TOS_COPY.sepa : TOS_COPY.baseAlso applies to: 105-105
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/Kyc/BridgeTosStep.tsx` around lines 24 - 25, The reasonCode is currently typed as a raw string which allows silent typos; introduce a specific ReasonCode union type or enum (e.g., ReasonCode) reflecting the allowed backend values (or import the contract type from the shared types package), replace the loose property signature reasonCode?: string in the BridgeTosStep props/interface with reasonCode?: ReasonCode, and update all usages in this file (including the occurrence around the component render/logic) to use the new ReasonCode type so TypeScript will catch invalid values at compile time.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/components/Kyc/BridgeTosStep.tsx`:
- Around line 24-25: The reasonCode is currently typed as a raw string which
allows silent typos; introduce a specific ReasonCode union type or enum (e.g.,
ReasonCode) reflecting the allowed backend values (or import the contract type
from the shared types package), replace the loose property signature
reasonCode?: string in the BridgeTosStep props/interface with reasonCode?:
ReasonCode, and update all usages in this file (including the occurrence around
the component render/logic) to use the new ReasonCode type so TypeScript will
catch invalid values at compile time.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ef5950a1-d3cf-4106-9f79-35ff135cf479
📒 Files selected for processing (8)
src/app/(mobile-ui)/add-money/[country]/bank/page.tsxsrc/app/(mobile-ui)/withdraw/[country]/bank/page.tsxsrc/app/(mobile-ui)/withdraw/manteca/page.tsxsrc/components/AddWithdraw/AddWithdrawCountriesList.tsxsrc/components/Claim/Link/views/BankFlowManager.view.tsxsrc/components/Kyc/BridgeTosStep.tsxsrc/utils/capability-gate.test.tssrc/utils/capability-gate.ts
CR nitpick: BE-emitted reason codes are typed as free-form string on the contract, so equality comparisons in FE code don't get compile-time typo protection. Extracting `bridge_tos_v2_required` to a `const`-typed identifier catches misspellings of MY comparison string; the prop itself stays `string` because the upstream type is still wider.
|
Merge order: depends on https://github.com/peanutprotocol/peanut-api-ts/pull/906 — the BE resolver PR that emits the new |
Summary
Two FE-side follow-ups to peanut-api-ts#906 (BE Bridge requirement vocabulary fix) — neither feature is usable without that BE PR.
waiting-on-providergate kind. BE now emits{kind:'wait', key:'wait:bridge'}when Bridge is doing internal review (`kyc_approval`, `post_processing`, generic `stripe_database_lookup_*`). Without a FE handler the wait-only rail fell through to `needs-enrollment` → user saw a misleading "verify your identity" CTA and got bounced back to Sumsub for nothing. Now: `deriveGate` returns `waiting-on-provider` with the BE-supplied "we're finalizing with Bridge" message, and the 4 consumer call sites suppress the KYC modal (treated like `loading`).Priority order change in deriveGate
`waiting-on-provider` slots between `pending` and `needs-identity` — AFTER `ready`, so a usable rail wins (don't block a user from a rail they can use), BEFORE `needs-identity` so the wait copy beats a misleading "verify" CTA.
```
```
Test plan
Risks