Skip to content

feat: align ViewTransition with React and add element scopes - #1095

Merged
domgan-oai merged 22 commits into
octanejs:mainfrom
openai-oss-forks:codex/react-view-transition-parity
Sep 15, 2026
Merged

domgan-oai merged 22 commits into
octanejs:mainfrom
openai-oss-forks:codex/react-view-transition-parity

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Align ViewTransition with React 19.3 for activation classes, transition type maps, stable names and refs, pseudo-element APIs, geometry/mutation detection, and cleanup at native animation finish.

  • Prepare ViewTransition updates with an optional DOM plan, then publish the accepted mutations inside the native update callback. This fixes nested update="none" captures while preserving node identity, committed handlers, deletion cleanup, and urgent interruption.

  • Add opt-in <ViewTransition scope="element"> with independent sibling/nested animations, names local to each native owner, and scope-targeted pseudo-element handles.

  • Animate streamed Suspense reveals and coordinate document/element captures across streaming, hydration, and client updates.

  • Remove per-node staging helper calls from ordinary rendering and run the existing js-framework work guards in PR CI.

  • Skip inactive driver calls during effect/scope cleanup and Activity/Suspense deactivation; guard post-transition cleanup work in Chromium CI.

Contract and implementation

Ordinary rendering retains its eager DOM path. After the optional ViewTransition driver is installed, all-transition batches can prepare a DOM plan, including batches that discover a newly entering boundary. Preparation uses the finished boundary activation props; old snapshots retain their previous names, matching React. Native publication accepts that plan once, runs mutation/insertion work, waits for relevant resources, completes refs/layout effects and their updates, then waits for an already-pending navigation before the new capture.

The plan retains real node identities. Suspended attempts cancel their writes; reentrant same-root refreshes finish accepted work before applying newer props; replacements and unmounts invalidate stale work. Retired cleanup remains owed even when an earlier callback unmounts the root. Hydration disposers and abort signals remain live until an accepted deletion publishes.

Element scopes

scope="element" requires one persistent direct host and adds no wrapper. Omitted boundaries inherit their nearest scope or use the document. Names, sharing, activation callbacks, pseudo-element targets, and cleanup belong to each native owner. One scheduled batch still publishes its DOM and layout work once across all participating owners. Sibling scopes can overlap; nested scopes can start after an ancestor's capture; work affecting a busy owner waits for its animation. Ordinary urgent work interrupts affected scopes; flushSync interrupts all.

The host retains native self-participation and clipping. Its default name is root; authored CSS names and none are respected, with an explicit component name taking precedence during capture. An unnamed scope's stable ref follows its host's committed CSS name. A shared stylesheet rule makes [vt-scope="element"] hosts scopes; authored inline !important can override it. Marker coownership preserves shared hosts until the final scope declaration is removed. Client and SSR use the same rule without style-setter hooks or inline hydration handoff attributes.

Unsupported Element.startViewTransition, invalid/missing hosts, and replaced scope roots commit normally without promoting the update to a document animation. Invalid visible hosts warn once in development. A callback-only native overload is detected and cached per native function; unexpected native failures report through the owning root handler while publishing once. The minimum browser version is unchanged. This is a progressive Octane extension based on the native element-scoped API.

Reference snapshots for React compatibility: React 19.3.0 and React main for the already-supported experimental parent relays. Gesture APIs remain a separate feature.

Validation

  • Cleanup follow-up current-head CI: all 26 jobs passed on ea346c0ce48926f076ae135d6cf3437dd011ecb2, including core/React parity, native Chromium, both work guards, lint, types, package validation, examples and compatibility. Cursor Bugbot passed. The Linux cleanup artifact reproduces all 12 local counts, source/compiler/fixture/harness hashes and complete emitted assets exactly; js-framework remains 34,088/46,167 calls. This head contains main ede01deec, is mergeable, and has a clean worktree. All 23 review threads are resolved; the earlier maintainer Changes requested review remains for re-review.
  • Scoped formatting; strict core/public types; explicit changed-fixture tsrx-tsc projects.
  • Final pnpm sync, scoped formatting and strict core/fixture types; nine staged-DOM checker cases including deliberate bypass mutations; production core build.
  • Receiver-change full local core development/production: 1,026 suites, 18,280 tests passed. Final typed receiver checker: 9/9; CI wiring tests: 63/63. After the final four event guards: strict core types, 85 native tests, 74 event tests in dev/prod, and 72 checker/workflow tests pass. The public staged host-state control passes in both modes; replacing inline receivers with native nodes makes both fail at the old-snapshot assertion.
  • Historical first-round broad core development/production: 1,026 suites, 18,214 passing tests and 14 existing expected failures. This broad local run was not repeated for round two; focused checks below and full current-head CI cover the new changes.
  • Final native Chromium 149: 85/85 across client parity (34), element scopes (34), streaming/hydration (15), and host-state projection (2), in development/production where applicable.
  • Round-two SSR/state/API neighbors: 184/184; async cache regression rechecked after its typing-only edit (4/4). Client scoped-effects/resume/staging/lifecycle: 114/114 before the final bounded-cascade regression, then 52/52 scoped-effects tests; host-state: 14/14. Added regressions fail under the corresponding pre-fix behavior or deliberate mutation.
  • Updated the four moved SSR evidence paths in the React parity ledger; both inventories, all 5,569 ledger entries, coverage report, and 8 cited dev/prod cases pass locally.
  • Production minified/readable semantic controls, ordinary style work controls, native adapter counters, and paired client/SSR measurements.
  • Previous-head CI: all 26 jobs passed on c6fb27a9f4f56693e6fe80435404692e9e582db2, including core/React-parity shards, native browser integration, the new js-framework work guard, lint/types, package validation, runtime loaders, examples and compatibility. Cursor Bugbot also passed. The Linux CI artifact records 34,088/46,167 calls and 33,040/61,653 gzip bytes; its source hash, compiled fixture inputs and emitted asset manifests exactly match the local final evidence. All 23 review threads remain resolved. The branch contains main fe1b2b7e6, has no merge conflict and is clean. The earlier maintainer Changes requested review remains for re-review.

Performance

The ordinary-client regression and its fix are recorded first in RESULTS.md, with complete canonical run reports, hashes, failure controls, and measurement limits. Final TSRX/JSX gzip sizes are 33,040/61,653 bytes: +767/+1,425 versus main, and +182/+578 versus the reviewed PR. Inline native selection removes the extra function calls, but stage branches and shared code still have a bundle cost. No zero-overhead claim is made.

The following paragraphs describe the earlier review rounds; the latest client measurements supersede their client-byte observations.

Final feedback measurements and comparisons against both the reviewed head and main are recorded in RESULTS.md, with raw distributions, source/fixture/asset hashes and reproducible commands. Ordinary controls exclude the optional driver and adapter. Scope style-setter hooks are removed; all 40 ordinary style work cases retain their counts. Native capture and rectangle counts remain unchanged, while unused old-capture computed-style reads are removed.

The 1,024-row retained-plus-append adapter control eliminates 3,672,576 copied sibling slots and 2,100,224 searched slots. Its full-parent clear uses one clear instead of 2,048 removals. Projection caching reduces imported nodes from 51,694 to 1,102 for 48 radio association reads on a page with 1,024 unrelated hosts. These are deterministic work reductions, not claims about whole-application latency or allocations.

Round two adds realistic pages with one tiny boundary among 200 or 1,600 unrelated rows. Against 759330f3, the 24.6 KB page improves from 139.350 to 22.108 µs (84%), and the 197 KB page from 1,220.954 to 310.027 µs (75%). A separate comparison against the earlier e36dec2b4 implementation verifies that the page regression is removed (20.707 → 19.718 µs and 298.967 → 285.458 µs). Ordinary client bundle sizes and capture/read counters are unchanged; document/scope fixtures add 24/43 gzip bytes.

Trusted raw HTML deliberately retains the robust parser: its 24.6 KB case improves from 133.401 to 82.955 µs against the reviewed implementation, but remains slower than the earlier unsafe regex (15.070 → 80.078 µs in that paired run). Tiny ready View retains a +0.583 µs cost against the earlier implementation; stream distributions track the plain control, with no speedup claimed. The combined server benchmark fixture adds 800 gzip bytes against 759330f3. Final source/dependency/fixture hashes, every timing sample and rejected intermediate runs are in review-round-two.json.

Risk / follow-ups

This expands the optional ViewTransition commit path substantially and adds a null-guarded host receiver adapter with a static guard for typed DOM accesses. Native capture barriers, overlapping owners, staged publication, interruption, hydration, rollback, and reentrancy have separate coverage. Feature-only projections and capture records add CPU and allocation cost. Whole-document observers and repeated owner discovery still have costs; a previously installed driver can stage batches without a currently mounted boundary. Active large-tree end-to-end CPU, browser paint cost, GC, and concurrent SSR throughput are not measured by the focused fixtures. A full host-operations-table rewrite remains a separate architectural change; this PR consolidates structural reads and guards the existing typed receiver seam.

Local core checks use an isolated configuration excluding the React differential setup, tests/differential/**, and imperative-dom.test.ts; full repository checks and React parity run in CI. After merging main's TSRX migration, the configured registry returned HTTP 403 for its locked TSRX packages. The requester explicitly approved downloading those exact versions from npm's public registry with lockfile SHA-512 verification. Only the worktree's local dependency graph was repaired; no tracked registry or dependency configuration was changed. The install still stopped on unrelated [email protected], which was not fetched from an alternate registry.

Provenance

  • An agent produced this diff (agent-authored)

Review feedback

Effect cleanup follow-up

Final head ea346c0ce incorporates main ede01deec (native signal styles). The benchmark-list conflict preserves both sets of guards. Post-merge verification retains identical cleanup assets, compiled fixture inputs, all call counts, and semantic observations; source/merge provenance is recorded separately without rewriting the original measurements. 616 focused tests, 89 native browser cases, strict runtime/fixture types, 72 checker/workflow tests, and 43/43 benchmark guards pass again. Sync/formatting are current.

Commit c19852c37 optimizes the installed-but-idle driver path. unmountScope, runScopeCleanups, and deactivateScope call staging methods only during an active staged capture. Active teardown/deactivation ordering and rollback remain intact; no new state or allocation is introduced.

The unchanged effectful-list TSRX and JSX fixtures reproduce the regression after an actual completed native transition. Clearing/remounting 1,000 rows removes 2,000 function calls, and removing 100 scattered rows removes 200, in each dialect. Cold control counts remain identical. These are function-entry reductions, not latency claims. Feature-containing fixture bundles add 23 raw bytes each and +3/+5 gzip bytes. Other installed-driver lifecycle work remains.

The final baseline and candidate share exact compiler, fixture, compiled-input, dependency, harness and toolchain hashes. See cleanup evidence and limits and the adjacent committed measurement report. Baseline ead781345 passes semantic checks but breaches 18 of the 30 new guards; the optimized candidate passes all 30. The complete registered ViewTransition suite passes 43/43 guards. CI now runs the cleanup guard and uploads its results alongside js-framework work results.

Local validation for this cleanup follow-up:

  • 534 focused development/production tests and 89 native browser cases pass; scope covers effects, refs, Activity/Suspense, hydration, staged transitions and urgent abort cleanup.
  • Strict runtime typecheck and explicit changed-fixture tsrx-tsc pass. Corrected the browser fixture's missing JSON-safe nestedTransition field.
  • 72 staged-DOM checker/workflow tests pass; deliberately broken cleanup staging/fallthrough produces the intended behavioral failures in both modes.
  • Canonical effectful-list: all six original operations pass in JSX and TSRX (one-sample semantic smoke; no timing comparison). Shared operation descriptors/oracles are preserved.
  • Scoped formatting, staged-DOM classification and pnpm sync pass; generated outputs are current and the worktree is clean.
  • Full repository test/typecheck matrices were not rerun locally for this follow-up; all current-head CI jobs now pass (linked above).

Ordinary client benchmark regression

The reviewed ab2c29e65 failed the existing js-framework production-call guards even without ViewTransition imports. Inline stage selection for local receivers removes the identity helper from hot DOM operations. Complex receiver expressions still evaluate once before selecting the stage; the checker validates the exact receiver binding. Twelve immediate local captures remove the remaining per-row insertion calls without caching across component callbacks.

The unchanged canonical guard now records TSRX 46,090 → 34,088 calls and JSX 60,209 → 46,167 calls per 1,000-row mount; main is 34,083/46,162 and the original limits remain 35,000/50,000. Both fixed repetitions pass with identical DOM/identity/event observations. A one-sample control confirms the new CI wrapper rejects both reviewed builds. The Chromium PR job now executes this guard and uploads its JSON on failure.

A warmed follow-up caught a remaining JSX selection cost from the 2,000 event-bundle updates per click. Guarding projection by active capture removes the idle optional-call assignment. In a fresh balanced comparison with 40 warmups and 80 samples per operation, final selection medians are 0.35/0.30 ms against main’s 0.30/0.40; swapping is 0.50/0.50 against 0.50/0.60. All identity, ordering and selection gates pass. The precise native/staging publication order is preserved, and final built assets match the measured prototype exactly. The shorter canonical sample still has a smaller JSX selection score difference (0.34/0.34 ms versus 0.22/0.28); the warmed comparison does not reproduce it, and early-run effects are not conclusively excluded.

Merged main’s style-spread optimization fe1b2b7e6 in b891b99f6. New main and final canonical assets are byte-identical to the measured baseline and candidate, with identical compiled fixture inputs; the separate equivalence report records updated source hashes. Strict types, the original guard, all 85 native cases and 112 style regressions pass after the merge. Document/scope bundle assets and native observations also remain identical. Historical timing hashes remain intact.

Second-round history

Second-round feedback is addressed in 8c2fbf753, after merging main bb11d0b3e:

  • Restore native candidate scanning for compiler-emitted SSR pages, with quote-aware parsing for trusted HTML. Preserve adjacent attributes, uppercase raw-text closing tags, and raw provenance across retries, memoized output, async components and streams; scan ClaimArm attributes once.
  • Inject and adopt scope styles in the committed host's ownerDocument, with per-document deduplication. Cover staged iframe adoption and existing SSR styles in native Chromium.
  • Settle passive effects introduced by nested flushSync before selecting capture owners and priority. A bounded cascade falls back to normal commits; an urgent sibling makes the entire batch commit without animation.
  • Retain fresh nodes removed and reinserted during DOM preparation; restrict checker exemptions to reviewed module-level declarations.
  • Correct the stylesheet guide and cite the task's explicit “Expand into staged DOM commits” authorization. The previously accepted stream-error retention behavior remains unchanged.

CI follow-up ab2c29e65 replaces a TypeScript parameter property in the raw-HTML wrapper with an explicit field assignment so Node's native type-stripping loader can import it. The six public loader regressions pass after reproducing the failures locally. Both standalone server transforms and the complete measured SSR bundle remain byte-identical; the equivalence evidence is recorded alongside the historical timing hashes.

First-round history

Integrated the maintainer's supplied fixes from d38e8477d and addressed the remaining review in 9aa4d7621, with the measured SSR parser follow-up in fc0dbf32b:

  • Preserve accepted DOM writes during pending same-root refreshes; keep eager event delegation and registration consistent across suspension, rollback, external roots and pending portal deletion.
  • Replay streamed errors/aborts after queued parent reveals, including dormant hydration; align SSR names, scope ownership, parsing and stylesheet behavior.
  • Refresh passive/resume batches before scope scheduling, preserve urgent priority and caller-thrown errors (including undefined), and report native failures for newly entering roots.
  • Cache and invalidate selector/form projections, use linked staged child records and eligible bulk clears, avoid ordinary subtree freshness scans, and retain scroll geometry readback.
  • Consolidate 269 structural reads through host helpers and add a typed DOM-access CI checker with mutation tests. Add native/public renderer regressions and move Octane feature suites out of conformance.
  • Document the explicitly authorized staged-commit trade-off, test same-commit activation and name changes, and replace scope style leases with one shared stylesheet rule.

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


Note

High Risk
Touches ViewTransition commit/staging, DOM receivers, SSR parsing, and effect cleanup on core rendering paths; regressions would affect animation correctness and ordinary client performance.

Overview
Aligns Octane ViewTransition with React 19.3 (activation classes, type maps, staged DOM commits, element scope="element", streamed Suspense reveals) and keeps ordinary renders cheap via inline native DOM receivers, active-capture-gated event projection, and no inactive stageTeardown during effect/Activity/Suspense cleanup after a transition finishes.

Adds a view-transitions benchmark suite (bundle reachability, native capture/read budgets, dom-stage adapter work, scoped SSR/client fixtures) plus wrappers that run the canonical js-framework and effectful-list harnesses against selected Octane revisions. Shared lifecycle oracles move into effectful-list/contract.mjs.

CI (Chromium browser lane) now runs deterministic js-framework work and effect-cleanup guards and uploads JSON artifacts; benchmarks/baselines/ratios.json registers ~40 ratio ceilings so optional driver/staging stay out of ordinary bundles and cleanup cannot regress.

Patch bumps for octane and @octanejs/mcp-server; MCP exposes the new benchmark tools (per changeset).

Reviewed by Cursor Bugbot for commit ea346c0. 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 Sep 14, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 7cd5428. Configure here.

Comment thread packages/octane/src/runtime.server.ts Resolved
Comment thread packages/octane/src/runtime.server.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
@domgan-oai
domgan-oai marked this pull request as ready for review September 14, 2026 19:32
@domgan-oai domgan-oai changed the title feat: align ViewTransition commits and streaming with React 19.3 feat: align ViewTransition with React and add element scopes Sep 14, 2026

@trueadm trueadm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full review of e36dec2b4 (base 277c10c3f). I read every hunk, ran the jsdom and Chromium ViewTransition suites locally, and verified each finding below against the head with a throwaway test or a traced code path. Local runs on the head: jsdom view-transition* + conformance + hydration 316/316, browser parity/scopes/streaming 68/68, pnpm sync clean, Prettier clean.

The parity work itself is thorough, and the new browser suites are a real asset. The problems are concentrated in the two new mechanisms, the staged DOM plan and element scopes, where the eager-commit invariants the rest of the runtime relies on stop holding. Seven confirmed correctness defects, two of them regressions from main.

Applied for you

I cannot push to openai-oss-forks (GitHub's maintainer-can-modify only covers user-owned forks), so the small fixes are on octanejs/octane branch fix/vt-review-fixes-1095, commit d38e8477d, based on this PR's head. Cherry-pick it onto the branch:

git fetch https://github.com/octanejs/octane fix/vt-review-fixes-1095 && git cherry-pick FETCH_HEAD

It contains, each with a regression test that fails on e36dec2b4 and passes after:

  1. vtFlush snapshots the batch before pre-render passives run (runtime.ts:6496-6501). queuedOwners/queuedBlocks are default parameters, so they are evaluated before drainPassivesBeforeRender(); a passive that calls startTransition(() => set()) pushes a block that the same work() renders but every planning loop skips. That scope's DOM changes inside another scope's transition with no capture, no startViewTransition on its owner and no onUpdate (regression: base captured all of VT_REGISTRY). Fix: snapshot after the passive drain. Test: view-transition-scoped-effects.test.ts "captures a scope whose update a pre-render passive effect schedules".
  2. Render errors inside an animated commit are demoted to onRecoverableError/console.error (runtime.ts:6606-6609, 6780, 6940-6956, 4696-4715). The drain error is caught into drainError, only re-surfaces via the update callback's rejection, and the sync rethrow at 6973 needs every group settled, which never holds. await act(...) resolves, actErrors never sees it, a root without onUncaughtError gets a console line, and the guide's "actionable native failures" sentence is applied to render errors. Base rethrew (sync path) or queueMicrotask(() => { throw }). Fix: the error is known before any native start, so interrupt() (publishes the prepared work) and rethrow. Test: view-transition.test.ts "surfaces a render error thrown inside an animated transition to the caller".
  3. SSR vt-scope="none" survives hydration and excludes those hosts from every document capture (runtime.server.ts:4867, runtime.ts:3988, 4017, 4088-4091). The server stamps none on the hosts of an invalid scope="element" declaration; vtClosestScope treats any vt-scope attribute as a scope; vtPrepareScopeBoundary returns before the only code that rewrites the attribute. After hydration an outer <ViewTransition onUpdate> around such a declaration never animates, while the identical client-rendered tree does. Fix: only vt-scope="element" is a scope on the client; the server marker stays for the streaming driver. Test: view-transition-ssr.test.ts "keeps hydrated hosts of an invalid element scope in the document capture". The inline driver's owns() (runtime.server.ts:9185, if(node.hasAttribute("vt-scope"))return false;) has the same over-broad check for pre-hydration reveals of a document-owned outer boundary; I left it for you since it needs a streaming test.
  4. Secondary hosts are named name_1 by the server but name-1 by the client (runtime.server.ts:4811 vs runtime.ts:4392, 4506). Authored ::view-transition-group(card-1) CSS matches a client update but not the streamed reveal of the same boundary. Fix: -, pinned in "annotates each host and reserves auto for generated names".

Plus, covered by the existing suites (3014 jsdom, 85 browser tests green on the branch): DOMStage reads native firstChild/lastChild/siblings when the parent has no staged entry, and native attributes when the element has no staged twin (items 8 and 9 below); the inline-style hooks check VIEW_TRANSITION_DRIVER !== null before the property-name compare (item 12); dead deferPassives hook and stale comment, unused vtRegisterHandle _capture parameter, unused DOMStage.discard(); resetStreamRuntimeGlobals also clears __octaneViewTransitionScopes (the SSR suite hand-rolls this superset today).

Blocking, needs your change

  1. Same-body root.render while a stage is pending discards the whole DOM plan (runtime.ts:39088-39100, 7476, 7550, 7842-7846, 39022-39030). startTransition(() => root.render(App, a)) prepares the plan and calls startViewTransition; before the async update callback, a second startTransition(() => root.render(App, a)) (a router re-navigation, or startTransition(async () => { await x; root.render(...) })) bumps renderOwner.generation without interrupting (TRANSITION_DEPTH > 0) and without refreshPublishingOwner (requires inFlush). At stage.commit() every stagedOwnerGuard receipt fails, so the prepared host writes, effects and refs are dropped while block state already reflects them: text stays old, an @if switch leaves the old branch in the DOM and never inserts the new one, and the follow-up render is a no-op. Reproduced with a jsdom test that fails on this head (expected 'old-tail' to be 'a-tail') and passes on main; the different-body variant is fine. view-transition-staging.test.ts:221 only covers the same-root refresh from inside the native callback. Either bump generation only on an identity change (the comment at 39084-39086 already says identity changes are what discard staged state) or extend refreshPublishingOwner to the not-yet-published capture on a same-body refresh.
  2. Streamed $OCTRX no-ops while its parent's reveal is queued (runtime.server.ts:9099-9103, 9128-9130, 9055-9059, 9795-9811, 10113-10119, 10157). The driver queues every $OCTRC and parks a blocked item without running prepare(), so a nested child's <template data-oct-b> is still JSON text; $OCTRX stays synchronous and if(t){...} finds nothing. Server side the child's error chunk (and the abort tail) needs only the parent in flushedSegments and is written in the same wave. Reproduced: animated first boundary, wave 2 parent carrying a nested pending child, inner.reject() or controller.abort() → child sentinel never gets data-oct-err; a dormant <Hydrate> around the parent then waits forever (runtime.ts:13277, 13294-13322). Pre-PR $OCTRC was synchronous so "child template is in the DOM before its own $OCT* call" held (the comment at 10096-10099 still relies on it). Simplest driver-independent fix: make the base $OCTRX lazy (stash [id,so] when no template is found, re-apply at the end of $OCTRC after the content is inserted). No test covers $OCTRX/abort after a queued reveal; the recipe above belongs in view-transition-ssr.test.ts.
  3. Staged delegation attach is dropped on rollback while _delegated keeps saying it is attached (runtime.ts:20891-20909, 7493-7511; dom-stage.ts:139-153, 657-660, 881-889). delegateEvents writes _delegated.set(name, type) eagerly (never journaled) but the back-attach domNode(target).addEventListener(...) on the root container (user-supplied, so never fresh) is enqueued with the journal-cancellable guard. A transition attempt that mounts the app's first <input value> (or the first spread/de-opt on* of a type) and then suspends rolls back, the guard turns false, the listener is skipped at publish, and on resume delegateEvents hits _delegated.has(name) → continue, so that root never receives the type: controlled restore and every $$input-style handler for it are dead permanently. Reproduced in jsdom (0 input listeners on the container after resume, onInput never fires, controlled value stays drifted; the unstaged run attaches 2 and passes; attaching to the raw target fixes it). Note tests/_helpers.ts pre-delegates the common types, which is why the existing suites cannot see this. Listeners are not visual mutations and the bookkeeping is already eager, so attach eagerly (target.addEventListener at 20909, 20915, 20943, and the same for registerDelegationTarget), and add the test to view-transition-staging.test.ts. Same hazard one level up: stageDelegation (7864-7869) enqueues registerDelegationTarget through the same guard, so a createRoot inside a rolled-back staged render is never registered.

Performance model

Non-VT apps stay at a null check, which is good, and the bundle guard really asserts DOMStage/vtFlush exclusion. Note that vtWouldWrap (runtime.ts:4933-4938) wraps every all-transition flush once the driver exists, with or without a mounted boundary; that gate is unchanged from base, but the cost of a wrapped flush went from one callback to a full Proxy-staged drain, so an app that rendered one <ViewTransition> anywhere now stages every later startTransition commit. Inside an active transition the plan is quadratic in several places; none of the fixtures has a large list, so RESULTS.md cannot see it.

  1. DOMStage sibling/child reads were O(n) per read (dom-stage.ts:189-210, 366-373): every nextSibling/firstChild through a view copied Array.from(parent.childNodes) and indexOf-scanned it, so vtRangeElements, unmountBlockInner, the hydration cursor and every keyed walk became O(n²) during preparation. Fixed on the branch (native read when the parent has no staged entry; every staged structural write records one).
  2. Attribute reads cloned a twin per element (dom-stage.ts:796-806, 256-285): hasAttribute('vt-scope') runs on every boundary element and ancestor inside the staged window, and each call built an inert clone with all attributes copied. Fixed on the branch (native read when no twin exists).
  3. matches/closest/form/elements clone the whole document per call (dom-stage.ts:288-334, 414-416, 861; runtime.ts:3167-3176, 3199-3203, 22752). projection(node, true) re-clones from the document root on every call and nothing caches it; a controlled radio write under a journaled transition does form/elements/form !== form per cousin, so a 20-radio group on a 10k-node page clones ~420k nodes for one checked write.
  4. Staged insert/remove copy the whole child array per op (dom-stage.ts:651-659, 683-687): appending or clearing N rows into an existing parent inside a transition is O(N²) plus N discarded arrays, and batchClearItems under staging (runtime.ts:37488) forces the per-item path so the one-shot textContent = '' becomes N removeChild calls at publish. Mutate the cached array in place and test the trailing anchor before indexOf.
  5. Inline-style hot path paid a string compare before the driver null check (runtime.ts:19512, 19556-19604, 19646): every property write/removal in every app compared the name against 'view-transition-scope' first. Fixed on the branch by reordering; this is also what turned the clear loop into a block and forced the style-literals-work.mjs change (the count guard cannot see the added per-iteration work, so that edit is fair but hides the cost).
  6. Also worth a look: created() walks every subtree with an array per node just to find <template>s (dom-stage.ts:99-113, use querySelectorAll('template') for element/fragment roots); vtMeasureElements reads getComputedStyle for clip on every boundary in the before pass but only nextRects.clip is ever consumed (runtime.ts:4415-4443, 6413); the whole-document MutationObserver with characterData + attributes allocates a record for every write outside any boundary (runtime.ts:4540-4560, 4589-4633); vtScopeForBlock/vtClosestScope are recomputed up to four times per boundary per flush with no per-flush memo (runtime.ts:3986-4028, 4815, 6548, 6611, 6631); an unnamed scope="element" boundary with a ref forces two getComputedStyle reads per render (runtime.ts:13970-13976, 4195-4218); vtSsrMapTags slices and visits every nested tag for callers that only look at depth 0 (runtime.server.ts:4771, 4807, 4849-4866).

Design

  1. This reverses a documented decision without recording why. The base plan doc (docs/view-transitions-plan.md:151-159 at 277c10c3f) said: do not fix toward React by inventing a staged-mutation reconciler mode, it trades the eager-mutation performance model for a timing nicety. The PR builds exactly that (an 894-line Proxy projection, domNode() at ~1,190 call sites in ~240 functions, three hand-curated key lists, a 20-method DeferredLayoutDriver consulted from ~36 general-purpose sites) and rewrites the plan doc so neither the old decision nor the reason it was overturned survives; the guide still points at "the implementation plan and its documented edge cases" that no longer exist (docs/view-transitions.md:199-202). Whatever the outcome, the trade-off needs to be written down in the plan doc: which requirement made the base divergence unacceptable (as far as I can tell only a boundary whose own update/name prop flips in the same animated commit needs post-render props, and no test pins that case).
  2. The seam. getFirstChild/getNextSibling are the right shape (one indirection) and are then bypassed ~270 times by inline domNode(x).nextSibling. Nothing enforces "no live write during a stage": a future el.setAttribute without domNode() type-checks, passes every non-VT test, and corrupts the old snapshot only while a transition prepares. The existing operations layer (initDomOperations, runtime.ts:16097) is where a single swap for the staged window would replace the per-site wraps, and it would let dom-stage.ts drop PROJECTED_PROPERTIES, state() and projection().
  3. Scope lease vs. one stylesheet rule. scope="element" is a string-level lease on the host's inline view-transition-scope (runtime.ts:4030-4037, 4081-4082, eight hooks on the style setters, hydration special-casing at 852-886 and 17024-17045, three SSR attributes). The host already carries vt-scope="element"; one injected rule [vt-scope="element"]{view-transition-scope:all!important} through the existing injectStyle path would remove the lease, the hooks and the harness change, and an author's inline !important still wins, which is the opt-out vtScopeName (3945-3949) already honours.
  4. Invalid scope hosts are silent and degrade scheduling (runtime.ts:3967-3971, 4090, 4806-4810, 4825-4827). A two-host scope="element" gets no DEV warning (the duplicate-name path warns once at 6257), and because vtScopeForBlock returns null, vtQueuedOwners returns null for any batch containing it, so vtActiveHandles(null) treats every session as affected and the batch waits for unrelated animating scopes.

Smaller items

  • startViewTransition is always called with the options object and the sync throw is swallowed by a bare catch {} (runtime.ts:6894-6913); callback-only engines pay the whole staged drain on every transition flush and never animate, with nothing reported and no memoized "unsupported" flag. The docs declare the outcome, so the remaining defect is the silent swallow plus the repeated cost.
  • set() records the detached twin's read-back for non-projected keys (dom-stage.ts:506-518), so a staged scrollTop = 480 reads back as 0 for the rest of the drain, against the file header's own rule. I could not find a reachable double read in one drain today (jsdom cannot show it either, its scrollTop is a plain slot), so this is a hazard rather than a repro; exclude scroll geometry from values.
  • vtSsrClaimArm's local read and the vtSsrInject dedupe use naive indexOf(' name="') (runtime.server.ts:4903-4909, 4793) while the PR adds vtSsrAttribute for exactly this; an attribute value containing vt-exit="none" misroutes the arm.
  • Three different viewport tests with different edge semantics (runtime.ts:4426-4431 inclusive, 4662-4668 exclusive, driver 9148 exclusive) replaced the one vtInViewport helper.
  • The TRANSITION_JOURNAL !== null && !ROOT_RENDER_ROLLBACK && !TRANSITION_JOURNAL_REPLAYING predicate is copied six times (runtime.ts:7772, 7792, 7812, 13044, 13055, 13288); the stream driver re-implements the M marker check and the carrier unwrap that streamRuntimeJs already defines (runtime.server.ts:9022 vs 9240, 9033 vs 9215).
  • EAGER_METADATA (dom-stage.ts:8-18) is a bare list with no comment saying why these eight $$ expandos bypass staging, and nothing at the runtime.ts definition sites points here; the next expando is staged-until-commit by omission.
  • wrapResume passes precomputed owners/blocks from getBlocks(), so a passive that enqueues during a resumed flush has the same stale-snapshot shape as item 1.

Tests and docs

  • conformance/view-transition-{staging,lifecycle,matching}.test.ts (28 its) cite no React case; testing.md reserves conformance/ for ports with a per-it source citation, and "staging" names an Octane-only phase.
  • Nothing imports dom-stage.ts; the staging suite does not cover a rolled-back staged addEventListener on an existing node, a projected read after a non-projected write, classList/style proxies, innerHTML staging, or querySelector/closest/form mapping back to originals.
  • Twelve new components in view-transition-matching.tsrx and two in deferred-hydration-contract.tsrx take an untyped props (tsrx-authoring.md), while the PR's other fixtures are typed.

Already answered by you on the Bugbot threads (streamed vt-update ancestor walk, auto relays, img.onload) and not re-raised here.

Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.server.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.ts Resolved
Comment thread packages/octane/src/runtime.server.ts Resolved
Comment thread docs/view-transitions-plan.md Resolved
trueadm and others added 4 commits September 14, 2026 23:13
Review fixes for the ViewTransition parity and element-scope work, each
with a regression test that fails on the PR head:

- vtFlush snapshots the queued batch after pre-render passives run, so a
  scope whose update a passive schedules into the same commit is captured
  instead of changing inside another scope's transition.
- A render error thrown inside an animated commit is rethrown to the
  caller (uncaught, or collected by act()) instead of being demoted to
  onRecoverableError/console.error through the native rejection.
- Only vt-scope="element" is a scope on the client; the server's
  vt-scope="none" marker for an invalid declaration no longer removes
  hydrated hosts from the document capture.
- Secondary SSR hosts take the client's `-N` name suffix.

Also: DOMStage reads native siblings/children for parents without a
staged entry and native attributes for elements without a staged twin
(the previous fallbacks copied the child list or cloned the element per
read); the inline-style scope hooks check the driver before comparing the
property name; dead deferPassives/discard/_capture removed; the shared
stream-globals reset clears the scoped handle map.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@domgan-oai

Copy link
Copy Markdown
Contributor Author

Pushed the review fixes in a04266a, including your supplied commit (cherry-picked with authorship preserved). Each inline thread now has its disposition and regression evidence.

The delegation finding in the main review is also fixed: native listener attachment stays consistent with eager bookkeeping, newly created roots survive a rolled-back attempt, and existing portal listeners remain live until accepted deletion publishes. The staging suite exercises first-input suspension without the helper's predelegation, controlled restoration, an external root, and held portal deletion.

Validation includes 18,214 passing local core tests, 81 native browser cases, and focused final follow-ups (334 SSR/stream cases, 15 native stream cases, 18 error/resume cases, strict types). The updated PR description distinguishes the broad run from later focused runs and the local differential dependency limitation.

The refreshed performance record includes the measured remaining document-ready SSR cost (1.282→2.314 µs), the parser optimization, raw samples and noise, plus large-tree work counters. The plan preserves the earlier eager-rendering decision and why this request expanded it. Current-head CI and Bugbot are running; I’m following them through completion.

@trueadm trueadm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 759330f34 against the 20 threads from review 5203270246. I re-ran my saved repros and the local suites on this head, and re-read every follow-up hunk (e36dec2b4..759330f34: runtime.ts, dom-stage.ts, runtime.server.ts, scripts, docs, tests).

Verified fixed, all 20 threads. The two saved repros for the open findings now pass (same-body root.render before the native callback: 5/5; staged delegation rollback without helper predelegation: 4/4). Locally on this head: jsdom ViewTransition, hydration, lists, portals, Suspense, controlled, transitions, events and styles 3,439/3,440 (the one failure, deferred-hydration.test.ts "shares eager module state", passes 3/3 in isolation and is a load flake unrelated to this diff); Chromium parity/scopes/streaming/host-state/activity/suspense-hydration 101/101; format, typecheck and pnpm sync clean. Receipt refresh, eager delegation with staged unregister only for pre-existing targets, resume-path passive ordering, boxed drain errors, callback-overload fallback memoized per native function, invalid-scope diagnostic gated on inInactiveSubtree, physical-owner scheduling fallback, the $OCTRX retention/replay, owns() on vt-scope="element", linked child records with lazy snapshots and complete projection invalidation, scroll readback, querySelectorAll template discovery, the staged-DOM checker (runs via ci:workflow:test in the lint job), typed fixture props, moved suites, ledger paths, and the evidence hashes all check out. Thread-level details are on the six threads I replied to.

One change requested before merge (details on the runtime.server.ts:4945 thread): vtSsrStrip became a full tag walk of the whole document, head and every stream chunk whenever any boundary rendered, replacing the reviewed head's single regex replace. On a 25 KB page with one tiny boundary that is 27.3 → 148.6 µs per render (about 5 µs per KB, roughly 1 ms for a 200 KB page); the committed 113-byte View fixture cannot see it, which is why RESULTS.md reports 1.28 → 2.31. Octane-emitted markup never carries vt-*-x=" inside an attribute value, so the regex strip was already correct for everything but raw dangerouslySetInnerHTML text. Restore the regex strip or confine the walk to the boundary's own segment, and add a large-page fixture to ssr.mjs so the record measures it.

Two small fixes to fold in with it: docs/view-transitions.md:117-119 still describes the removed inline view-transition-scope lease and contradicts lines 170-172; and vtInjectScopeStyle injects only into the global document with a runtime-wide dedupe, so a root in a foreign document (iframe roots are supported) gets the vt-scope marker but never the stylesheet (runtime.ts:4079 thread).

Optional, noted on the threads: the checker's owner() keys exemptions on bare function names; the plan's "request was explicitly expanded" sentence should cite the instruction or say it was the task's own re-scoping; a one-line hardening for DOMStage.insert()'s eager branch (pre-existing, not a regression); two raw-HTML-only stripper edge cases (a="1"vt-exit-x="b" adjacency, case-sensitive </SCRIPT> search) and up to five attribute scans per tag in vtSsrClaimArm; the whole-batch downgrade for a passive-introduced urgent update is coarser than docs/view-transitions.md:111 states; the $OCTRX retention code ships on every stream (+136 gzip) and abort-tail entries persist for the page lifetime, both bounded.

The fix/vt-review-fixes-1095 branch is superseded by your cherry-pick and can be deleted once this merges.

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