Skip to content

Bug: A non user generated route shows up when going back two pages #200

Description

@kirillakovalenko

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.

Image

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

  1. From the edit page, run optimize and let the app navigate to /results (route renders correctly).
  2. Click the browser Back arrow once.
  3. 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.tsxreadInitialRoutes 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

  • Navigating back to /results (including the double-Back case in Reproduction) never displays mockRouteData.
  • When no real optimizeResults data is present, /results shows the empty/error state rather than a fabricated route.
  • A freshly optimized route still renders correctly on first navigation to /results.
  • ?mock=1 still loads the fixture route for visual QA.
  • Regression test covers the "empty sessionStorage → no mock route shown" case.

Assignee

@Gill87

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions