fix(kyc): stand the hosted task down beside a native step, and settle after the return (TASK-22818) [dev copy of #3277] - #3278
Conversation
… after the return (TASK-22818) A Bridge user who owed a proof-of-address document saw two tasks for one requirement, took the hosted one (Persona identity, which cannot collect the document), came back to an app that looked unchanged, and ran it again several times. The hosted task now stands down while a Bridge rail carries a native sumsub step: the resolver stopped emitting the pair (peanut-api-ts#1639), this keeps older responses honest on Home and on the prep screen. Coming back opens a settle window: refetch at once, ask the API to re-read the provider (peanut-api-ts#1640, best effort), keep asking every 5s for a minute until the task clears. The vendor's page never hands the user back and nothing else polls a requires-info rail, so a finished check used to look like nothing had happened. The prep screen says what is going on while the window runs, and says so when it ends with the task still pending, instead of re-offering the same button in silence.
…the expedite answer
The API's refresh route now expedites the poller instead of reading Bridge
in the request path (peanut-api-ts#1640), so one call per return is enough
and three keep the row on the fresh cadence if the vendor is slow. The
refetch every 5s is unchanged and cheap. The route answers { expedited },
not { refreshed }.
…oad in the app" when the hosted task stands down Review round 1 of the return leg: a window opened on every tab switch and never closed for good, its deadline moved with slow requests, it ran a second poller beside the shared one, the Rain portal return ran a Bridge refresh, and a deep link to the prep screen read "nothing left to do" to a user still blocked on a document. A Bridge return now opens one window per launch: expedite the provider poll, re-arm the shared user poller (markSubmitted), refetch once, and nudge again at 20s and 40s until the task clears or a minute passes on a wall clock. The API is not asked again once it answers that there is nothing to expedite. Rain returns, pre-launch restores and signals inside an open window are one refetch, as before. When the hosted task stood down behind a Sumsub step, the prep screen points at the upload in the profile instead of declaring the step done. The server action gets its wire-level tests.
…en the window opens, name the reviewer branch Review round 2 (Chip advisory + CodeRabbit): the "still pending" copy promised minutes where product truth says a reviewer can take 1 to 3 business days; the launch flag was set before the handoff, so a failed start still turned the next restore into a settle window; the window never consumed the launch, so a signal after it closed opened another one; and the task-pending ref was written during render. The flag is now set only when the vendor page actually opened (or right before the same-tab navigation whose return is a BFCache restore), the window consumes it, and the ref moves into the effect. The copy names both branches, as the prep copy two keys away already does.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: peanutprotocol/peanut-ui/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code-analysis diffPainscore total: 8465.42 → 8469.79 (+4.37) 🆕 New findings (15)
✅ Resolved (14)
📈 Painscore deltas (top movers)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
🖼 Visual diff — 2 screens moved3 of 144 shots changed · 141 identical · baseline
job summary · before/after/diff images — artifact Fixture screenshots, no backend. Advisory — this check never blocks a merge. Posted from the default branch by ds-shots-comment.yml; the report it renders is untrusted data. |
|
English · Español · Español (Argentina) · Português (Brasil) After merge: 12bd900 → 852cb57. Capture complete in all locales. |
Summary
Client half of TASK-22818. A Bridge user who owed a proof-of-address document saw two tasks for one requirement, took the hosted one (Persona identity, which cannot collect the document), came back to an app that looked unchanged, and ran it again several times. The resolver fix is peanutprotocol/peanut-api-ts#1641; the poll expedite is peanutprotocol/peanut-api-ts#1642 (dev twins of the closed #1639 and #1640). This PR closes the client side of the loop, in three parts:
sumsubstep (selectBridgeTasks, now rail-aware). The same rule the resolver applies after Peanut wallet #1641, so older API responses read the same way. Advisory (future-dated) hosted tasks stay. When the hosted task stood down for that reason, the prep screen says the document is uploaded in the app and points at the profile, instead of "nothing left to do".useHostedVerification): ask the API to expedite the provider poll (POST /users/kyc/refresh, best effort), re-arm the shared user poller (markSubmitted: 30s of 4s refetches with its in-flight guard), refetch once, and repeat the nudge at 20s and 40s until the task clears or a minute passes. The provider's page never hands the user back (Bridge issues no redirect for most customers), the ~4s auto-refresh only runs while a rail ispending, and a webhook can arrive hours later or never. Same handling for every return signal: in-app browser close (iOS and Android), the programmatic close of the universal-link leg, tab focus on web, BFCache restore. A signal before any launch, inside an open window, or on the Rain portal return is one refetch, as before.Not in this PR, deliberately: the tab-launch
SecurityErroron Chrome Mobile and Mobile Safari (Sentry PEANUT-UI-T07, T4W). Both engines allow the current order in a headless probe, so a reorder would be a guess; it needs a device-level look.Review round 1 (
/code-review high, 10 findings) reshaped the return leg: one window per launch instead of one per visibility flip, a wall-clock deadline instead of a round count, the shared poller instead of a second hand-rolled one, Bridge-only (the Rain portal return no longer runs a Bridge refresh), and the API is not asked again once it answers that there is nothing to expedite.Task
TASK-22818: https://app.notion.com/p/3df8381175798102ac1de417db7f6629
Risks / breaking changes
refreshKycStatecalls a route that lands with peanut-api-ts#1642. Until it deploys the call answers 404 and reads as "not expedited"; the window then only refetches. Safe in either deploy order.Notificationrows and one alternate panel on the prep screen. Reaches installed apps through the normal OTA path.markSubmittedper nudge; the shared poller's refetches are the ones it already runs after any Sumsub submission.QA
ds-shots.🤖 Generated with Claude Code