Repository navigation
fix(auth): avoid setup redirect on expired token - #1435
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoPrevent false setup redirects during auth startup
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
1.
|
Skip competing hard window.location.assign redirects on bootstrap /auth/me 401 responses, and retry /auth/setup/status before falling back to /auth/login rather than /setup. Fixes #1430
…n frontend HTTP client
Retry /api/auth/setup/status with bounded backoff on the login page so a first-run store still redirects to /setup after transient startup errors. Fixes #1430
f0c8da0 to
faa4ad4
Compare
Intent
When starting the app after an update (or when the app has been closed and a previously stored token in
localStorageis expired or invalidated), the app sometimes opens onto the first-run/setupscreen instead of/auth/login, requiring the user to close the app and start it a second time (which then shows/auth/login). Investigate and fix this startup routing edge case (tracked in #1430).Follow the Obra Superpowers engineering procedure end-to-end (research, spec/plan under
~/tools/firstmate/data/flocafe-startup-setup-redirect-r1/, TDD red-green-refactor, verification, andno-mistakesvalidation pipeline). Keep PR title<= 50chars, single-line PR body paragraphs, and includeFixes #1430.What Changed
skipAuthRedirect: trueonloadFromStorage'sGET /auth/mestartup probe and clear in-memory auth state on failure so expired or invalidated stored tokens do not racewindow.location.hrefnavigation againstAuthGuard's setup-status check.GET /auth/setup/statusup to twice with a 400ms delay inAuthGuard,/setup, and/auth/login, and fall back toneedsSetup = falseinAuthGuardafter retries are exhausted instead of routing an initialized store to/setup.tests/auth-ui-deterministic.test.tsand documentskipAuthRedirecthandling indocs/architecture/frontend.md.Fixes #1430
Risk Assessment
✅ Low: The changes are minimal, targeted fixes that prevent competing 401 full-page unloads during auth bootstrap, add bounded retries for setup-status probes, and fall back to normal login routing rather than stranding initialized stores on /setup, backed by deterministic unit tests and updated documentation.
Testing
Ran
npm run test:auth-ui-deterministic,npm run test:script-coverage,npm run build,npm run build:frontend, and live Playwright Chromium E2E tests against the running backend and static desktop frontend export covering all five startup and setup-status routing scenarios, capturing five browser screenshots as visual evidence; all checks passed.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run test:auth-ui-deterministicnpm run test:script-coveragenpm run build && npm run build:frontendcd frontend && npx playwright test e2e/auth.spec.ts --config=playwright.config.ts --project=chromiumLive Playwright Chromium browser verification of expired-token startup, transient and persistent/api/auth/setup/statusfailures, first-run/setupredirect, and initialized/setupbounce-back to/auth/loginwith screenshot capture✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.