Conversation
📝 WalkthroughWalkthroughMobile route entry points now share a common auth gate hook. The root, auth, and tabs layouts delegate redirect decisions to ChangesShared auth gating for mobile routing
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant Root
participant AuthLayout
participant TabsLayout
participant useAuthGate
User->>Root: open app
Root->>useAuthGate: redirectIfSignedIn / redirectIfSignedOut
useAuthGate-->>Root: null, Redirect, or undefined
alt gate returns Redirect
Root-->>User: redirect
else gate returns undefined
Root-->>User: render root content
end
User->>AuthLayout: open auth route
AuthLayout->>useAuthGate: redirectIfSignedIn "/(tabs)/home"
useAuthGate-->>AuthLayout: null, Redirect, or undefined
alt gate returns Redirect
AuthLayout-->>User: redirect to /(tabs)/home
else gate returns undefined
AuthLayout-->>User: render Stack
end
User->>TabsLayout: open tabs route
TabsLayout->>useAuthGate: redirectIfSignedOut "/(auth)/sign-in"
useAuthGate-->>TabsLayout: null, Redirect, or undefined
alt gate returns Redirect
TabsLayout-->>User: redirect to /(auth)/sign-in
else gate returns undefined
TabsLayout-->>User: render Tabs
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/mobile/app/(tabs)/_layout.tsx (1)
6-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider extracting the auth-gating boilerplate.
The
isLoaded/isSignedIngate here duplicates the same shape inapps/mobile/app/(auth)/_layout.tsxandapps/mobile/app/index.tsx. A small shared hook (e.g.useAuthGate) returning a redirect element ornullwould reduce triplication as more route groups are added.🤖 Prompt for 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. In `@apps/mobile/app/`(tabs)/_layout.tsx around lines 6 - 11, The auth-loading and sign-in redirect logic in TabsLayout is duplicated in other route entry points, so extract it into a shared hook such as useAuthGate that returns either a Redirect element or null. Update TabsLayout to delegate the isLoaded/isSignedIn handling to that shared helper, and reuse the same hook from the auth layout and app index so the auth-gating pattern stays centralized as more routes are added.
🤖 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.
Nitpick comments:
In `@apps/mobile/app/`(tabs)/_layout.tsx:
- Around line 6-11: The auth-loading and sign-in redirect logic in TabsLayout is
duplicated in other route entry points, so extract it into a shared hook such as
useAuthGate that returns either a Redirect element or null. Update TabsLayout to
delegate the isLoaded/isSignedIn handling to that shared helper, and reuse the
same hook from the auth layout and app index so the auth-gating pattern stays
centralized as more routes are added.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: be3594d8-e012-4195-a429-06cfcc9eb7ab
📒 Files selected for processing (2)
apps/mobile/app/(auth)/_layout.tsxapps/mobile/app/(tabs)/_layout.tsx
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/mobile/app/index.tsx (1)
5-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting route targets to a shared constant.
"/(tabs)/home"and"/(auth)/sign-in"are repeated as literals here and in(auth)/_layout.tsx/(tabs)/_layout.tsx. Centralizing them (e.g. a smallroutes.tsconstants module) avoids drift if a route path is ever renamed.♻️ Example extraction
+// apps/mobile/constants/routes.ts +export const ROUTES = { + tabsHome: "/(tabs)/home", + authSignIn: "/(auth)/sign-in", +} as const;+import { ROUTES } from "`@/constants/routes`"; const gate = useAuthGate({ - redirectIfSignedIn: "/(tabs)/home", - redirectIfSignedOut: "/(auth)/sign-in", + redirectIfSignedIn: ROUTES.tabsHome, + redirectIfSignedOut: ROUTES.authSignIn, });🤖 Prompt for 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. In `@apps/mobile/app/index.tsx` around lines 5 - 6, The redirect targets in the app entry and layout files are duplicated string literals, so centralize them into a shared routes constants module. Update the values used by the app redirect config and the `(auth)/_layout.tsx` and `(tabs)/_layout.tsx` consumers to import the same symbols instead of hardcoding `"/(tabs)/home"` and `"/(auth)/sign-in"`, so route changes stay in sync.
🤖 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.
Nitpick comments:
In `@apps/mobile/app/index.tsx`:
- Around line 5-6: The redirect targets in the app entry and layout files are
duplicated string literals, so centralize them into a shared routes constants
module. Update the values used by the app redirect config and the
`(auth)/_layout.tsx` and `(tabs)/_layout.tsx` consumers to import the same
symbols instead of hardcoding `"/(tabs)/home"` and `"/(auth)/sign-in"`, so route
changes stay in sync.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a9768fc-a506-43de-9947-adaee7f71628
📒 Files selected for processing (4)
apps/mobile/app/(auth)/_layout.tsxapps/mobile/app/(tabs)/_layout.tsxapps/mobile/app/index.tsxapps/mobile/hooks/useAuthGate.tsx
✅ Files skipped from review due to trivial changes (1)
- apps/mobile/hooks/useAuthGate.tsx
Summary by CodeRabbit