Skip to content

Add install PWA step in invites flow android#1534

Open
Zishan-7 wants to merge 2 commits intodevfrom
fix/invite-android-force-pwa
Open

Add install PWA step in invites flow android#1534
Zishan-7 wants to merge 2 commits intodevfrom
fix/invite-android-force-pwa

Conversation

@Zishan-7
Copy link
Contributor

@Zishan-7 Zishan-7 commented Dec 4, 2025

No description provided.

@vercel
Copy link

vercel bot commented Dec 4, 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 Dec 4, 2025 7:10pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

When an invite code and initial step are present, the setup flow now conditionally routes Android devices not running as a standalone PWA to an Android PWA install view; other cases continue to the signup step. No public signatures changed.

Changes

Cohort / File(s) Summary
Setup page branch
src/app/(setup)/setup/page.tsx
Added platform and PWA-mode detection to route Android non-standalone devices to android-initial-pwa-install instead of directly advancing to signup when an invite code exists.
Install PWA view & setup store usage
src/components/Setup/Views/InstallPWA.tsx
Introduced ISetupStep typing, read inviteCode and steps from setup store, added useAppDispatch dispatch; Continue fallback now dispatches setupActions.setStep(signupIndex + 1) for Android invite flows, otherwise calls existing handleNext().
Redux slice (action usage)
src/redux/slices/setup-slice (usage)
New/public action setupActions.setStep(index: number) is dispatched by UI to jump to a specific setup step.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check correctness of Android and standalone PWA detection logic and user-agent/platform assumptions.
  • Verify signup step index resolution from steps and off-by-one correctness when dispatching setStep.
  • Confirm setupActions.setStep implementation semantics and that stepping integrates with existing flow state.
  • Ensure android-initial-pwa-install route/view exists and handles the incoming state (inviteCode/steps) as expected.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
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.
Description check ❓ Inconclusive No pull request description was provided, making it impossible to assess relevance to the changeset. Add a pull request description explaining the purpose and impact of adding the PWA install step in the Android invites flow.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly relates to the main change: adding an Android PWA install step in the invites flow, which matches the code changes that branch Android devices to an android-initial-pwa-install screen.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/invite-android-force-pwa

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.

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0af0f1e and 16b5b61.

📒 Files selected for processing (1)
  • src/app/(setup)/setup/page.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1251
File: src/app/invite/page.tsx:44-53
Timestamp: 2025-09-25T11:18:10.633Z
Learning: The setup page (/setup) contains the waitlist functionality in the welcome step using the JoinWaitlist component, so redirecting users to /setup for joining the waitlist is correct.
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1089
File: src/components/LandingPage/dropLink.tsx:35-42
Timestamp: 2025-08-12T17:44:04.268Z
Learning: In the Peanut UI project, opening the `/setup` route in a new tab from landing page CTAs is intentional design behavior to keep users on the marketing page while they start the setup process.
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1241
File: src/components/ForceIOSPWAInstall/index.tsx:6-51
Timestamp: 2025-10-15T06:45:22.055Z
Learning: In the ForceIOSPWAInstall component (src/components/ForceIOSPWAInstall/index.tsx), the blocking behavior without a skip/dismiss option is intentional by design to force PWA installation on iOS devices.
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1251
File: src/components/Invites/JoinWaitlistPage.tsx:41-55
Timestamp: 2025-09-29T18:34:33.596Z
Learning: In the JoinWaitlistPage component, after successfully accepting an invite via invitesApi.acceptInvite(), calling fetchUser() is sufficient to update the user state and automatically display the app. No manual navigation to /home or other pages is required since the user is already on the home page and the app will be displayed once user.hasAppAccess is updated.
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1072
File: src/app/(setup)/setup/page.tsx:173-175
Timestamp: 2025-08-07T12:53:50.946Z
Learning: In the peanut-ui setup flow at `src/app/(setup)/setup/page.tsx`, when handling unsupported scenarios, both device not supported and browser not supported cases should show the same "Unsupported browser" message using the `UnsupportedBrowserModal` component, rather than having distinct messaging for each scenario.
📚 Learning: 2025-08-07T12:53:50.946Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1072
File: src/app/(setup)/setup/page.tsx:173-175
Timestamp: 2025-08-07T12:53:50.946Z
Learning: In the peanut-ui setup flow at `src/app/(setup)/setup/page.tsx`, when handling unsupported scenarios, both device not supported and browser not supported cases should show the same "Unsupported browser" message using the `UnsupportedBrowserModal` component, rather than having distinct messaging for each scenario.

Applied to files:

  • src/app/(setup)/setup/page.tsx
📚 Learning: 2025-09-29T18:34:33.596Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1251
File: src/components/Invites/JoinWaitlistPage.tsx:41-55
Timestamp: 2025-09-29T18:34:33.596Z
Learning: In the JoinWaitlistPage component, after successfully accepting an invite via invitesApi.acceptInvite(), calling fetchUser() is sufficient to update the user state and automatically display the app. No manual navigation to /home or other pages is required since the user is already on the home page and the app will be displayed once user.hasAppAccess is updated.

Applied to files:

  • src/app/(setup)/setup/page.tsx
📚 Learning: 2025-10-08T17:13:13.155Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1299
File: src/app/(mobile-ui)/points/page.tsx:41-51
Timestamp: 2025-10-08T17:13:13.155Z
Learning: In `src/app/(mobile-ui)/points/page.tsx`, the icon name "invite-heart" is intentionally used (not "inviter-heart") when displaying who invited the current user, as this is a deliberate design choice despite semantic differences with UserHeader usage.

Applied to files:

  • src/app/(setup)/setup/page.tsx
📚 Learning: 2025-09-25T11:18:10.633Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1251
File: src/app/invite/page.tsx:44-53
Timestamp: 2025-09-25T11:18:10.633Z
Learning: The setup page (/setup) contains the waitlist functionality in the welcome step using the JoinWaitlist component, so redirecting users to /setup for joining the waitlist is correct.

Applied to files:

  • src/app/(setup)/setup/page.tsx
🧬 Code graph analysis (1)
src/app/(setup)/setup/page.tsx (2)
src/components/Setup/Setup.types.ts (1)
  • ISetupStep (43-55)
src/redux/slices/setup-slice.ts (1)
  • setupActions (69-69)
⏰ 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/(setup)/setup/page.tsx (1)

129-138: The review comment is based on an incorrect interpretation of the code flow.

The code at lines 129-138 determines which step to initially navigate to when entering the setup flow, not the progression from android-initial-pwa-install. The logic correctly distinguishes between two initial entry points:

  • Android users not in standalone PWA mode start at android-initial-pwa-install (index 1)
  • All other users start at signup (index 5)

The actual progression from android-initial-pwa-install follows the setupSteps array order: android-initial-pwa-install (index 1) → pwa-install (index 2) → landing (index 3) → welcome (index 4) → signup (index 5), which is the correct flow design.

Likely an incorrect or invalid review comment.

Comment on lines +129 to +138
// if user is on android and not in a standalone pwa, force them to install the PWA first
if (localDeviceType === 'android' && !isStandalonePWA) {
const androidInitialPwaInstallScreenIndex = steps.findIndex(
(s: ISetupStep) => s.screenId === 'android-initial-pwa-install'
)
dispatch(setupActions.setStep(androidInitialPwaInstallScreenIndex + 1))
} else {
const signupScreenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
dispatch(setupActions.setStep(signupScreenIndex + 1))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add missing error handling for findIndex results.

The code uses findIndex to locate step indices but doesn't check if the step exists (returns -1), unlike the existing logic at lines 140-148 which properly handles this case. If either 'android-initial-pwa-install' or 'signup' steps are missing from the steps array, this would dispatch invalid step indices.

Apply this diff to add consistent error handling:

 // If invite code is present, set the step to the signup screen
 if (determinedSetupInitialStepId && userInviteCode) {
     // if user is on android and not in a standalone pwa, force them to install the PWA first
     if (localDeviceType === 'android' && !isStandalonePWA) {
         const androidInitialPwaInstallScreenIndex = steps.findIndex(
             (s: ISetupStep) => s.screenId === 'android-initial-pwa-install'
         )
-        dispatch(setupActions.setStep(androidInitialPwaInstallScreenIndex + 1))
+        if (androidInitialPwaInstallScreenIndex !== -1) {
+            dispatch(setupActions.setStep(androidInitialPwaInstallScreenIndex + 1))
+        } else {
+            console.warn('Could not find android-initial-pwa-install step. Defaulting to step 1.')
+            dispatch(setupActions.setStep(1))
+        }
     } else {
         const signupScreenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
-        dispatch(setupActions.setStep(signupScreenIndex + 1))
+        if (signupScreenIndex !== -1) {
+            dispatch(setupActions.setStep(signupScreenIndex + 1))
+        } else {
+            console.warn('Could not find signup step. Defaulting to step 1.')
+            dispatch(setupActions.setStep(1))
+        }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// if user is on android and not in a standalone pwa, force them to install the PWA first
if (localDeviceType === 'android' && !isStandalonePWA) {
const androidInitialPwaInstallScreenIndex = steps.findIndex(
(s: ISetupStep) => s.screenId === 'android-initial-pwa-install'
)
dispatch(setupActions.setStep(androidInitialPwaInstallScreenIndex + 1))
} else {
const signupScreenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
dispatch(setupActions.setStep(signupScreenIndex + 1))
}
// if user is on android and not in a standalone pwa, force them to install the PWA first
if (localDeviceType === 'android' && !isStandalonePWA) {
const androidInitialPwaInstallScreenIndex = steps.findIndex(
(s: ISetupStep) => s.screenId === 'android-initial-pwa-install'
)
if (androidInitialPwaInstallScreenIndex !== -1) {
dispatch(setupActions.setStep(androidInitialPwaInstallScreenIndex + 1))
} else {
console.warn('Could not find android-initial-pwa-install step. Defaulting to step 1.')
dispatch(setupActions.setStep(1))
}
} else {
const signupScreenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
if (signupScreenIndex !== -1) {
dispatch(setupActions.setStep(signupScreenIndex + 1))
} else {
console.warn('Could not find signup step. Defaulting to step 1.')
dispatch(setupActions.setStep(1))
}
}
🤖 Prompt for AI Agents
In src/app/(setup)/setup/page.tsx around lines 129 to 138, the code calls
findIndex for 'android-initial-pwa-install' and 'signup' but doesn't handle a -1
result; mirror the existing handling at lines 140-148 by checking the found
index for -1, and if -1 log an error (or console.error) and dispatch a safe
fallback (e.g., setStep(0) or the same fallback used later) instead of
dispatching an invalid index; otherwise dispatch setStep(foundIndex + 1) as
before.

@notion-workspace
Copy link

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16b5b61 and a1d5c95.

📒 Files selected for processing (1)
  • src/components/Setup/Views/InstallPWA.tsx (4 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1089
File: src/components/LandingPage/dropLink.tsx:35-42
Timestamp: 2025-08-12T17:44:04.268Z
Learning: In the Peanut UI project, opening the `/setup` route in a new tab from landing page CTAs is intentional design behavior to keep users on the marketing page while they start the setup process.
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1251
File: src/components/Invites/JoinWaitlistPage.tsx:41-55
Timestamp: 2025-09-29T18:34:33.596Z
Learning: In the JoinWaitlistPage component, after successfully accepting an invite via invitesApi.acceptInvite(), calling fetchUser() is sufficient to update the user state and automatically display the app. No manual navigation to /home or other pages is required since the user is already on the home page and the app will be displayed once user.hasAppAccess is updated.
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1251
File: src/app/invite/page.tsx:44-53
Timestamp: 2025-09-25T11:18:10.633Z
Learning: The setup page (/setup) contains the waitlist functionality in the welcome step using the JoinWaitlist component, so redirecting users to /setup for joining the waitlist is correct.
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1241
File: src/components/ForceIOSPWAInstall/index.tsx:6-51
Timestamp: 2025-10-15T06:45:22.055Z
Learning: In the ForceIOSPWAInstall component (src/components/ForceIOSPWAInstall/index.tsx), the blocking behavior without a skip/dismiss option is intentional by design to force PWA installation on iOS devices.
📚 Learning: 2025-09-29T18:34:33.596Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1251
File: src/components/Invites/JoinWaitlistPage.tsx:41-55
Timestamp: 2025-09-29T18:34:33.596Z
Learning: In the JoinWaitlistPage component, after successfully accepting an invite via invitesApi.acceptInvite(), calling fetchUser() is sufficient to update the user state and automatically display the app. No manual navigation to /home or other pages is required since the user is already on the home page and the app will be displayed once user.hasAppAccess is updated.

Applied to files:

  • src/components/Setup/Views/InstallPWA.tsx
📚 Learning: 2025-09-25T11:18:10.633Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1251
File: src/app/invite/page.tsx:44-53
Timestamp: 2025-09-25T11:18:10.633Z
Learning: The setup page (/setup) contains the waitlist functionality in the welcome step using the JoinWaitlist component, so redirecting users to /setup for joining the waitlist is correct.

Applied to files:

  • src/components/Setup/Views/InstallPWA.tsx
📚 Learning: 2025-10-15T06:45:22.055Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1241
File: src/components/ForceIOSPWAInstall/index.tsx:6-51
Timestamp: 2025-10-15T06:45:22.055Z
Learning: In the ForceIOSPWAInstall component (src/components/ForceIOSPWAInstall/index.tsx), the blocking behavior without a skip/dismiss option is intentional by design to force PWA installation on iOS devices.

Applied to files:

  • src/components/Setup/Views/InstallPWA.tsx
🧬 Code graph analysis (1)
src/components/Setup/Views/InstallPWA.tsx (2)
src/components/Setup/Setup.types.ts (1)
  • ISetupStep (43-55)
src/redux/slices/setup-slice.ts (1)
  • setupActions (69-69)
⏰ 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

Comment on lines +224 to +230
// If user is on android and has an invite code, redirect to signup screen
if (inviteCode && deviceType === DeviceType.ANDROID) {
const signupScreeenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
dispatch(setupActions.setStep(signupScreeenIndex + 1))
} else {
handleNext()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix typos and add error handling for missing signup step.

Issues identified:

  1. Typo in variable name (line 226): signupScreeenIndex has three 'e's—should be signupScreenIndex.
  2. Typo in comment (line 224): "screeeen" should be "screen".
  3. Logic clarification needed: The comment states "redirect to signup screen", but the code navigates to signupScreenIndex + 1 (the step after signup). Please verify if the intent is to navigate TO the signup step or to the step AFTER signup.
  4. Missing error handling: If the signup step is not found, findIndex returns -1, causing setStep(0) to be dispatched, which may not be the desired behavior.

Apply this diff to fix the typos and add error handling:

-                        // If user is on android and has an invite code, redirect to signup screen
+                        // If user is on android and has an invite code, redirect to signup screen
                         if (inviteCode && deviceType === DeviceType.ANDROID) {
-                            const signupScreeenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
-                            dispatch(setupActions.setStep(signupScreeenIndex + 1))
+                            const signupScreenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
+                            if (signupScreenIndex !== -1) {
+                                dispatch(setupActions.setStep(signupScreenIndex + 1))
+                            } else {
+                                // Fallback to handleNext if signup step not found
+                                handleNext()
+                            }
                         } else {
                             handleNext()
                         }

Note: If the intent is to navigate TO the signup step (not after it), remove the + 1. Please clarify the expected navigation target and update the comment accordingly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// If user is on android and has an invite code, redirect to signup screen
if (inviteCode && deviceType === DeviceType.ANDROID) {
const signupScreeenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
dispatch(setupActions.setStep(signupScreeenIndex + 1))
} else {
handleNext()
}
// If user is on android and has an invite code, redirect to signup screen
if (inviteCode && deviceType === DeviceType.ANDROID) {
const signupScreenIndex = steps.findIndex((s: ISetupStep) => s.screenId === 'signup')
if (signupScreenIndex !== -1) {
dispatch(setupActions.setStep(signupScreenIndex + 1))
} else {
// Fallback to handleNext if signup step not found
handleNext()
}
} else {
handleNext()
}
🤖 Prompt for AI Agents
In src/components/Setup/Views/InstallPWA.tsx around lines 224 to 230, fix the
typos and add error handling: rename signupScreeenIndex to signupScreenIndex and
correct the comment to "screen"; determine navigation target — if the intent is
to go TO the signup step remove the "+ 1" when calling setStep, otherwise keep
it to go after signup; add a guard after findIndex that checks for -1 and, in
that case, log an error/warning and fall back to handleNext() (do not dispatch
setStep(0) silently).

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