Description
On the results page, a route that the user never created can appear after they navigate back through their browser history. The results page reads the user's optimized routes from sessionStorage under the key optimizeResults, but it also ships a mock/example route as a fallback that renders whenever that key is missing. Once the user lands back on /results with an empty optimizeResults, the page silently shows the demo route instead of an empty/error state — making it look like a real route the user generated.
The fallback is intentional for visual QA (results/page.tsx:43-52), but it leaks into the normal user flow because the page deletes optimizeResults from sessionStorage immediately after the first successful load (results/page.tsx:72-76). So any back-navigation that remounts /results re-reads an now-empty key and drops into the mock fallback.
Goal
A user who navigates back to the results page never sees a mock/example route — they see their own route or an appropriate empty/error state.
Reproduction
Steps
- From the edit page, run optimize and let the app navigate to
/results (route renders correctly).
- Click the browser Back arrow once.
- Click the browser Back arrow a second time (landing back on
/results, or forward/back into it).
Expected: The results page shows the user's optimized route, or — if no route data is available — a clear empty/error state ("Run optimize again from the edit page").
Actual: A mock/example route (mockRouteData) is displayed as if it were a route the user generated.
Environment: branch main; Next.js UI under app/ui. Root cause in app/ui/src/app/results/page.tsx — readInitialRoutes returns mockRouteToRoute(mockRouteData) when sessionStorage.getItem("optimizeResults") is null, and the useEffect removes that key after the first load.
Scope
In scope
- Remove the mock-route fallback from the real user flow on
/results, or gate it strictly behind the existing ?mock=1 flag so it never renders during normal navigation.
- Fix the interaction between the
sessionStorage.removeItem("optimizeResults") cleanup and back-navigation remounts so re-entering /results does not lose / fake the user's route data.
- Show a proper empty/error state when no real route data exists.
Out of scope
- The
?mock=1 explicit demo path (results/page.tsx:33-41) — keep this as a deliberate QA tool.
- Redesigning how optimize results are persisted/passed to the results page (e.g. moving off
sessionStorage), unless required to fix the above.
Acceptance Criteria
Assignee
@Gill87
Description
On the results page, a route that the user never created can appear after they navigate back through their browser history. The results page reads the user's optimized routes from
sessionStorageunder the keyoptimizeResults, but it also ships a mock/example route as a fallback that renders whenever that key is missing. Once the user lands back on/resultswith an emptyoptimizeResults, the page silently shows the demo route instead of an empty/error state — making it look like a real route the user generated.The fallback is intentional for visual QA (results/page.tsx:43-52), but it leaks into the normal user flow because the page deletes
optimizeResultsfromsessionStorageimmediately after the first successful load (results/page.tsx:72-76). So any back-navigation that remounts/resultsre-reads an now-empty key and drops into the mock fallback.Goal
A user who navigates back to the results page never sees a mock/example route — they see their own route or an appropriate empty/error state.
Reproduction
Steps
/results(route renders correctly)./results, or forward/back into it).Expected: The results page shows the user's optimized route, or — if no route data is available — a clear empty/error state ("Run optimize again from the edit page").
Actual: A mock/example route (
mockRouteData) is displayed as if it were a route the user generated.Environment: branch
main; Next.js UI underapp/ui. Root cause in app/ui/src/app/results/page.tsx —readInitialRoutesreturnsmockRouteToRoute(mockRouteData)whensessionStorage.getItem("optimizeResults")is null, and theuseEffectremoves that key after the first load.Scope
In scope
/results, or gate it strictly behind the existing?mock=1flag so it never renders during normal navigation.sessionStorage.removeItem("optimizeResults")cleanup and back-navigation remounts so re-entering/resultsdoes not lose / fake the user's route data.Out of scope
?mock=1explicit demo path (results/page.tsx:33-41) — keep this as a deliberate QA tool.sessionStorage), unless required to fix the above.Acceptance Criteria
/results(including the double-Back case in Reproduction) never displaysmockRouteData.optimizeResultsdata is present,/resultsshows the empty/error state rather than a fabricated route./results.?mock=1still loads the fixture route for visual QA.Assignee
@Gill87