Skip to content

fix(browser-sync): reflect the step path in the address bar - #3

Open
a22hobman wants to merge 1 commit into
mainfrom
fix/browser-sync-url
Open

fix(browser-sync): reflect the step path in the address bar#3
a22hobman wants to merge 1 commit into
mainfrom
fix/browser-sync-url

Conversation

@a22hobman

Copy link
Copy Markdown
Collaborator

Problem

useJourneyBrowserSync already computes each history entry's path (from the active top step — hooks.ts makeEntry), but every pushState/replaceState call passes "" as the URL argument and omits the path:

history.pushState(makeEntry({ position: positionRef.current }), "");   // no URL

When you call pushState/replaceState with no URL, the browser deliberately keeps the current address. So the location bar never updates on in-app navigation. Deep-linking and back/forward still work (state carries path, and popstate reconstructs from data.path), but:

  • the visible URL stays stale as you drill, so you can't copy the bar to share a specific position;
  • consumers that read window.location see stale segments — notably segment-based layout routers (e.g. strata, which cascades templates → slots → components off URL segments) would cascade off the wrong, stale path.

Fix

Pass the entry's path as the third pushState/replaceState argument at all four sync sites (initial replaceState, forward push, workspace-switch push, in-place replace). The history state shape is unchanged, so popstate reconstruction is unaffected; this only surfaces the path that was already being tracked.

Tests

  • Updated the four browser-sync assertions to expect the URL arg.
  • Full suite 99/99 green, tsc --noEmit clean, tsup build OK.

Notes

  • No version bump / publish in this PR — left to the maintainer's release step (the repo bumps versions in dedicated commits).
  • Found while dogfooding journey-stack + strata in the conducted-desk shell (the address bar showed no paths as you navigated).

🤖 Generated with Claude Code

useJourneyBrowserSync computed each history entry's `path` (from the active top
step) but passed "" as the pushState/replaceState URL argument, so the browser kept
the current address and the location bar never updated on in-app navigation. Deep-link
and back/forward worked (state carries `path`), but the visible URL stayed stale — and
consumers that read window.location (e.g. segment-based layout routers like strata,
which cascades templates off URL segments) saw stale segments.

Pass the entry's `path` as the third pushState/replaceState argument at all four
sync sites (initial replaceState, forward push, workspace-switch push, in-place
replace). State shape is unchanged, so popstate reconstruction is unaffected.

Tests: updated the four browser-sync assertions to expect the URL arg; full suite
99/99 green, tsc clean, build OK.
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