Skip to content

feat(card): specific reason on the rejected-card screen + crypto reassurance#2310

Merged
Hugo0 merged 3 commits into
mainfrom
feat/card-rejection-reason
Jun 29, 2026
Merged

feat(card): specific reason on the rejected-card screen + crypto reassurance#2310
Hugo0 merged 3 commits into
mainfrom
feat/card-rejection-reason

Conversation

@jjramirezn

Copy link
Copy Markdown
Contributor

Why

The "We couldn't issue you a card" screen showed only a generic catch-all body ("…duplicate attempt, incomplete documents, information mismatch, or regional restrictions"). Users couldn't tell what actually happened, and the dead-end framing implied the whole account was blocked.

What

  • card/page.tsx (rejected case): wait for capabilities, then pass the vetted reason from the capability read-model (railsForProvider('rain')[0].reason.userMessage) into the screen — mirrors the existing requires-info case. Falls back to the generic body when capabilities haven't resolved.
  • ApplicationStatusScreen: rejected body → reassurance: "You can still use Peanut freely to deposit, withdraw, and pay with crypto." A declined card doesn't gate the rest of the account. The specific reason (e.g. "Peanut cards aren't available in your state yet.") renders above it via the existing reasonMessage slot.

Tests

New ApplicationStatusScreen.test.tsx (3): reason-above-body, reassurance-only fallback, Contact-support still wired. Card + capabilities suites green (114).

Cross-repo

Requires peanut-api-ts ops/card-rejection-reason (PR #1086) to populate reason.userMessage for Rain rejections. Without it the screen falls back to the generic body — safe to merge in either order, best UX once both land.

🤖 Generated with Claude Code

…assure

The "We couldn't issue you a card" screen showed only a generic catch-all
body. Surface the vetted, region-aware reason from the capability read-model
(e.g. "Peanut cards aren't available in your state yet.") above a reassurance
body — a declined card doesn't touch the rest of the account, so point the
user back to crypto deposit / withdraw / pay, which still work.
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
peanut-wallet Ready Ready Preview, Comment Jun 29, 2026 3:38pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 344dde63-1742-4e68-8721-5995e191be3a

📥 Commits

Reviewing files that changed from the base of the PR and between 3780741 and 216912a.

📒 Files selected for processing (2)
  • src/app/(mobile-ui)/card/page.tsx
  • src/components/Card/__tests__/ApplicationStatusScreen.test.tsx

Walkthrough

The card page's rejected state now waits for capabilitiesLoading before rendering ApplicationStatusScreen, then passes a reasonMessage derived from the Rain rail's userMessage. The rejected copy is shortened, and tests cover the reasonMessage behavior.

Changes

Rejected state reason message

Layer / File(s) Summary
ApplicationStatusScreen copy and reasonMessage rendering
src/components/Card/ApplicationStatusScreen.tsx
Updates the rejected variant body copy to a shorter reassurance message and adds comments describing how reasonMessage and the generic body are rendered.
Card page rejected state: capabilities loading and reasonMessage wiring
src/app/(mobile-ui)/card/page.tsx
Adds a capabilitiesLoading guard in the rejected state, then computes cardRailReason from railsForProvider('rain')[0]?.reason?.userMessage and passes it as reasonMessage to ApplicationStatusScreen.
ApplicationStatusScreen rejected variant tests
src/components/Card/__tests__/ApplicationStatusScreen.test.tsx
Adds a new test suite for the rejected variant covering provided and missing reasonMessage cases plus the Contact support callback.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • peanutprotocol/peanut-ui#2043: Modifies ApplicationStatusScreen.tsx in the rejected variant copy, directly related to this PR's copy change.
  • peanutprotocol/peanut-ui#2207: Introduces the reasonMessage prop pattern and Rain rail reason.userMessage wiring into ApplicationStatusScreen for related card states.

Suggested labels

enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a specific rejected-card reason and updated reassurance copy.
Description check ✅ Passed The description is directly related to the PR and accurately describes the code changes and test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the enhancement New feature or request label Jun 29, 2026
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 5845.51 → 5846.01 (+0.5)
Findings: +1 net (+6 new, -5 resolved)

🆕 New findings (6)

  • critical complexity — src/app/(mobile-ui)/card/page.tsx — CC 96, MI 57.33, SLOC 378
  • high hotspot — src/app/(mobile-ui)/card/page.tsx — 38 commits, +1074/-467 lines since 6 months ago
  • medium high-mdd — src/app/(mobile-ui)/card/page.tsx:53 — CardPage: MDD 103.8 (uses across many lines from declarations)
  • medium method-complexity — src/app/(mobile-ui)/card/page.tsx:436 — CC 16 SLOC 49
  • low high-mdd — src/components/Card/ApplicationStatusScreen.tsx:49 — ApplicationStatusScreen: MDD 19.0 (uses across many lines from declarations)
  • low high-mdd — src/app/(mobile-ui)/card/page.tsx:436 — renderState: MDD 14.4 (uses across many lines from declarations)

✅ Resolved (5)

  • src/app/(mobile-ui)/card/page.tsx — CC 95, MI 57.44, SLOC 376
  • src/app/(mobile-ui)/card/page.tsx — 36 commits, +1049/-455 lines since 6 months ago
  • src/app/(mobile-ui)/card/page.tsx:53 — CardPage: MDD 104.3 (uses across many lines from declarations)
  • src/app/(mobile-ui)/card/page.tsx:436 — CC 15 SLOC 47
  • src/components/Card/ApplicationStatusScreen.tsx:46 — ApplicationStatusScreen: MDD 19.0 (uses across many lines from declarations)

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 1599 ran, 0 failed, 0 skipped, 25.3s

📊 Coverage (unit)

metric %
statements 54.3%
branches 36.9%
functions 41.7%
lines 54.1%
⏱ 10 slowest test cases
time test
3.5s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
0.5s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.3s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in updateUserById
0.3s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in updateUserById body
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid 9-digit US account
0.1s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Perk claimed shows shake class + go home button
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle invalid ETH address (missing 0x prefix)
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle too long for US account
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid ENS name
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid ETH address with surrounding spaces
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@src/app/`(mobile-ui)/card/page.tsx:
- Around line 568-580: The rejected card screen is being replaced by a loading
spinner while capabilities are still pending, which hides the intended fallback
copy and support CTA. In the card page render flow around
ApplicationStatusScreen, remove the capabilitiesLoading guard for the rejected
state and always render the rejected screen immediately. Keep using
railsForProvider('rain')[0]?.reason?.userMessage for reasonMessage so it can
populate later, and let ApplicationStatusScreen handle the no-reason case until
the capability read-model arrives.

In `@src/components/Card/__tests__/ApplicationStatusScreen.test.tsx`:
- Around line 27-45: The current tests only verify that the rejected reason
exists, not that it appears above the reassurance body as rendered by
ApplicationStatusScreen. Update the ApplicationStatusScreen test cases to assert
the DOM order between the reasonMessage text and REASSURANCE, using the
ApplicationStatusScreen render output so the placement contract is checked
directly. Also strengthen the fallback case by asserting no extra reason
paragraph is present in a generic way, not just by matching one example phrase.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9a58816f-8917-4597-a534-82f3b947e229

📥 Commits

Reviewing files that changed from the base of the PR and between efbb2bd and 0185213.

📒 Files selected for processing (3)
  • src/app/(mobile-ui)/card/page.tsx
  • src/components/Card/ApplicationStatusScreen.tsx
  • src/components/Card/__tests__/ApplicationStatusScreen.test.tsx

Comment thread src/app/(mobile-ui)/card/page.tsx Outdated
Comment thread src/components/Card/__tests__/ApplicationStatusScreen.test.tsx
…nt (CodeRabbit)

Don't spinner-gate the rejected screen on capabilities — it's useful without the
reason (reassurance + support CTA), so show it now and fill reasonMessage once
capabilities resolve. Strengthen the test to assert the reason renders ABOVE the
body (DOM order) and to count paragraphs generically instead of phrase-matching.
@jjramirezn jjramirezn changed the base branch from dev to main June 29, 2026 15:40
@Hugo0 Hugo0 merged commit 70272d1 into main Jun 29, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants