Skip to content

fix(hydration): continue after a component adopted in place without a range - #1567

Merged
trueadm merged 4 commits into
mainfrom
claude/intelligent-darwin-50350d
Oct 2, 2026
Merged

trueadm merged 4 commits into
mainfrom
claude/intelligent-darwin-50350d

Conversation

@trueadm

@trueadm trueadm commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

During hydration, a component call that finds no server range of its own adopts the server element at the cursor in place. This happens when the server rendered a different @if/@switch arm there, or when a component returns a single-root component. The production compile reaches it through componentSlotImpl's singleRoot path, and the development compile through componentSlotLite's no-range branch. Neither moved the hydration cursor past the adopted element:

  • <><Leaf v="x" /><Leaf v="z" /></> hydrated over the server arm <em>x</em><!--[--><em>z</em><!--]--> left <em>z</em><!--[--><em>z</em><!--]-->. Both Leaf blocks shared the first <em>, and the server's range for the second stayed on the page. Later updates to the second Leaf wrote into the first element.
  • When the first component's own holes left the cursor inside its element (an @if inside <em>), the null cursor sent the next call to host.firstChild, which is the enclosing @if's open marker. The next call claimed that range, and the whole arm disappeared.
  • A returned single-root component that hydration rebuilt at its parent component's server close marker stamped that marker as its own boundary. Hiding it later left the element on the page and removed the close marker. Showing it again threw NotFoundError.

Changes, all in packages/octane/src/runtime.ts:

  • HydrationCapability.renderInPlace(render, target, root) renders such a call while adopt() watches whether a template adopts root. The watch is a private inPlace field. It is saved and restored for nested calls and cleared on adopt()'s in-place return. When the body adopted root, the cursor steps past it, wherever the body's holes left it. A body that rebuilt root or rendered nothing there leaves the cursor where it put it. "Root still attached after the body" would not work as the signal: an empty lite body leaves the root attached without adopting it.
  • componentSlotImpl's singleRoot path renders through renderInPlace while hydrating. It stamps the cursor as the block boundary only when the body adopted it or threw, which keeps the existing behavior for a render that suspends. Otherwise the client-mount probe finds the root the body inserted.
  • componentSlotLite's no-range branch re-enters through a cold renderLiteInPlace helper. This keeps the helper's closure out of ordinary lite dispatch, as suspendFreshLiteComponent does.

Validation

  • pnpm format:files:check on the changed files; the repo-wide pnpm format:check was not run.
  • pnpm typecheck:files on runtime.ts and the new test and fixture; the repo-wide pnpm typecheck was not run.
  • pnpm test: not run. I stopped a full local octane run because the base had moved, and I'm rerunning octane and octane-prod on this head. CI covers the other projects.
  • targeted tests:
    • New tests/hydration/in-place-component-sibling.test.ts, covering the development and production compiles:

      • an @if arm and a @switch arm;
      • a first root whose @if leaves the cursor inside it;
      • a server arm with other content after the adopted element;
      • an empty lite component before the adopting one. This case is development-compile only, because the production compile gives that component a full slot;
      • a returned single root rebuilt at a component's close marker.

      The tests assert final markup, adopted-node identity, updates after hydration, and recoverable errors and dev diagnostics. All 11 fail on main. Three partial fixes each fail at least one case: stepping only while the cursor sits on the root, treating "root still attached" as adoption, and keeping the old stamp condition.

    • octane and octane-prod projects, tests/hydration/** plus non-jsx-return.test.ts on the merged head: 246 files, 12,158 tests passed.

  • Bundle size (node benchmarks/bundle-size/run-minimal.mjs, before and after; budgets pass):
    • hydrate-root: +200 raw / +62 gzip
    • deferred-hydration: +250 raw / +117 gzip
    • root-static, context, suspense-transition, and the binding bundles that include the component slots: about +50 raw / +30–50 gzip
    • all other scenarios: unchanged

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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
Touches core hydration and component-slot paths in runtime.ts; behavior changes affect DOM adoption, cursor advancement, and block boundary stamping on first hydrate.

Overview
Fixes hydration cursor desync when a component call has no server range of its own and adopts the element at the cursor in place (typical when client and server disagree on an @if/@switch arm, or for returned single-root components).

Adds HydrationCapability.renderInPlace, which tracks whether the body actually adopted the server node; when it did, the cursor steps past that element so the next sibling claims its own range instead of reusing the same DOM or swallowing the parent block. componentSlotLite routes anchored no-range first renders through renderLiteInPlace; componentSlotImpl’s hydrating single-root path uses the same helper and only stamps the adopted cursor as block boundaries when adoption (or a throw) happened—so toggling a rebuilt single-root child off/on no longer leaves stray nodes or NotFoundError.

New hydration tests (dev + prod compiles) cover @if/@switch arms, nested holes inside the adopted root, mismatched following siblings, empty lite components, and conditional returned roots.

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

trueadm and others added 2 commits October 2, 2026 15:12
… 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]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 2, 2026
@github-actions
github-actions Bot marked this pull request as draft October 2, 2026 14:14
@trueadm
trueadm marked this pull request as ready for review October 2, 2026 14:16

@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 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Null cursor re-adopts first child
    • Added inPlaceExhausted tracking on HydrationCapability so that when renderInPlace advances the cursor to null (last child adopted), the getFirstChild fallback in componentSlotLite and componentSlotImpl is suppressed for that exhausted host, preventing re-adoption of the first child.

Create PR

Or push these changes by commenting:

@cursor push 889cabcb2a
Preview (889cabcb2a)
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
@@ -11689,7 +11689,11 @@
 			// just-cloned (empty) host, so descend to host.firstChild; later siblings
 			// (and the sole-hole case) already have the cursor on the open marker.
 			let open: Node | null = hydration.node;
-			if (open === null || (STAGED_DOM?.view(open) ?? open).parentNode !== host)
+			if (
+				open === null
+					? !hydration.isInPlaceExhausted(host)
+					: (STAGED_DOM?.view(open) ?? open).parentNode !== host
+			)
 				open = getFirstChild(host);
 			if (open !== null && hydration.isOpen(open)) {
 				adoptedOpen = open;
@@ -18770,6 +18774,8 @@
 	private readonly unframedRootRanges = new WeakMap<Node, Node>();
 	/** The server node renderInPlace's body may adopt, until a template does. */
 	private inPlace: Node | null = null;
+	/** Parent whose children renderInPlace exhausted (cursor stepped to null). */
+	private inPlaceExhausted: Node | null = null;
 	/** Pairs discovered while matching an outer range; released with this hydration pass. */
 	private matchingCloses: WeakMap<Node, Comment> | null = null;
 	/** First unclaimed root sibling after a compiled root clone; undefined until known. */
@@ -19004,6 +19010,11 @@
 		}
 	}
 
+	/** Whether renderInPlace's last adoption exhausted the children of `host`. */
+	isInPlaceExhausted(host: Node): boolean {
+		return this.inPlaceExhausted === host;
+	}
+
 	/**
 	 * First render, by `render(target)`, of a component call that found `root`
 	 * at the cursor instead of a server range of its own. Its template adopts
@@ -19024,6 +19035,10 @@
 			this.inPlace = outer;
 		}
 		if (adopted) this.node = getNextSibling(root);
+		this.inPlaceExhausted =
+			adopted && this.node === null
+				? ((STAGED_DOM?.view(root) ?? root).parentNode as Node | null)
+				: null;
 		return adopted;
 	}
 
@@ -31436,7 +31451,11 @@
 			// In both cases mountTry/renderBlock parked the cursor on the server range's
 			// `<!--[-->`; adopt from it, the same way childSlot's cursor branch does.
 			let c: Node | null = hydration.node;
-			if (c === null || (STAGED_DOM?.view(c) ?? c).parentNode !== domParent)
+			if (
+				c === null
+					? !hydration.isInPlaceExhausted(domParent)
+					: (STAGED_DOM?.view(c) ?? c).parentNode !== domParent
+			)
 				c = getFirstChild(domParent);
 			hydrationCursor = c;
 			if (c !== null && hydration.isOpen(c)) open = c;

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit a4a8f37. Configure here.

Comment thread packages/octane/src/runtime.ts Resolved
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 27 value(s) increased
  • 🔴 bundle-reachability: 32 value(s) increased

Compares a50b8460d with 980463d39 on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample also moving beyond that margin. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

All 20 timed operations (20 within noise)
target operation base head Δ noise
octane-tsrx run 4.64 5.44 +17.2% ±48% ⚪ within noise
octane-tsrx replace 10.85 11.54 +6.4% ±34% ⚪ within noise
octane-tsrx add 4.62 4.50 −2.6% ±37% ⚪ within noise
octane-tsrx update 0.64 0.62 −3.1% ±57% ⚪ within noise
octane-tsrx select 0.23 0.23 −0.0% ±54% ⚪ within noise
octane-tsrx swap 0.58 0.41 −29.3% ±61% ⚪ within noise
octane-tsrx remove 0.54 0.47 −13.0% ±51% ⚪ within noise
octane-tsrx runlots 38.31 36.85 −3.8% ±30% ⚪ within noise
octane-tsrx select_lots 0.32 0.30 −6.3% ±44% ⚪ within noise
octane-tsrx clear 49.57 52.30 +5.5% ±38% ⚪ within noise
octane-jsx run 4.49 4.39 −2.2% ±21% ⚪ within noise
octane-jsx replace 10.74 9.61 −10.5% ±29% ⚪ within noise
octane-jsx add 4.25 3.77 −11.3% ±20% ⚪ within noise
octane-jsx update 0.74 0.76 +2.7% ±36% ⚪ within noise
octane-jsx select 0.54 0.57 +5.6% ±59% ⚪ within noise
octane-jsx swap 0.85 1.04 +22.4% ±61% ⚪ within noise
octane-jsx remove 0.94 0.71 −24.5% ±50% ⚪ within noise
octane-jsx runlots 36.31 33.39 −8.0% ±13% ⚪ within noise
octane-jsx select_lots 2.83 2.62 −7.4% ±27% ⚪ within noise
octane-jsx clear 51.36 46.29 −9.9% ±15% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-tsrx todo_js_raw 141,134 141,193 +59 (+0.0%) 🔴
octane-tsrx todo_js_gzip 46,602 46,626 +24 (+0.1%) 🔴
octane-tsrx todo_js_brotli 40,811 40,833 +22 (+0.1%) 🔴
octane-tsrx todo_app_brotli 2,117 2,123 +6 (+0.3%) 🔴
octane-tsrx todo_fw_raw 136,024 136,083 +59 (+0.0%) 🔴
octane-tsrx todo_fw_gzip 44,126 44,150 +24 (+0.1%) 🔴
octane-tsrx todo_fw_brotli 38,694 38,710 +16 (+0.0%) 🔴
octane-tsrx chat_js_raw 140,379 140,438 +59 (+0.0%) 🔴
octane-tsrx chat_js_gzip 46,545 46,569 +24 (+0.1%) 🔴
octane-tsrx chat_js_brotli 40,865 40,899 +34 (+0.1%) 🔴
octane-tsrx chat_app_gzip 2,978 2,981 +3 (+0.1%) 🔴
octane-tsrx chat_app_brotli 2,641 2,640 −1 (−0.0%) 🟢
octane-tsrx chat_fw_raw 133,726 133,785 +59 (+0.0%) 🔴
octane-tsrx chat_fw_gzip 43,567 43,588 +21 (+0.0%) 🔴
octane-tsrx chat_fw_brotli 38,224 38,259 +35 (+0.1%) 🔴
octane-tsrx weather_js_raw 176,674 176,782 +108 (+0.1%) 🔴
octane-tsrx weather_js_gzip 57,732 57,804 +72 (+0.1%) 🔴
octane-tsrx weather_js_brotli 50,126 50,223 +97 (+0.2%) 🔴
octane-tsrx weather_app_brotli 7,563 7,594 +31 (+0.4%) 🔴
octane-tsrx weather_fw_raw 149,939 150,047 +108 (+0.1%) 🔴
octane-tsrx weather_fw_gzip 48,689 48,761 +72 (+0.1%) 🔴
octane-tsrx weather_fw_brotli 42,563 42,629 +66 (+0.2%) 🔴
octane-jsx js_raw 225,289 225,339 +50 (+0.0%) 🔴
octane-jsx js_gzip 71,838 71,876 +38 (+0.1%) 🔴
octane-jsx js_brotli 62,192 62,317 +125 (+0.2%) 🔴
octane-jsx app_gzip 2,943 2,942 −1 (−0.0%) 🟢
octane-jsx fw_raw 216,822 216,872 +50 (+0.0%) 🔴
octane-jsx fw_gzip 68,895 68,934 +39 (+0.1%) 🔴
octane-jsx fw_brotli 59,690 59,815 +125 (+0.2%) 🔴

16 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
root-static raw 201,612 201,662 +50 (+0.0%) 🔴
root-static gzip 63,985 64,019 +34 (+0.1%) 🔴
root-static brotli 55,478 55,571 +93 (+0.2%) 🔴
context raw 109,986 110,036 +50 (+0.0%) 🔴
context gzip 36,379 36,420 +41 (+0.1%) 🔴
context brotli 32,167 32,190 +23 (+0.1%) 🔴
hydrate-root raw 161,241 161,738 +497 (+0.3%) 🔴
hydrate-root gzip 51,671 51,798 +127 (+0.2%) 🔴
hydrate-root brotli 44,991 45,096 +105 (+0.2%) 🔴
deferred-hydration raw 223,669 224,217 +548 (+0.2%) 🔴
deferred-hydration gzip 71,157 71,329 +172 (+0.2%) 🔴
deferred-hydration brotli 61,419 61,599 +180 (+0.3%) 🔴
suspense-transition raw 166,494 166,543 +49 (+0.0%) 🔴
suspense-transition gzip 53,485 53,522 +37 (+0.1%) 🔴
suspense-transition brotli 46,736 46,740 +4 (+0.0%) 🔴
binding-base-ui-vite raw 211,806 211,856 +50 (+0.0%) 🔴
binding-base-ui-vite gzip 67,565 67,603 +38 (+0.1%) 🔴
binding-base-ui-vite brotli 58,565 58,608 +43 (+0.1%) 🔴
binding-base-ui-esbuild raw 209,779 209,830 +51 (+0.0%) 🔴
binding-base-ui-esbuild gzip 67,566 67,591 +25 (+0.0%) 🔴
binding-base-ui-esbuild brotli 58,648 58,624 −24 (−0.0%) 🟢
binding-aria-esbuild gzip 3,363 3,361 −2 (−0.1%) 🟢
binding-aria-esbuild brotli 3,013 3,012 −1 (−0.0%) 🟢
binding-radix-vite raw 213,735 213,785 +50 (+0.0%) 🔴
binding-radix-vite gzip 68,121 68,159 +38 (+0.1%) 🔴
binding-radix-vite brotli 59,135 59,108 −27 (−0.0%) 🟢
binding-radix-esbuild raw 211,667 211,718 +51 (+0.0%) 🔴
binding-radix-esbuild gzip 68,122 68,151 +29 (+0.0%) 🔴
binding-radix-esbuild brotli 59,172 59,208 +36 (+0.1%) 🔴
binding-apollo-client-vite raw 356,858 356,908 +50 (+0.0%) 🔴
binding-apollo-client-vite gzip 111,703 111,738 +35 (+0.0%) 🔴
binding-apollo-client-vite brotli 97,582 97,558 −24 (−0.0%) 🟢
binding-apollo-client-esbuild raw 359,836 359,886 +50 (+0.0%) 🔴
binding-apollo-client-esbuild gzip 113,935 113,984 +49 (+0.0%) 🔴
binding-apollo-client-esbuild brotli 99,262 99,269 +7 (+0.0%) 🔴
binding-usehooks-ts-esbuild gzip 32,911 32,912 +1 (+0.0%) 🔴
binding-usehooks-ts-esbuild brotli 29,258 29,268 +10 (+0.0%) 🔴

68 other measured values are unchanged.

CI job durations

  • 🟡 9 job(s) slower than every recent main run: test shard (Node 24, 4/4), test shard (Node 24, 3/4), React parity shard (2/4), website integration suite, React parity shard (3/4), example apps (2/3), example apps (3/3), Three compatibility, example apps (1/3)

Compares the CI run for cff9e1cbc (run) with the last 5 successful main push runs. A job is only slower or faster outside the whole main range, by at least 10% and 15s. Job time excludes runner setup.

job main median main range this PR Δ
wall clock (first job start to last job end) 13m 00s 11m 55s–14m 59s 13m 49s +49s (+6%) ⚪ within noise
total job time 140m 58s 134m 18s–157m 45s 155m 47s +14m 49s (+11%) ⚪ within noise
test shard (Node 24, 4/4) 10m 26s 10m 21s–11m 11s 12m 56s +2m 30s (+24%) 🟡 slower
test shard (Node 24, 3/4) 9m 33s 9m 29s–10m 46s 11m 58s +2m 25s (+25%) 🟡 slower
React parity shard (2/4) 10m 08s 10m 04s–11m 23s 11m 36s +1m 28s (+14%) 🟡 slower
website integration suite 6m 06s 5m 43s–6m 49s 7m 21s +1m 15s (+20%) 🟡 slower
React parity shard (3/4) 10m 25s 10m 07s–11m 31s 11m 38s +1m 13s (+12%) 🟡 slower
example apps (2/3) 3m 44s 3m 42s–3m 55s 4m 53s +1m 09s (+31%) 🟡 slower
example apps (3/3) 3m 30s 3m 22s–3m 49s 4m 08s +38s (+18%) 🟡 slower
Three compatibility 2m 43s 2m 42s–3m 16s 3m 17s +34s (+21%) 🟡 slower
example apps (1/3) 3m 13s 3m 04s–3m 31s 3m 37s +24s (+12%) 🟡 slower
All 26 timed jobs
job main median main range this PR Δ
test shard (Node 24, 4/4) 10m 26s 10m 21s–11m 11s 12m 56s +2m 30s (+24%) 🟡 slower
test shard (Node 24, 3/4) 9m 33s 9m 29s–10m 46s 11m 58s +2m 25s (+25%) 🟡 slower
React parity shard (4/4) 10m 53s 10m 08s–13m 14s 12m 49s +1m 56s (+18%) ⚪ within noise
React parity shard (2/4) 10m 08s 10m 04s–11m 23s 11m 36s +1m 28s (+14%) 🟡 slower
heavy integration (browser - chromium) 11m 40s 11m 03s–14m 20s 13m 01s +1m 21s (+12%) ⚪ within noise
website integration suite 6m 06s 5m 43s–6m 49s 7m 21s +1m 15s (+20%) 🟡 slower
React parity shard (3/4) 10m 25s 10m 07s–11m 31s 11m 38s +1m 13s (+12%) 🟡 slower
example apps (2/3) 3m 44s 3m 42s–3m 55s 4m 53s +1m 09s (+31%) 🟡 slower
test shard (Node 24, 1/4) 11m 40s 11m 19s–12m 22s 12m 25s +45s (+6%) ⚪ within noise
example apps (3/3) 3m 30s 3m 22s–3m 49s 4m 08s +38s (+18%) 🟡 slower
Three compatibility 2m 43s 2m 42s–3m 16s 3m 17s +34s (+21%) 🟡 slower
example apps (1/3) 3m 13s 3m 04s–3m 31s 3m 37s +24s (+12%) 🟡 slower
test shard (Node 24, 2/4) 11m 55s 10m 38s–13m 38s 12m 18s +23s (+3%) ⚪ within noise
React parity shard (1/4) 11m 18s 10m 23s–11m 27s 11m 36s +18s (+3%) ⚪ within noise
Lynx compatibility 1m 32s 1m 29s–1m 36s 1m 44s +12s (+13%) ⚪ within noise
classify changeset release 13s 12s–15s 17s +4s (+31%) ⚪ within noise
heavy integration (package builds, eval corpus, runtime loaders, Astro) 5m 23s 5m 21s–5m 53s 5m 25s +2s (+1%) ⚪ within noise
CI provenance 3s 3s–4s 4s +1s (+33%) ⚪ within noise
typecheck 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
examples 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
React parity checks 12s 10s–14s 12s ±0s (±0%) ⚪ within noise
test (24) 3s 2s–5s 3s ±0s (±0%) ⚪ within noise
lint 4s 3s–4s 3s −1s (−25%) ⚪ within noise
typecheck checks 2m 13s 1m 56s–2m 40s 2m 08s −5s (−4%) ⚪ within noise
validate publishable packages 3m 58s 3m 51s–4m 54s 3m 52s −6s (−3%) ⚪ within noise
lint checks 8m 51s 7m 43s–12m 03s 8m 20s −31s (−6%) ⚪ within noise

trueadm and others added 2 commits October 2, 2026 15:52
…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]>
@trueadm
trueadm merged commit 416882f into main Oct 2, 2026
31 checks passed
@trueadm
trueadm deleted the claude/intelligent-darwin-50350d branch October 2, 2026 15:36
trueadm added a commit that referenced this pull request Oct 2, 2026
…ition

#1567's renderInPlace steps the cursor past a node that an unframed
component adopted in place, in both the lite and the singleRoot paths. It
supersedes this branch's stepPastRoot and its lite-path rebuiltTail clear:
an adopted node no longer leaves the cursor on the rebuilt tail, so the
sweep cannot take it. The singleRoot boundary stamps the cursor only when
the body adopted it or threw (#1567), no root was rebuilt in its place, and
it is not a closing marker. The fallback still finds a root rebuilt in the
cursor's place before probing the anchor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 2, 2026
Resolve runtime.ts conflicts with #1567: keep both the in-place adoption
(renderInPlace, the inPlace check in adopt()) and the component-range
claims (beginClaim/endClaim/renderClaimed/settleClaim, the claimRoots
check in adopt()).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm pushed a commit that referenced this pull request Oct 2, 2026
Resolve runtime.ts against #1561, #1567 and #1576: keep main's adopted-range
claims (renderClaimed) and in-place lite rendering (renderInPlace) beside the
unframed-claim changes.

#1567 renders a lite call that found no range against the cursor, so a
hookless component that renders nothing leaves the server element to the next
call. Drop this branch's routing of such calls through the missing-range
path, which contradicted that. Fix the over-sweep where it happens instead:
when such a call rebuilds its fragment, placeRebuilt now discards only the
server content in its place, up to the next marker, and drainFrag inserts the
fragment there, ahead of later siblings' ranges. The development diagnostic
names the call site. renderUnframed shares the same bounded sweep
(discardInPlace).

The fixture's FragChild gets a hook so it is a full component call in both
compiles, which is the path that case covers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LqA51dmsggKyu7uH3zc9N2
trueadm added a commit that referenced this pull request Oct 2, 2026
…er its last root (#1597)

* fix(hydration): continue after a component adopted in place without a 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]>

* test(hydration): run the lite empty-component case without a test modifier

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]>

* fix(hydration): continue after an unframed fragment component root

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]>

* docs(changeset): describe the unframed fragment fix against current main

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(octane): keep renderBlock's in-place exemption inside one hydration 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]>

* fix(hydration): end an in-place fragment's server nodes at the enclosing 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]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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 fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant