[TASK-18803] fix: redirect to onboarding when manteca reports missing fund origin#1762
[TASK-18803] fix: redirect to onboarding when manteca reports missing fund origin#1762jjramirezn merged 3 commits intodevfrom
Conversation
jjramirezn
commented
Mar 18, 2026
- Detect onboarding-incomplete errors (fund origin, profile incomplete)
- Auto-generate onboarding URL and redirect user to complete their profile
- Return URL set to current page so user lands back in withdraw flow
- Fallback message if onboarding URL generation fails
- Detect onboarding-incomplete errors (fund origin, profile incomplete) - Auto-generate onboarding URL and redirect user to complete their profile - Return URL set to current page so user lands back in withdraw flow - Fallback message if onboarding URL generation fails
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds onboarding error handling to the Manteca withdraw flow: a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
|
@coderabbitai review in depth. Evaluate:
Also, write a very concise testing guide for QA |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/app/(mobile-ui)/withdraw/manteca/page.tsx (2)
193-196: Capture onboarding-initiation failures before fallback messaging.This catch path swallows useful diagnostics. Add exception capture so onboarding URL failures are traceable.
Suggested improvement
- } catch { + } catch (error) { + captureException(error) setErrorMessage('Please complete your account setup. Go to Settings to update your profile.') setIsRedirectingToOnboarding(false) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx around lines 193 - 196, The catch block currently swallows errors when initiating onboarding; change the catch to capture the exception (e.g., catch (err) or catch (error)) and surface it by logging it (console.error or the app logger) and/or append a short error detail to setErrorMessage so failures to build the onboarding URL are traceable; keep the existing setIsRedirectingToOnboarding(false) behavior. Target the catch in the onboarding initiation flow that calls setErrorMessage and setIsRedirectingToOnboarding.
97-97:isRedirectingToOnboardingis currently write-only.The state is set/reset but never read, so it does not prevent duplicate actions or provide loading feedback during redirect.
Suggested usage pattern
- const [isRedirectingToOnboarding, setIsRedirectingToOnboarding] = useState(false) + const [isRedirectingToOnboarding, setIsRedirectingToOnboarding] = useState(false) ... - disabled={ + disabled={ !isCompleteBankDetails || isDestinationAddressChanging || !isDestinationAddressValid || - isLockingPrice + isLockingPrice || + isRedirectingToOnboarding } - loading={isDestinationAddressChanging || isLockingPrice} + loading={isDestinationAddressChanging || isLockingPrice || isRedirectingToOnboarding}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx at line 97, isRedirectingToOnboarding is write-only and should be read to prevent duplicate redirects and show loading UI: update the redirect handler (where setIsRedirectingToOnboarding(true) is called) to early-return if isRedirectingToOnboarding is already true, set it back to false on error/cleanup, and use isRedirectingToOnboarding in the component JSX (e.g., disable the submit/button that triggers the redirect and render a spinner or "Redirecting…" text) so the state both guards the action and provides user feedback; reference the isRedirectingToOnboarding state and setIsRedirectingToOnboarding setter and modify the redirect-triggering function and related button/element rendering accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx:
- Line 239: Onboarding redirect detection is only checking result.error while
user messaging sometimes uses result.message; update the call sites that invoke
handleOnboardingError (e.g., the statements calling
handleOnboardingError(result.error)) to use the same unified source as the
displayed message — for example pass result.error ?? result.message or pass the
whole result and let handleOnboardingError read from result.message as fallback
— so detection and user-facing messaging are consistent (apply the same change
to both call sites where handleOnboardingError is invoked).
- Around line 178-185: The onboarding error detector in handleOnboardingError is
too broad and brittle; update onboardingErrors to match specific phrases and
common backend variants (e.g., 'onboarding_incomplete', 'onboarding incomplete',
'fund origin missing', 'profile incomplete') and implement a normalized-match
before testing (lowercase, replace underscores/dashes with spaces, collapse
extra whitespace), or use word-boundary regex checks (e.g.,
/\bonboarding(?:[_\s-]incomplete)?\b/, /\bfund\s+origin\b/,
/\bprofile\s+incomplete\b/) so only exact/intentional onboarding-related
messages trigger the redirect; keep the function name handleOnboardingError and
the onboardingErrors concept so the change is localized.
---
Nitpick comments:
In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx:
- Around line 193-196: The catch block currently swallows errors when initiating
onboarding; change the catch to capture the exception (e.g., catch (err) or
catch (error)) and surface it by logging it (console.error or the app logger)
and/or append a short error detail to setErrorMessage so failures to build the
onboarding URL are traceable; keep the existing
setIsRedirectingToOnboarding(false) behavior. Target the catch in the onboarding
initiation flow that calls setErrorMessage and setIsRedirectingToOnboarding.
- Line 97: isRedirectingToOnboarding is write-only and should be read to prevent
duplicate redirects and show loading UI: update the redirect handler (where
setIsRedirectingToOnboarding(true) is called) to early-return if
isRedirectingToOnboarding is already true, set it back to false on
error/cleanup, and use isRedirectingToOnboarding in the component JSX (e.g.,
disable the submit/button that triggers the redirect and render a spinner or
"Redirecting…" text) so the state both guards the action and provides user
feedback; reference the isRedirectingToOnboarding state and
setIsRedirectingToOnboarding setter and modify the redirect-triggering function
and related button/element rendering accordingly.
🪄 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: 949d3fc3-cdbe-4340-98e9-bc435fdbf41b
📒 Files selected for processing (1)
src/app/(mobile-ui)/withdraw/manteca/page.tsx
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3404 🏁 Script executed: Length of output: 36410 🏁 Script executed: Length of output: 14495
🐛 Risk of Introducing Bugs1. Dead state —
|
| # | Scenario | Steps | Expected Result |
|---|---|---|---|
| 1 | Redirect on initiateWithdraw error |
Fill amount + bank details → tap "Review" with an account that triggers a fund origin error |
App calls initiateOnboarding, then redirects to the onboarding URL; after completing onboarding, browser returns to the withdraw page |
| 2 | Redirect on withdrawWithSignedTx error |
Complete all steps through "Review" → tap "Withdraw" with an account triggering a profile incomplete error |
Same redirect behaviour as above; loading state clears (setLoadingState('Idle') via finally) |
| 3 | Fallback message on initiateOnboarding failure |
Mock / block the initiateOnboarding endpoint → trigger an onboarding error |
Error message "Please complete your account setup. Go to Settings to update your profile." appears; user stays on page; no spinner stuck |
| 4 | Non-onboarding error unaffected | Trigger a TAX_ID_MISMATCH or CUIT_MISMATCH error |
Normal user-friendly error message shown; no redirect |
| 5 | Happy path regression | Complete a full withdraw with a fully onboarded account | No change in behaviour; success screen shown normally |
| 6 | Return URL | After completing onboarding redirect (scenario 1/2), check the URL the onboarding flow returns to | Should be the exact withdraw page URL (with method/country params) |
🧠 Learnings used
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 852
File: src/hooks/useTransactionHistory.ts:177-239
Timestamp: 2025-05-14T21:16:06.369Z
Learning: When reviewing code, pay attention to and resolve CodeRabbit comments as they can contain useful refactoring suggestions and insights.
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 594
File: src/components/Request/Pay/Views/Initial.view.tsx:188-213
Timestamp: 2024-12-31T15:08:15.640Z
Learning: Always resolve coderabbit comments when reviewing code, since they can contain useful suggestions.
- Tighten error matching (remove broad 'onboarding', use 'onboarding required') - Add handleOnboardingError to useCallback deps - Wire isRedirectingToOnboarding into button (disabled + loading + 'Redirecting...') - Check result.message in withdraw path for onboarding errors
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/(mobile-ui)/withdraw/manteca/page.tsx (1)
758-766:⚠️ Potential issue | 🟡 MinorReview step button missing redirect state handling.
Unlike the bank details step button (lines 696-707), this button doesn't account for
isRedirectingToOnboarding. If an onboarding error occurs duringhandleWithdraw, the finally block setsloadingStateto'Idle'before the page navigates away, briefly leaving the button enabled and clickable.For consistency, consider adding
isRedirectingToOnboardingto the disabled and loading checks:Suggested fix
<Button icon="arrow-up" onClick={handleWithdraw} - loading={isLoading} - disabled={!!errorMessage || isLoading} + loading={isLoading || isRedirectingToOnboarding} + disabled={!!errorMessage || isLoading || isRedirectingToOnboarding} shadowSize="4" > - {isLoading ? loadingState : 'Withdraw'} + {isRedirectingToOnboarding ? 'Redirecting...' : isLoading ? loadingState : 'Withdraw'} </Button>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx around lines 758 - 766, The Withdraw step button currently doesn't consider isRedirectingToOnboarding, so when handleWithdraw triggers an onboarding redirect the finally block resets loadingState and briefly makes the button clickable; update the Button rendering (the component using props icon, onClick={handleWithdraw}, loading={isLoading}, disabled={!!errorMessage || isLoading}, and children {isLoading ? loadingState : 'Withdraw'}) to include isRedirectingToOnboarding in both loading and disabled checks (e.g., loading={isLoading || isRedirectingToOnboarding} and disabled={!!errorMessage || isLoading || isRedirectingToOnboarding}) and ensure the displayed label also reflects the combined state (use the combined loading flag when selecting loadingState vs 'Withdraw') so the button stays disabled/shows loading while redirecting.
🧹 Nitpick comments (1)
src/app/(mobile-ui)/withdraw/manteca/page.tsx (1)
196-199: Consider capturing the error for observability.The catch block discards error details. While the user sees a fallback message, logging or capturing the exception would help diagnose why
initiateOnboardingfailed.Suggested improvement
- } catch { + } catch (err) { + captureException(err) setErrorMessage('Please complete your account setup. Go to Settings to update your profile.') setIsRedirectingToOnboarding(false) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx around lines 196 - 199, The catch block that handles failures from initiateOnboarding currently swallows the exception; update it to capture and record the error (e.g., catch (err) { ... }) and forward the error to your observability tooling (console.error or app-specific logger / Sentry via captureException) while preserving the existing UI behavior that calls setErrorMessage and setIsRedirectingToOnboarding; locate the try/catch around initiateOnboarding in page.tsx and add the error reporting there.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx:
- Around line 758-766: The Withdraw step button currently doesn't consider
isRedirectingToOnboarding, so when handleWithdraw triggers an onboarding
redirect the finally block resets loadingState and briefly makes the button
clickable; update the Button rendering (the component using props icon,
onClick={handleWithdraw}, loading={isLoading}, disabled={!!errorMessage ||
isLoading}, and children {isLoading ? loadingState : 'Withdraw'}) to include
isRedirectingToOnboarding in both loading and disabled checks (e.g.,
loading={isLoading || isRedirectingToOnboarding} and disabled={!!errorMessage ||
isLoading || isRedirectingToOnboarding}) and ensure the displayed label also
reflects the combined state (use the combined loading flag when selecting
loadingState vs 'Withdraw') so the button stays disabled/shows loading while
redirecting.
---
Nitpick comments:
In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx:
- Around line 196-199: The catch block that handles failures from
initiateOnboarding currently swallows the exception; update it to capture and
record the error (e.g., catch (err) { ... }) and forward the error to your
observability tooling (console.error or app-specific logger / Sentry via
captureException) while preserving the existing UI behavior that calls
setErrorMessage and setIsRedirectingToOnboarding; locate the try/catch around
initiateOnboarding in page.tsx and add the error reporting there.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1b505293-8b15-4e45-8feb-c196088ae864
📒 Files selected for processing (1)
src/app/(mobile-ui)/withdraw/manteca/page.tsx