fix(mobile): stop the signed-out launch redirect loop #494
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.45) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 448 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.365
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #494"
general
weight: 0.35
mattmck
What was wrong
After the Expo SDK 58 / expo-router 58.0.26 upgrade (#486), a cold signed-out launch froze on a blank screen and logged "Maximum update depth exceeded" hundreds of times.
Root cause. I instrumented on the iOS simulator (expo-router's guard resolution,
Redirectand the navigation tree reducer). The router alternatedNAVIGATE_TO_HREFREPLACE/auth→/→/auth:1. When signed out, the
(app)guard fails. It had noredirectTo, so expo-router falls back to the first unguarded sibling in its route sort order. That isauth, becauseauthis shorter thansign-in(getNavigatorFallbackinlayouts/GuardContext). The fallback href is/auth.2.
auth.tsxalways renders<Redirect href="/" />.3.
/resolves to(app)/(tabs)/index, inside the guarded group, so step 1 runs again.This is the same mechanism as expo/expo#52072, where the default fallback's URL lands back inside a guarded group. Here the fallback route redirects instead of sharing the URL. It can be fixed in app code, so this needs no
patch-package.Fix
apps/mobile/src/app/_layout.tsx: eachStack.Protectednow names its target.(app)→/sign-in, andsign-in→/.apps/mobile/src/api/client.ts: on sign-out, the Collection tab refetches after the token is cleared. Those requests go out without a bearer and get 401s. Every 401 used to count as an expired session, so sign-out showed "The API stopped accepting the dev session". Now only a 401 on a request that carried a token expires the session (same change for the export download).apps/mobile/README.md: notes for both changes.Verification
On an iOS 27 simulator (iPhone 18 Pro, a separate "SW Debug" device) with a native dev build from this branch:
/sign-in). No update-depth errors.- A cold launch shows sign-in.
- "Continue as dev user" opens the Collection tab.
- Profile → Sign out returns to sign-in with no error banner.
- Signing in a second time and signing out again also works.
- No JS errors or warnings in the simulator log for the run.
npm run typecheck --workspace=apps/mobile,npm run test --workspace=apps/mobile(231 pass) andnpm run lint --workspace=apps/mobileall pass.I did not test Entra sign-in itself (it needs real credentials). It goes through the same
status→ guard path as dev bypass.Testing note: the dev build installed on the shared iPhone 18 Pro simulator was built with
expo run:ios --port 8082, which compiles the Metro port into the app. It always loads from port 8082, whatever dev-client URL orRCT_jsLocationyou set. To test a different worktree you need a separate build (expo run:ios --port <n> --device <other sim>).🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Prevented requests sent without an authorization token from triggering session expiration after a 401 response.
Updated sign-in redirects to prevent loops between signed-in and signed-out routes.
Prevented token refreshes interrupted by sign-out or a session change from expiring or clearing the replacement session.
Documentation
Clarified authentication fallback routing and how 401 responses are handled after sign-out.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->