Skip to content

fix(TASK-24847): signup passkey sheet, login and setup recovery, KYC start deadline, US-state card copy - #4077

Closed
innolope-dev wants to merge 10 commits into
mainfrom
innolope/24848-bad-session-fixes-main
Closed

innolope-dev wants to merge 10 commits into
mainfrom
innolope/24848-bad-session-fixes-main

Conversation

@innolope-dev

@innolope-dev innolope-dev commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Hotfix for the 12 Nov bad-session review and a support case.

  • TASK-24847: the iOS passkey "Sign In" sheet keeps popping up during signup. The automatic iOS login on Landing ran on every mount and could outlive Landing. Its sheet reappeared over Claim username about six times in 17 s.
  • TASK-24856: a logged-in user was sent back into onboarding, and the email failed to save four times. /setup treated a failed profile fetch as signed out. The signup email step repeated a request the API refuses without the protected replacement flow.
  • TASK-24857: login hangs on loading, then "Something went wrong".
    • Login verify 429 and 5xx responses had no typed handling and cleared the session.
    • The login hydration budget was shorter than one request's timeout.
    • The 15 s setup watchdog had no retry.
  • TASK-24163: the KYC drawer was stuck on "Loading" for 16 minutes. The transport timeout stopped when headers arrived, so waits fell outside it: a stalled body, auth readiness, and the native import. The Manteca drawers also hid start errors.
  • TASK-24858: after the Sumsub SDK closes without a submit, refresh identity once. This lets the backend heal an unlinked applicant.
  • Card copy: a US resident in a state Rain doesn't cover (Georgia) was told the card "isn't available for residents of your country". Rain issues cards across the US, so for a US resident a geo-blocked card is a state block. The drawer now says "your state".

What changed

  • Transport (sentry.utils.ts, native-http.ts): one budget covers headers, the body and error telemetry. It drains a clone of the body, so callers still get an unread response. The native module import runs inside the deadline.
  • KYC start (useSumsubKycFlow.ts):
    • One 30 s deadline over the whole start. On expiry: loading stops, the existing error shows, and the drawer unlocks.
    • Late results are fenced and never open the SDK.
    • Closing the SDK without a submit refreshes identity once.
  • Manteca Add Money / Withdraw: pass the start error to the drawer and keep it open.
  • Landing:
    • The automatic iOS passkey login runs once per app launch, only on Landing, and never after Sign up or Log in.
    • Leaving Landing retires it and frees the native slot.
    • A ceremony retired while its result settles commits no session.
  • /setup: a profile-fetch error is an unknown state with a retry, never the signup entry. Initialization retries once before the generic error screen.
  • Email step: step-up, verification-code and replacement-disabled refusals keep the confirmed email and let signup continue, with the existing "change anytime in your profile" line. Duplicate and retryable errors behave as before. Telemetry records the failure kind.
  • Login:
    • Verify 429 and 5xx are typed and retryable, and keep the existing session.
    • Retry-After is honoured, with no stacked immediate retries.
    • The hydration budget is derived from the per-request timeout (about 45 s).
  • Account recovery link (Landing): "Need to recover a Peanut account?" no longer shows on the first screen. It appears only after a Log in attempt fails: any login error, or a second dismissal of the passkey sheet. One dismissal, or the silent automatic iOS attempt, doesn't count.
  • Card drawer (ClosedRowDrawer.tsx): new key cardNotAvailableStateNote in en, es-419 and pt-BR. es-AR inherits es-419.

Risks

  • The transport change touches every API call. No caller streams a response through it. Large bodies are read twice in memory (the clone).
  • Native-only behaviour is unverified on a device: iOS auto-login, the native transport, and the SDK close refresh. The tests cover the lifecycles.
  • The email step matches the 400 and 503 refusals by the API's message text, because those responses carry no code.
  • No API contract change. The identity refresh shape is unchanged.

Screenshots

⚠️ None. The visible changes are the email-step "change anytime" line, the setup retry screen, the Manteca drawer error and one card-drawer sentence. They reuse existing components and copy except one new string. The flows that trigger them need native iOS or production states that the local sandbox can't reproduce.

Tests

  • New tests per fix: Landing remount and retire, ceremony settle and cancel, setup fetch error and retry, email protected-replacement branches, login 429/5xx and Retry-After, hydration budget, stalled body, the KYC start deadline and late-result fence, Manteca errors, close refresh, and the US-state card copy.
  • The configured jest gate passes (43 suites, 1,279 tests), plus the adjacent setup, auth, KYC, transport, Manteca and Money suites. Typecheck passes. Disposable mutations fail the new tests.

Deploy and follow-up

  • Ship the API hotfix first: peanutprotocol/peanut-api-ts#2124. This also starts an OTA and store-build run, and the change is JS-only with no native surface.
  • Back-merge main → dev after merge (hotfix path).

Pre-review rounds

Two independent adversarial reviews (Claude and Codex) ran before this PR went up for review, then a re-review of the fixes:

  • Transport: once response headers arrive, a mutating request is never resent, so a POST that got a 201 can't be charged twice. Statement downloads skip the body drain.
  • /setup recovery applies only when no profile is loaded, and a successful recovery resumes the post-login routing.
  • The email step keeps the current email only when the account has one.
  • A passkey login that has committed its token finishes, even if the automatic attempt is retired.
  • The post-SDK refresh sends the poll's scope and skips action, document and residence-change sessions. Closing without a submit never completes the flow later.
  • The Manteca drawers close when the SDK opens. Retry-After is capped at 60 s.

A KYC start could leave the drawer locked on "Loading" for minutes:
the transport timeout stopped when headers arrived, so a stalled body,
auth readiness or the native module import could wait forever.

- The transport budget now covers the response body and error telemetry.
- The whole KYC start has one 30 s deadline; late results are fenced
  so they cannot reopen the SDK.
- Manteca Add Money and Withdraw pass the start error to the drawer and
  keep it open instead of closing silently.
- After the Sumsub SDK closes without a submit, refresh identity once
  so the backend can heal a missing applicant link (TASK-24858).

TASK-24163, TASK-24858
A US resident in a state Rain does not cover (Georgia) was told the
card "isn't available for residents of your country". Rain issues
cards across the US, so for a US resident a geo-blocked card is always
a state block: name the state instead.
…save

- TASK-24847: the automatic iOS passkey sign-in ran on every Landing
  mount and could outlive Landing, so its sheet kept popping up over
  Claim username. It now runs once per app launch, never after Sign up
  or Log in, and leaving Landing retires it and frees the native slot.
  A ceremony retired while its result settles commits no session.
- TASK-24856: a failed profile fetch on /setup is "unknown", with a
  retry, not "signed out" (no more signup for a logged-in user). The
  signup email step tells a protected email replacement (step-up,
  verification code, replacement disabled) from a retryable failure,
  keeps the confirmed email and lets signup continue instead of failing
  the same request again.
- TASK-24857: login verify 429/5xx are typed and retryable, keep the
  existing session and honour Retry-After; the login hydration budget
  now covers the per-request timeout; setup initialization retries once
  before the generic error screen.

TASK-24847, TASK-24856, TASK-24857
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
peanut-wallet Ready Ready Preview Nov 12, 2026 4:03pm UTC

Request Review

@notion-workspace

Copy link
Copy Markdown

@innolope-dev innolope-dev self-assigned this Nov 12, 2026
- Transport: once response headers arrive, a body-read failure or budget
  expiry never resends a mutating request (no native/WebView fallback, no
  retry); a POST that got 201 is sent once. Statement downloads skip the
  body drain so a large export is not cut off and regenerated.
- /setup: a profile-fetch error is "unknown" only when no profile is
  loaded, so a failed focus refetch no longer replaces the current step;
  a successful recovery resumes the post-login routing.
- Email step: keep the current email only when the account has one;
  otherwise the save failure shows as before.
- Login: once the passkey login has committed its token, retiring the
  automatic attempt no longer cancels it half way; it finishes hydration
  and key setup.
- KYC: the refresh after the SDK closes sends the same scope as the poll
  and skips document, action and residence-change sessions; the Manteca
  drawers close when the SDK opens or demo succeeds.
- Retry-After is capped at 60 s.

TASK-24847, TASK-24856, TASK-24857, TASK-24163, TASK-24858
Round 2 skipped the identity refresh for action sessions, which also
skipped clearing the user-initiated flag, so a delayed APPROVED after
closing an unsubmitted action (supplement:bridge) called onKycSuccess
and moved FeatureAction to feature-ready without the upload. Clear the
flag on every close without a submit; the refresh stays skipped.

TASK-24858

@chip-peanut-bot chip-peanut-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chip review — no blocking findings — this is not an approval

One major finding: successful Manteca verification starts leave the entry gate open in Add Money and Withdraw.

Findings

  • MAJOR · src/components/AddMoney/components/MantecaAddMoneyFlow.tsx:466 · Close the Manteca gate when verification starts successfully
    For a Manteca restart-identity or fixable rejection, the start handler can set showWrapper and open Sumsub, but only the ordinary initiate branch closes the entry gate. The same branch structure exists in src/features/withdraw/views/MantecaBankWithdrawFlow.tsx. The gate therefore remains open during the SDK and reappears when it closes; on Add Money the fixable case also keeps rendering the document-request page instead of the amount step. Close the gate when either handler actually opens the SDK, while retaining it on a start error. Cover successful restart and fixable starts in both flows; the new tests cover failures only.

  • MINOR · src/features/deposit-accounts/components/ClosedRowDrawer.tsx:106 · [claude-opus] US-state card refusal copy promises the card will come later
    The new string cardNotAvailableStateNote says "The Peanut card isn't available in your state yet." The es-419 ('todavía') and pt-BR ('ainda') versions say the same. product/card.md lists the 19 states, DC and the territories as refused under Rain's Platform Standards (§ Refused US states). It gives no plan to open them, and countries.md:516 says card copy must not promise issuance. card.md:254 also separates a hard block from a 'not yet'. The product truth is right and the copy is wrong. Fix: drop 'yet' in all three locales, e.g. "The Peanut card isn't available in your state." The new code comment at line 59 ('Rain issues cards across the US') also contradicts card.md:199, which says only 31 states are allowed. Reword it to say that for a US residence the only geo rule is rain.us-state. A narrower edge case: livesInUs reads verified ?? declared residence only. A verified US user with an open residence-change request to a refused country gets 'geo-blocked' from that request, because card.md:223 applies the strictest residence. That user would wrongly be told it is their state.

Checked clean

  • Exact detached head and merge-base diff; trusted PR metadata matched supplied refs.
  • CI checks at this head were green; inspected transport, passkey, setup, email, KYC, and Manteca behavior beyond those gates.
  • Manteca error tests cover failed starts; successful restart and fixable starts do not assert gate dismissal.
  • Card eligibility checked against the API sibling and product source; UI changes checked against design.md and the Notion Lexicon.

Security review by moonshotai/kimi-k3: 0 finding(s), marked with the model name. It reads the diff only and answers only security, privacy and money, so treat its findings as advice.

Third opinion by claude-opus: 1 finding(s), marked with the model name. It answers only product truth, missing tests and the cross-repo contract, so treat its findings as advice.

Copy check by claude-haiku-5-5: 0 finding(s), titled "Copy now wrong". Every quoted passage was checked against the file.

Exact head: 93d217635f64 · Context: repo, product, design, sibling, lexicon · Took 6m

…ailed login

The "Need to recover a Peanut account?" link sat on the first screen for
everyone, new users included. Show it only after a Log in attempt fails:
any login error, or a second dismissal of the passkey sheet (the drawer's
existing "can't log in" signal). One dismissal or the silent automatic
iOS attempt does not count.
…y residence

Chip review: "isn't available in your state yet" promised issuance
that product/card.md does not plan (Rain refuses 19 states, DC and the
territories). Drop "yet" in en, es-419 and pt-BR. A verified US user
with a pending residence change elsewhere can be refused by that change
(strictest residence), so name the state only when every residence on
file is US.
…ens the SDK

Chip review: only the ordinary initiate branch closed the entry drawer,
so for a restart-identity or fixable rejection the drawer stayed open
under the Sumsub SDK and came back after it, and Add Money kept showing
the document-request page instead of the amount step. The restart and
fixable handlers now report whether they opened the SDK; both Manteca
flows close the drawer on success and keep it, with the error, on a
failed start.

TASK-24163

@chip-peanut-bot chip-peanut-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chip review — no blocking findings — this is not an approval

One major finding remains: a Manteca progress handoff can leave its entry gate over the status modal.

Answered by a human, not raised again

These are still present as far as this review can tell. You resolved the thread or deferred the fix, so Chip does not repeat them. If one needs a follow-up, file the task yourself.

  • MAJOR · src/components/AddMoney/components/MantecaAddMoneyFlow.tsx:468 · Close the Manteca gate when verification is already in progress

Checked clean

  • Exact detached head, base merge diff, trusted PR metadata, and check runs at this SHA; some CodeQL analysis jobs were still in progress.
  • P1 SDK-token restart and fixable paths now close the gate; new caller tests cover those paths.
  • P2 is fixed: the state copy no longer promises future availability, and the state-specific branch requires every recorded residence to be US.
  • Verified the no-token Manteca session response in the API sibling and the drawer/modal stacking in the UI and design rulebook.
  • Reviewed Landing recovery-link change and its cancellation/error tests; no additional finding.

Security review by moonshotai/kimi-k3: 0 finding(s), marked with the model name. It reads the diff only and answers only security, privacy and money, so treat its findings as advice.

Third opinion: did not run — it reads only the first review of a pull request; the first reviewer checks later rounds. This review is one reviewer short.

Copy check by claude-haiku-5-5: 0 finding(s), titled "Copy now wrong". Every quoted passage was checked against the file.

Exact head: 5d2bf070f79c · Context: repo, product, design, sibling, lexicon · Took 4m

…ogress

Chip review: a start that finds verification already in progress opens
the progress modal without the SDK, and the Manteca entry drawer stayed
over it. Both Manteca flows now close the drawer whenever the status
modal opens, whichever start handed off; a failed start keeps it with
its error.

TASK-24163
@innolope-dev

Copy link
Copy Markdown
Collaborator Author

/chip review

@chip-peanut-bot chip-peanut-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chip review — no blocking findings — this is not an approval

No PR-scoped findings at this head. The Manteca verification handoffs and US-state card copy address the supplied prior findings.

Checked clean

  • Exact detached HEAD and trusted PR metadata match the requested head and base; reviewed the merge-base diff and the new four-file change.
  • Manteca Add Money and Withdraw: successful SDK starts close the entry gate; in-progress no-token starts close it when the status modal opens; failed starts retain the gate and error.
  • US-state card refusal copy in en, es-419, and pt-BR has no future-issuance promise; the state-specific copy requires only US residences on file.
  • Design-system guidance checked for the changed UI; no new visual primitive or token drift in this commit.
  • Exact-head CI check-runs, including guard, review, CodeQL, and JavaScript/TypeScript analysis, are successful.

Security review by moonshotai/kimi-k3: 0 finding(s), marked with the model name. It reads the diff only and answers only security, privacy and money, so treat its findings as advice.

Third opinion: did not run — it reads only the first review of a pull request; the first reviewer checks later rounds. This review is one reviewer short.

Copy check by claude-haiku-5-5: 0 finding(s), titled "Copy now wrong". Every quoted passage was checked against the file.

Exact head: 7031dea827e3 · Context: repo, design, sibling, product, lexicon · Took 4m

innolope-dev added a commit that referenced this pull request Nov 12, 2026
…hose profile read failed

c968603 (#4077, TASK-24856) treats any failed /users/me on /setup as
"account unknown" and shows Something went wrong + Try again instead of
the entry step. On web the readable jwt-token cookie is the only
credential the API sees (apiFetch sends no cookies), so a visitor with
no token is signed out whatever the request did. With the API down,
offline, or absent (the press-contract harness) they never reached
Welcome: press-contract timed out waiting for Sign up.

profileFetchFailed now also requires mayHoldSession(): a web token, or
any native app, where a legacy session can live in the OS cookie jar
that JS cannot read (see api-fetch). Signed-in web sessions and every
native case keep the TASK-24856 recovery screen.
@innolope-dev

Copy link
Copy Markdown
Collaborator Author

Replaced by #4083.

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — 7031dea8 Deployed Nov 12, 2026 by vercel[bot]
content-publish — 7031dea8 Deployed Nov 12, 2026 by innolope-dev via approve-and-merge #7968
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant