Skip to content

refactor: move compiled Router scroll restoration into Strong match tree - #2129

Merged
trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:feat/strong-router-scroll-2059
Oct 17, 2026
Merged

trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:feat/strong-router-scroll-2059

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Move the compiled Router’s scroll-restoration script from the compatibility lifecycle module into the existing Strong match tree. The script remains beneath the same immediate child of the root route, with the same SSR source, CSP nonce, permanent-static hydration range, and post-hydration removal. Keep the location predicate live because the Router object survives location changes.

This narrows the ownership tracked by #2059; pending/error handling still makes MatchLifecycle.tsrx a compatibility dependency. No public API changes.

Validation

  • pnpm format:check — repository-wide check not run; scoped formatting passed for all changed files.
  • pnpm typecheck — repository-wide check not run; pnpm typecheck:files passed for the four changed source/test files.
  • pnpm test — repository-wide run not performed locally. A filtered install could not load an unrelated StyleX dependency from the root Vitest config; an external config mirroring the two owning projects ran Router and Router SSR: 141/141 tests across 22 files.
  • targeted tests: the same scroll hydration suite passed 9/9 on main 175b85d and the candidate; compiled cases exercise accepting/declining predicates, SSR script and nonce, hydration, root identity, and navigation without script reinsertion. A transform-only negative control omitting the compiled client arm produced the expected hydration mismatch.
  • Matched production website builds in Chromium: each restored seeded scrollY=640 before hydration while client JavaScript was gated, executed the byte-identical SSR script once, removed it during hydration, retained header/main identity, reset to 0 on the Benchmarks link, restored 640 on Back and 0 on Forward, and restored/focused #async-ui for direct and in-page anchors. One document request per independent flow; no page/console errors or hydration warnings.
  • Tracked website Strong analysis: 54 authored modules, zero diagnostics on both builds; the same MatchLifecycle.tsrx compatibility dependency remains. pnpm sync passed.
  • perf-review: scan found no candidates. CompiledScrollRestoration (packages/tanstack-router/src/compiled/Matches.tsrx:104) runs per enabled root-child render/SSR request; the production client output keeps main’s three memo slots and eager predicate, and SSR keeps the same script range. No new record shapes, DOM measurement, listeners, or scheduling. Complete emitted public JS inventory: 619 files on each build, +23 raw bytes and +20 summed per-file gzip bytes (level 9, mtime 0); this is not route transfer size. Browser latency was not benchmarked.
  • concise-code: binding source +21/-25 lines (core runtime +0/-0); no new source module or public export; the only new file is the package changeset. Reusing ordinary ScriptOnce would use the wrong Router context; a new adapter/module would add an unnecessary owner. The location-keyed const alternative changed callback evaluation, so the local conditional preserves main’s generated behavior.

Risk / follow-ups

Strong rendering requires pure application predicates; this change preserves the current generated evaluation but does not make side-effectful predicates safe. Whole-package Strong compliance, pending/error lifecycle ownership, lazy loading, and generic-renderer removal remain open under #2059.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · host com-79386


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Touches SSR scroll-script markup and hydration parity for the compiled entry; behavior is intended to be unchanged and is heavily regression-tested, but mismatches would affect initial load scroll restoration.

Overview
Moves compiled scroll-restoration script rendering from the compatibility MatchLifecycle module into the Strong Matches tree as a local CompiledScrollRestoration, still emitted under the root route’s immediate child with the same router-core script, CSP nonce, and Hydrate/never() static SSR arm.

The location predicate stays live on each render (rendersScript + router.latestLocation) so function-valued scrollRestoration options keep evaluating after navigations without changing router identity.

Conformance coverage now runs the scroll-restoration hydration suite for both ordinary and compiled providers (nonce, accept/decline predicates, post-hydration script removal, no script on client navigation). Package status/docs and a patch changeset record that the compiled scroll script is Strong-owned; pending/error scroll lifecycle wording is dropped from the compatibility-owned list.

Reviewed by Cursor Bugbot for commit d28e75e. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent refactor PR: internal restructuring, no behavior change labels Oct 17, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 17, 2026 19:35
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 175b85dfc, the merge commit's first parent with 1fa6b7e84 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.833 2.692 −0.0% −3.8% … +0.0% ⚪ within noise
octane-tsrx replace 5.892 5.650 +0.8% −3.5% … +3.5% ⚪ within noise
octane-tsrx add 2.575 2.592 −3.9% −12.1% … ±0.0% ⚪ within noise
octane-tsrx update 0.094 0.093 −0.3% −3.7% … +1.5% ⚪ within noise
octane-tsrx select 0.006 0.006 −0.7% −3.6% … +1.9% ⚪ within noise
octane-tsrx swap 0.017 0.017 −0.7% −5.0% … +1.5% ⚪ within noise
octane-tsrx remove 0.014 0.014 −0.9% −2.8% … +0.5% ⚪ within noise
octane-tsrx runlots 22.908 23.192 +0.6% −0.8% … +2.6% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 +0.5% −0.5% … +1.6% ⚪ within noise
octane-tsrx clear 37.592 37.392 +0.5% −1.9% … +2.9% ⚪ within noise
octane-jsx run 3.417 3.375 ±0.0% −1.4% … +2.9% ⚪ within noise
octane-jsx replace 5.833 5.933 +1.7% −1.6% … +5.1% ⚪ within noise
octane-jsx add 3.083 2.992 ±0.0% −3.4% … +3.1% ⚪ within noise
octane-jsx update 0.159 0.163 +1.5% −1.1% … +3.3% ⚪ within noise
octane-jsx select 0.087 0.089 −0.3% −3.1% … +2.0% ⚪ within noise
octane-jsx swap 0.130 0.130 −0.6% −2.1% … +1.8% ⚪ within noise
octane-jsx remove 0.111 0.114 +0.0% −1.7% … +1.8% ⚪ within noise
octane-jsx runlots 27.458 27.042 −0.5% −2.7% … +2.2% ⚪ within noise
octane-jsx select_lots 0.934 0.944 +0.6% −6.2% … +3.9% ⚪ within noise
octane-jsx clear 37.775 37.650 +2.2% −1.7% … +3.7% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 93 measured values.

Public-import reachability bundles (bytes)

No changes across 123 measured values.

@trueadm
trueadm merged commit 9c79968 into octanejs:main Oct 17, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent refactor PR: internal restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants