Skip to content

Fix: application error and app stuck on home page#1264

Merged
jjramirezn merged 1 commit intopeanut-wallet-devfrom
fix/application-error
Sep 30, 2025
Merged

Fix: application error and app stuck on home page#1264
jjramirezn merged 1 commit intopeanut-wallet-devfrom
fix/application-error

Conversation

@Zishan-7
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Sep 30, 2025

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

Project Deployment Preview Comments Updated (UTC)
peanut-wallet Ready Ready Preview Comment Sep 30, 2025 5:28pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

Introduces user-presence guards and dependency updates in balance-related effects on the mobile Home page, and tightens authentication/render gating in the mobile layout with a redirect for unauthenticated users.

Changes

Cohort / File(s) Summary
Mobile Home balance effects
src/app/(mobile-ui)/home/page.tsx
Added early returns in balance-related useEffects when no user; included user in dependency arrays for three balance effects and the Add Money Prompt modal effect.
Mobile layout auth gating
src/app/(mobile-ui)/layout.tsx
Added useEffect to redirect unauthenticated users to /setup; expanded render guard to require a valid user or loading state; refined readiness/auth conditions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • jjramirezn
  • kushagrasarathe

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description is entirely absent and does not reference any of the changes, so it fails to describe any aspect of the modifications made. Without a description, reviewers lack context about the intent and scope of the updates. This omission means the description is effectively unrelated to the changeset. Please add a brief description summarizing the changes made—such as the addition of user guards in balance-related effects and the updated layout redirect logic—to provide context for reviewers.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly states the core issue being addressed—an application error causing the app to get stuck on the home page—which directly aligns with the guard additions and redirect logic implemented to resolve that problem. It succinctly summarizes the primary fix without unnecessary detail or noise. It is concise and specific enough for team members scanning the history to understand the main change.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/application-error

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.

❤️ Share

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

@coderabbitai coderabbitai bot added the enhancement New feature or request label Sep 30, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/app/(mobile-ui)/layout.tsx (1)

24-26: Include /setup in public paths so the setup flow renders while unauthenticated

Without allowing /setup, the loader gate above will still block it. Minimal fix below (keeps your existing pattern style).

-// Allow access to some public paths without authentication
-const publicPathRegex = /^\/(request\/pay|claim|pay\/.+$|support)/
+// Allow access to some public paths without authentication
+const publicPathRegex = /^\/(setup|request\/pay|claim|pay\/.+$|support)/

Optionally, consider a clearer pattern (future): ^/(setup|request/pay|claim|pay/[^/]+|support)(?:/.*)?$.

src/app/(mobile-ui)/home/page.tsx (1)

158-178: Duplicate balance warning effect with looser conditions; unify to one source

This second effect duplicates the first but omits !isPostSignupActionModalVisible, which can surface the warning over the post‑signup modal. It can also trigger redundant state updates. Remove or merge into a single effect (prefer the stricter first one).

-    // effect for showing balance warning modal
-    useEffect(() => {
-        if (isFetchingBalance || balance === undefined || !user) return
-
-        if (typeof window !== 'undefined') {
-            const hasSeenBalanceWarning = getFromLocalStorage(`${user!.user.userId}-hasSeenBalanceWarning`)
-            const balanceInUsd = Number(formatUnits(balance, PEANUT_WALLET_TOKEN_DECIMALS))
-
-            // show if:
-            // 1. balance is above the threshold
-            // 2. user hasn't seen this warning in the current session
-            // 3. no other modals are currently active
-            if (
-                balanceInUsd > BALANCE_WARNING_THRESHOLD &&
-                !hasSeenBalanceWarning &&
-                !showIOSPWAInstallModal &&
-                !showAddMoneyPromptModal
-            ) {
-                setShowBalanceWarningModal(true)
-            }
-        }
-    }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal, user])
🧹 Nitpick comments (1)
src/app/(mobile-ui)/home/page.tsx (1)

205-218: Minor: non-null assertion on username relies on layout auth gate

username! is fine given layout gating; if this component is ever reused outside that context, add a defensive check or derive from a single user source to avoid drift between useAuth and useUserStore.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0caee81 and 817a269.

📒 Files selected for processing (2)
  • src/app/(mobile-ui)/home/page.tsx (3 hunks)
  • src/app/(mobile-ui)/layout.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-18T09:30:42.901Z
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#1230
File: src/app/(mobile-ui)/withdraw/page.tsx:92-97
Timestamp: 2025-09-18T09:30:42.901Z
Learning: In src/app/(mobile-ui)/withdraw/page.tsx, the useEffect that calls setShowAllWithdrawMethods(true) when amountFromContext exists is intentionally designed to run only on component mount (empty dependency array), not when amountFromContext changes. This is the correct behavior for the withdraw flow where showing all methods should only happen on initial load when an amount is already present.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Deploy-Preview
🔇 Additional comments (1)
src/app/(mobile-ui)/home/page.tsx (1)

134-156: Early exit on missing user is correct; prevents null access

The !user guard and adding user to deps align the effect with auth state. Looks good.

@jjramirezn jjramirezn merged commit 445a2aa into peanut-wallet-dev Sep 30, 2025
5 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