fix: mobile routing renders Dashboard instead of correct page (#162) #163
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Relates to #162
Severity: Critical
Problem
Direct URL navigation on mobile (e.g. typing
/garage/fuel-logsor/garage/maintenancein the address bar, or refreshing the page) renders the Dashboard instead of the correct page. Only bottom-nav button taps correctly navigate. This means bookmarked links and shared URLs break on mobile.Acceptance Criteria
Implementation Plan (from #162 -- Milestone 2)
Phase: 1 (Foundation) | Priority: Critical | Depends on: None | Blocks: None
Context
Mobile navigation uses Zustand state-based nav (
activeScreenin the navigation store), NOT React Router. When a user navigates directly to a URL like/garage/maintenance, the browser path is ignored and the Dashboard screen renders instead. URLs and Zustand screen state are never synchronized.Implementation
1. Create route-to-screen mapping in
frontend/src/core/store/navigation.ts:2. In
frontend/src/App.tsx, adduseEffectfor URL-to-screen sync on mount:window.location.pathnameMobileScreenvalue using the mapping abovenavigateToScreen()from Zustand store3. Sync screen changes back to browser URL:
activeScreenchanges in Zustand, callwindow.history.replaceState()to update the browser URL4. Prevent stale localStorage override:
activeScreenfrom Zustandpartializepersist config to avoid stale localStorage overriding URLs on reloadFiles
frontend/src/App.tsxfrontend/src/core/store/navigation.tsCommit Convention
Test Criteria
/garage/maintenance) renders the correct pageRisk Notes
Branch
Work on branch
issue-162-ux-design-audit-cleanup(shared with all #162 sub-issues)Milestone: Mobile URL-to-Screen Sync
Phase: Execution | Agent: Developer | Status: PASS
Changes Made
1. Route-to-screen mapping (
navigation.ts)routeToScreenmapping: 16 URL paths toMobileScreenvalues (including/garage,/garage/dashboard, all feature and admin routes)screenToRoutereverse mapping:MobileScreenvalues to canonical URL pathsactiveScreenfrompartializepersist config to prevent stale localStorage from overriding URL on reload2. URL sync effects (
App.tsx)useEffect: readswindow.location.pathname, maps viarouteToScreen, callsnavigateToScreen()so direct URLs render the correct screenactiveScreenwatcheruseEffect: callswindow.history.replaceState()to keep browser URL in sync when Zustand state changes (enables bookmarks and URL sharing)3. Store barrel export (
store/index.ts)routeToScreenandscreenToRoutefor use in App.tsxFiles Modified
frontend/src/core/store/navigation.ts- route mappings + persist fixfrontend/src/App.tsx- URL sync effectsfrontend/src/core/store/index.ts- exportsVerification
Commit
0e8c607-fix: sync mobile routing with browser URL for direct navigation (refs #163)Verdict: PASS | Next: Browser testing on mobile (320px, 768px) and desktop (1920px) viewports