Repository navigation
fix(hydration): adopt an unframed fragment component and continue after its last root - #1597
Merged
Merged
Conversation
… range A component call that finds no server range of its own, because the server rendered another @if/@switch arm there, adopts the server element at the cursor in place. Neither componentSlotImpl's singleRoot path nor componentSlotLite's no-range branch moved the cursor past that element, so the next component adopted the same element again and the server's range for it stayed on the page. When the first component's holes left the cursor inside the element, the next call claimed the enclosing block's range and discarded the arm. HydrationCapability.renderInPlace renders such a call while adopt() watches for its template adopting the node, then steps the cursor past it. The singleRoot path stamps the cursor as the block boundary only when the body adopted it (or threw), so a root rebuilt at a close marker no longer takes that marker as its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rwin-50350d Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rwin-50350d Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # packages/octane/src/runtime.ts
…ifier The repository forbids skip/todo modifiers in committed tests, so the development-compile-only case moves into its own describe instead of `it.runIf(dev)`. Only the development compile renders that hookless call through the lite slot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A component call that finds no server range of its own, because the server rendered another @if arm inline there, renders in place of the server node at the cursor (renderInPlace). A template with several roots now compares every root there (fragmentRemainder) and, when they match, adopts them and moves the cursor past the last one, so the next call adopts its own server range. - Development compile (lite slot): the next call no longer reads the fragment's first root, removes it, and renders itself twice. - Production compile (renderUnframed): the body now renders in place of an element or text node. A matching template is adopted and framed by the fresh markers. A template that does not match is rebuilt without discarding anything until the body has run, so a seeded rejection still leaves the server catch arm intact. The stale sweep no longer removes a later sibling's server range or leaves its close marker behind. - adopt() tests one `claiming` flag on its common path in place of the root-remainder check, so the in-place claims add no work to framed clones. Stacked on #1567 (renderInPlace). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…' into fix/unframed-fragment-root # Conflicts: # packages/octane/src/runtime.ts
…-root # Conflicts: # packages/octane/src/runtime.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
8 other measured values are unchanged. Public-import reachability bundles (bytes)
36 other measured values are unchanged. |
…-root # Conflicts: # packages/octane/src/runtime.ts
…on call renderBlock ships in every bundle, so the second call it made for the fresh-frame exemption pushed root-chained-jsx 2 bytes over its committed budget. HydrationCapability.rebuilds(end) now answers both questions at the one call site isFresh(end) used to fill. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 2, 2026 19:37
2 of 5 tasks
…-root # Conflicts: # packages/octane/src/runtime.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Hole can escape enclosing range
- Added an isBlockClose guard in fragmentRemainder so that when a comment hole's server content is missing and actual sits on the enclosing range's close marker, sibling() is not called and the remainder stays on the close instead of escaping past it.
Or push these changes by commenting:
@cursor push 03dd48ca02
Preview (03dd48ca02)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -20165,7 +20165,9 @@
) {
return undefined;
}
- actual = this.sibling(actual, 1);
+ // A block close is the enclosing range's boundary. A comment hole whose
+ // server content is missing lands here; do not walk past it.
+ if (!isBlockClose(actual)) actual = this.sibling(actual, 1);
expected = getNextSibling(expected);
childIndex++;
}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit b79077b. Configure here.
…ing range A fragment template adopted in place of a server node compared its roots against the server nodes after that node. A hole skips the shape check, so when the server's range ended where a hole was expected, the walk stepped past the range's close: the fragment matched, its end landed outside the @if arm, and production moved the fresh end marker out of the arm. The in-place walk now fails at the enclosing range's close. A fragment that does not match where it stands is rebuilt in both compiles: the lite path rebuilds it at once (rebuildFragment) instead of adopting its first root, whose holes then claimed the wrong server nodes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-root # Conflicts: # packages/octane/src/runtime.ts
This was referenced Oct 2, 2026
This was referenced Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
When hydration finds a component call's server content without the call's own range (the server rendered a different
@ifarm with the same markup inline), a component whose template has several roots now adopts those server nodes and hydration continues after its last root. The next call adopts its own server range. This extends #1567'srenderInPlace, which already handles single-root templates, to fragment templates, in both the development and the production compile.Repro (server renders the first arm, client the second):
Before:
<s>but left the cursor there. A then read<s>as its own root, reported a mismatch and rebuilt itself.componentSlotImpl's missing-range path,renderUnframed): F was always rebuilt and reported as a mismatch, even though the server nodes matched. Before fix(hydration): keep a later sibling's server range when a component without one is built #1589, the rebuild also swept A's server range.After, in both compiles, F keeps
<s>and<i>, A keeps its server<b>, and nothing is reported.Changes
All in
packages/octane/src/runtime.ts:adopt(): a fragment template cloned at the node a call renders in place of (inPlace) now compares every root (fragmentRemainder) and records where its server nodes end (inPlaceEnd). A single-root template records the node after its root.renderInPlacemoves the cursor there instead of past the first root.renderUnframed: when an anchored call's fresh markers stand before a server element or text, which is whereunframedBeforeputs them, the body renders in place of that node throughrenderInPlace(..., unframed = true), with hydration active.adopt(). The existing report and discard then run after the body, so a seeded rejection still leaves the server's catch arm intact.anchor === null, the fix(hydration): rebuild component calls in an adopted element with other server content #1563 path) and root-level calls whose root remainder is still unclaimed are unchanged.fragmentRemainder(..., bounded)), because a hole's server form is never a close marker. An in-place fragment that does not match is rebuilt in both compiles: the lite path goes throughrebuildFragment, the production path throughrenderUnframed.renderLiteInPlacenow records the cursor thatrenderInPlaceleft (parkInPlace), past a fragment's last root. The existingparkPast(root)stepped only past its first root.renderBlock: its "fresh end marker means client-built" suspend now exempts that one frame (framesInPlace). This check runs only afterisFreshis already true.adopt()prologue: onependingClaimsflag replaces therootRemainder === undefinedtest. The in-place checks sit behind that flag, so a framed clone does no more work than on main. fix(hydration): continue after a component adopted in place without a range #1567's single-rootcursor === this.inPlacecompare is now behind the flag too.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkpasses on every changed file.pnpm typecheck: not run repo-wide.pnpm typecheck:filespasses onruntime.ts, the test, and the.tsrxfixture.pnpm test: not run in full; local runs are being kept small because of machine load.packages/octane/tests/hydration/unframed-fragment-root.test.ts(dev and prod compile), covering a fragment of static roots and a fragment whose last root is a component. Each case asserts final markup, that every server node is the same node after hydration, no recoverable errors, and no dev warnings. A third case unmounts the adopted fragment by flipping the arm and back.octaneandoctane-prodprojects. The dev component-last case already passed, because the nested call moves the cursor itself.tests/hydration/passed inoctaneandoctane-prod(246 files, 12,090 tests).mainthrough fix(hydration): adopt a component hole's own server node in a template adopted in place #1602, in theoctaneproject only: this file (8/8, including the trailing-hole case from Bugbot's review),in-place-fragment-hole,unframed-component-range,in-place-mismatch-fullandin-place-component-sibling, all passing. CI covers the rest.Bundle size: the signal-free budget gate passes (
node benchmarks/bundle-size/run-minimal.mjs --budgets root-static-local root-chained-jsx hooks-state prop-attributes context;root-chained-jsxis 86,002 raw against its 86,016 budget).renderBlockships in every bundle, so itsisFresh(end)call became onerebuilds(end)call, which costs 1 byte there. The rest is inHydrationCapability, which only bundles that hydrate include. Hydration timing benchmarks were not measured: the machine's load average was around 50, so timings were not trustworthy.Risk / follow-ups
renderUnframedandadopt().Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core hydration adoption, cursor advancement, and production unframed rendering; behavior changes from rebuild+mismatch to silent adoption when multi-root templates match server inline markup.
Overview
Fixes hydration when a component has no server range (e.g. another
@ifarm inlined the same DOM) but the client renders it as a multi-root fragment.renderInPlace/adopt()now walk every fragment root against server siblings, record where adoption ends (inPlaceEnd), and advance the cursor after the last root instead of after the first—so the following component keeps its own range. ApendingClaimsgate keeps the common clone path cheap.renderUnframed(production missing-range path) can run the body in place when fresh markers sit directly before matching server element/text: successful adoption reframes those nodes; non-matching templates rebuild without an early discard so rejections still see the server catch arm.renderBlockuses newrebuilds()so that in-place frame is not treated as a client-only rebuild.Lite slots call
parkInPlaceafter in-place adoption so arm tail tracking matches the updated cursor.Adds hydration tests (dev + prod compile) and an
octanepatch changeset.Reviewed by Cursor Bugbot for commit f0ba900. Bugbot is set up for automated code reviews on this repo. Configure here.