Skip to content

fix(web): preserve deep-link routes when setup is incomplete#136

Merged
WZ merged 1 commit into
mainfrom
fix/routing-no-provider
Apr 24, 2026
Merged

fix(web): preserve deep-link routes when setup is incomplete#136
WZ merged 1 commit into
mainfrom
fix/routing-no-provider

Conversation

@WZ
Copy link
Copy Markdown
Owner

@WZ WZ commented Apr 24, 2026

Summary

Closes ISSUE-001 from the QA report on PR #133. Direct URL navigation to any route silently redirected to `/settings` when the active stack had no provider — bookmarks, shared deep links, and 404 fallbacks were broken.

Root cause

The auto-routing `useEffect` in `src/web/App.tsx` (lines 117-129 before this change) ran on every setup-stage transition and pushed the user to `/settings` regardless of where they currently were. There was no check for the current pane.

Fix

  • Extracted the redirect decision into a pure helper, `autoRouteTargetForSetupStage`, paired with the existing `shouldResetOnStackSwitch` pattern.
  • Helper returns `null` for any non-dashboard pane (deep link / shared link / browser reload) and for the `notfound` view (typo'd URLs render the 404 instead of bouncing).
  • Returns `"settings"` or `"services"` only when the user is on the dashboard and the setup stage warrants a nudge.
  • The setup stepper at the top of every page still surfaces the next setup step, so onboarding nudge is preserved.

Verified end-to-end

  • `/investigations` → stays at `/investigations` ✓
  • `/services` → stays at `/services` ✓
  • `/investigations?severity=high&range=7d` → query string preserved ✓
  • `/xyz-does-not-exist` → renders NotFound page (was: silent redirect) ✓
  • `/` → still redirects to `/settings` when no provider ✓ (the intended nudge)

Test plan

  • New unit tests for `autoRouteTargetForSetupStage` cover all six gating clauses + two positive paths
  • Existing `shouldResetOnStackSwitch` tests still pass
  • `npx tsc --noEmit` clean
  • Manual browser pass against a fresh, no-provider stack

🤖 Generated with Claude Code

QA caught: opening /investigations, /services, /scan/runs/:id, or any
other route via direct URL load (bookmark, shared link, browser reload)
silently redirected to /settings whenever the active stack had no
provider. The setup-stage useEffect didn't check the current pane —
it pushed every visitor to /settings on initial mount and then back
again on every stage transition. Bookmarks, deep links, and 404s
broken.

Scope the auto-redirect to dashboard origin only:
- Extract the decision into a pure helper, autoRouteTargetForSetupStage,
  paired with the existing shouldResetOnStackSwitch pattern.
- The helper returns null whenever the user is already on a non-dashboard
  route (deep link respected) or on the notfound view (typo'd URLs render
  the 404 instead of bouncing to /settings).
- The setup stepper at the top of every page still surfaces the next
  step, so first-time onboarding nudge is preserved on /, just not
  forced on every URL.

Tests:
- New unit tests cover all six gating clauses (deep route, notfound,
  complete, dismissed, loading, already-routed-this-stage) plus the two
  positive paths (needs-provider → settings, needs-discovery → services).
- Verified end-to-end in the browser: /investigations, /services,
  /investigations?severity=high&range=7d, and /xyz-does-not-exist all
  preserve their URLs on a fresh load with no provider configured.
  Dashboard / still redirects to /settings (the intended nudge).
@WZ WZ merged commit 062a3f7 into main Apr 24, 2026
2 checks passed
@WZ WZ deleted the fix/routing-no-provider branch April 25, 2026 03:28
WZ added a commit that referenced this pull request Apr 25, 2026
…01) (#136)

QA caught: opening /investigations, /services, /scan/runs/:id, or any
other route via direct URL load (bookmark, shared link, browser reload)
silently redirected to /settings whenever the active stack had no
provider. The setup-stage useEffect didn't check the current pane —
it pushed every visitor to /settings on initial mount and then back
again on every stage transition. Bookmarks, deep links, and 404s
broken.

Scope the auto-redirect to dashboard origin only:
- Extract the decision into a pure helper, autoRouteTargetForSetupStage,
  paired with the existing shouldResetOnStackSwitch pattern.
- The helper returns null whenever the user is already on a non-dashboard
  route (deep link respected) or on the notfound view (typo'd URLs render
  the 404 instead of bouncing to /settings).
- The setup stepper at the top of every page still surfaces the next
  step, so first-time onboarding nudge is preserved on /, just not
  forced on every URL.

Tests:
- New unit tests cover all six gating clauses (deep route, notfound,
  complete, dismissed, loading, already-routed-this-stage) plus the two
  positive paths (needs-provider → settings, needs-discovery → services).
- Verified end-to-end in the browser: /investigations, /services,
  /investigations?severity=high&range=7d, and /xyz-does-not-exist all
  preserve their URLs on a fresh load with no provider configured.
  Dashboard / still redirects to /settings (the intended nudge).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant