fix(app-router): restore shallow pathname on history traversal - #2829
fix(app-router): restore shallow pathname on history traversal#2829GtechGovind wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee5604e238
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 126007f9e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e4bdabd84
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f54ae1f078
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
/bigbonk |
Summary
history.pushStateandhistory.replaceStateentriesusePathnameanduseSearchParamswhen popstate takes the same-route fast pathRoot cause
External History API calls updated Vinext's navigation-hook URL cache, but the App Router popstate fast path only restored history metadata and scroll position. It did not resynchronize the hooks or first restore an entry-specific tree when traversing to the same pathname and search. The pushed entry also lacked a marker that would let forward traversal reuse the current tree instead of attempting an RSC navigation.
Durable shallow snapshots were pruned by numeric traversal index when branching, but a traversal to an older metadata-less entry made that cutoff unknown. A later push discarded the browser's forward branch without releasing its durable React trees.
The new internal shallow URL metadata identifies those entries, snapshot restoration now runs before the same-route shortcut, and pushes from metadata-less entries clear the app-owned snapshot branch.
Fixes #1541.
Validation
./node_modules/.bin/vp check./node_modules/.bin/vp test run tests/app-browser-history-controller.test.ts(22 passed)./node_modules/.bin/vp test run tests/shims.test.ts -t 'preserves App Router history metadata when external history calls provide caller state'PLAYWRIGHT_PROJECT=app-router ./node_modules/.bin/playwright test tests/e2e/app-router/advanced.spec.ts -g 'Shallow Routing'(7 passed, 1 existing fixme skipped)