Skip to content

feat: add useLayoutSnapshot - #1677

Closed
domgan-oai wants to merge 5 commits into
octanejs:mainfrom
openai-oss-forks:feat/use-layout-snapshot
Closed

domgan-oai wants to merge 5 commits into
octanejs:mainfrom
openai-oss-forks:feat/use-layout-snapshot

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Add useLayoutSnapshot for values that need to be measured from committed DOM and reflected in rendered output before paint. A stable initial value is used for server rendering and hydration; measurements publish only when they change.

Validation

  • pnpm format:check (repository-wide check not run; changed files passed the scoped formatter)
  • pnpm typecheck (the full workspace command was blocked before typechecking by registry HTTP 403 responses for unrelated dependencies; Octane core and public API typechecks passed)
  • pnpm test (full suite not run)
  • Targeted layout snapshot, compiler, and server shell tests: 122 passed across development and production projects; 1,705 nearby Strong and Suspense tests also passed.
  • Chromium: four development and production scenarios exercised real DOM geometry and verified the committed result by the first animation frame, with a deferred-update control.
  • Website documentation and examples compiled for client and server, including Strong development and production. The website route test could not collect locally because a dependency was unavailable in the filtered installation.
  • pnpm sync, changeset and release-plan checks.
  • Required production bundle budgets: all 35 minimal scenarios and six application budgets passed; no budgets changed.

Risk / follow-ups

  • Measurements are commit-coupled and do not subscribe to independent layout changes. The DOM renderer supports the hook; the experimental universal and Valdi renderers reject it.
  • A non-converging measurement reaches the update-depth guard. Development diagnostics identify the hook and component source where available, but do not pinpoint the exact hook call.
  • The browser test observes the DOM by the first animation frame, not painted pixels. The bundle checks cover existing apps that do not use the new hook, not its cost in an app that does.

Provenance

  • An agent produced this diff (agent-authored)

Codex task: 01a0d872-201b-7472-bbe9-adcca6ba2406 · host: com-79386


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


Note

Medium Risk
New layout-time state publication path with suspense/async interaction and update-depth limits; DOM-only support means misuse on universal/Valdi is a compile-time rejection but wrong renderer choice could surprise adopters.

Overview
Ships useLayoutSnapshot as a public Octane hook for rendering from committed DOM measurements before paint, with initial for SSR/hydration and optional equal (default Object.is) so only changed snapshots schedule updates.

The DOM client runtime runs the measure callback in a layout effect, publishes updates with sync-flush semantics (including convergence guarding), and the server returns initial without measuring. The compiler registers the hook for slots, spread-args, passive setup, renderer boundaries (DOM only), and Strong mode treats the measure/equal callbacks like layout-effect work (no state writes, no leaked resources) while snapshot return values are not mistaken for effect cleanup.

Docs and site promote the API alongside createResizeObserver; tests cover hydration, Suspense/Activity, plain TS spreads, Chromium first-frame timing, and SSR shell witnessing.

Reviewed by Cursor Bugbot for commit 3c25981. 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 feat PR: new feature or capability labels Oct 3, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 3, 2026 17:51
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No budget breaches, no added work, and no timing changes beyond ±3%.

Compares 4778bf374, the merge commit's first parent with c85cbfada on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. 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.758 2.717 ±0.0% −3.4% … +3.7% ⚪ within noise
octane-tsrx replace 5.700 5.783 +1.6% −0.8% … +2.5% ⚪ within noise
octane-tsrx add 2.375 2.467 +0.0% ±0.0% … +4.2% ⚪ within noise
octane-tsrx update 0.121 0.119 −1.5% −2.5% … −0.5% ⚪ within noise
octane-tsrx select 0.005 0.005 +0.0% −0.5% … +0.5% ⚪ within noise
octane-tsrx swap 0.031 0.031 ±0.0% −0.9% … +0.9% ⚪ within noise
octane-tsrx remove 0.017 0.017 −0.4% −2.2% … +1.8% ⚪ within noise
octane-tsrx runlots 23.450 23.317 +0.6% −3.2% … +5.5% ⚪ within noise
octane-tsrx select_lots 0.005 0.005 +0.5% −0.3% … +1.1% ⚪ within noise
octane-tsrx clear 39.558 39.283 −0.0% −2.0% … +1.6% ⚪ within noise
octane-jsx run 3.133 3.033 −0.0% −4.4% … +1.5% ⚪ within noise
octane-jsx replace 6.192 5.767 +1.7% −2.5% … +3.4% ⚪ within noise
octane-jsx add 2.917 2.958 ±0.0% −0.0% … +2.9% ⚪ within noise
octane-jsx update 0.224 0.231 +0.7% ±0.0% … +4.2% ⚪ within noise
octane-jsx select 0.119 0.123 +3.5% +2.6% … +6.9% ⚪ within noise
octane-jsx swap 0.211 0.210 +1.6% ±0.0% … +2.7% ⚪ within noise
octane-jsx remove 0.160 0.164 +1.2% −1.2% … +3.9% ⚪ within noise
octane-jsx runlots 26.925 26.475 +1.3% −2.4% … +2.5% ⚪ within noise
octane-jsx select_lots 1.357 1.333 −0.6% −1.9% … +0.9% ⚪ within noise
octane-jsx clear 39.958 42.442 +1.6% +0.4% … +3.2% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx bindings_js_gzip 240,407 240,396 −11 (−0.0%) 🟢
octane-tsrx bindings_js_brotli 204,738 204,641 −97 (−0.0%) 🟢
octane-tsrx bindings_app_gzip 121,728 121,717 −11 (−0.0%) 🟢
octane-tsrx bindings_app_brotli 101,836 101,739 −97 (−0.1%) 🟢

50 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
binding-aria-esbuild brotli 2,980 2,979 −1 (−0.0%) 🟢

104 other measured values are unchanged.

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 feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants