Repository navigation
fix(web): nested slot fills see the enclosing fill's context - #4131
Conversation
A fill nested in a region (server content an enclosing fill places) now renders and mounts under the owner that placed the region, on the server and the client, so it reads the context the enclosing fill provides. Server: a fill called while an enclosing occurrence's args evaluate parks as a token the region expands at placement; the usage flip runs at the range's tail, after provider children resolved. Client: nested fills mount under the region's reader owner, wait while unplaced, remount at the next placement; both claim windows of a fill share one claim owner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012xU4iGQqRKP12d5Nkr4BA2
…-58026x-nested-ctx
Placement bookkeeping (which owner placed a region, the nested fills waiting on it) lives in the lazy regions tier: no region exists without it, so the eager client keeps only the read hook and the call. Size ledger for the four scenarios over their caps (+3..+12 B minified). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012xU4iGQqRKP12d5Nkr4BA2
🦋 Changeset detectedLatest commit: d76dc62 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size (brotli, eager entry chunk)
Bundled with Rolldown (what Vite ships), brotli q11, decimal KB. A scenario fails only when it is over its brotli cap and its minified size is more than 20 B over the minified recorded with the cap; over the cap within that allowance is brotli layout noise and passes with a warning. Caps and their recorded minified in |
Coverage Report for CI Build 39020014523Coverage remained the same at 77.564%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Merging this PR will degrade performance by 3.87%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | memo + sync render effect only (reference) |
27.6 ms | 32.4 ms | -14.89% |
| ⚡ | createStore setter: delete + set one root key (#3044 overlay) |
1.9 ms | 1.8 ms | +8.57% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing claude/project-thread-58026x-nested-ctx (d76dc62) with next (7010268)2
Footnotes
-
5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
next(db4b281) during the generation of this report, so 7010268 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
|
CodSpeed's one regression, Generated by Claude Code |
Summary
Before: a client fill nested in server content that another fill places (a region) did not see the context that enclosing fill provides. The server rendered the nested fill while the enclosing occurrence's args were still being evaluated, before the enclosing fill existed, and under the server component's zone owner. The client mounted it under the boundary owner. Both sides read the default. Also, when a fill wrapped its region in a provider (
<Ctx value={x}>{props.children}</Ctx>), the server counted the region as occluded because the provider's children only resolve during the walk. It shipped the region as a data record and left the section empty. On the client, a fill whose root is a provider rendered a detached copy instead of claiming the server markup.After: nested fills see the enclosing fill's context everywhere. That covers the server render, eager hydration, deferred hydration (including an inner occurrence that mounts before its enclosing one through
mountEnclosing), occluded regions that are placed later, and occurrences a stream or live hole adds to a region.A fill in a region is the enclosing fill's child, the same as in a plain client tree: it renders and mounts where the region is placed, under the owner that placed it.
How.
frame-sink.ts): when a fill is called during an enclosing occurrence's arg evaluation, it parks. It mints its occurrence id at the call but leaves a token in the region's markup. The region thunk swaps each token for the fill's range, rendered under the placing owner in a freshsc-hydration scope. For an occluded region, the swap happens when its record is serialized. The usage flip (lock and serialize regions that were not used) now runs as the range's tail, after the fill's output has resolved, so regions placed inside a provider ship as markup.regions-tier.ts, lazy): a read of a region element through the slot props places it under the reader's owner. A fill nested in that region mounts under the placing owner. If the region is unplaced (occluded, or its placement was disposed), the fill waits. The next placement mounts it fresh. The eager client only calls into the tier.client.ts): both claim windows of one fill share one claim owner, created under the binding owner. Content the first window evaluated lazily, such as a provider's children, now claims when the second window reads it.How did you test this change?
New tests. Each one fails without the fix:
test/server/frame-nested-fill-context.spec.tsx(server config) renders a page with a badge inside a panel that providesTheme, a badge outside it, an open drawer and a closed drawer. It checks the markup readsdark/default/drawer, that the panel's region ships as markup, and that the closed drawer's region ships as a record. It writes the committed artifact.test/hydration/frame-nested-fill-context.spec.tsx(hydrate config) checks that every badge adopts the server's nodes without warnings and thatseenrecords the context each badge read. It then closes the drawer (disposes its badge), opens it again (fresh remount under the drawer's context), and opens the occluded drawer (its badge mounts on first placement).test/hydration/frame-nested-fill-context-deferred.spec.tsxturns on deferred hydration. A click inside the inner occurrence mounts the panel, then the badge, and the badge readsdarkand sees the click.test/consistency/nested-fill-context.spec.tsx(stream face) covers a region with a live hole: the badge reads the panel's provider, and so does a badge that a hole patch adds later.Suites (
packages/web):vite.config.mjs: 152 files, 1375 passed.vite.config.hydrate.mjs: 114 passed and 1 skipped; 509 passed, 16 expected fail, 2 skipped.vite.config.server.mjs: 190 passed and 1 failed; 1712 passed, 3 expected fail, 2 skipped. The one failure is the known Node 22 container failure "keeps a rebuild failure's own error", which is unrelated.tscontsconfig.build.jsonandtsconfig.test.jsonis clean.Size (
scripts/size, local linux, brotli / minified vs next):The minified growth is +1 to +12 B, but brotli moves −67 to +118 B with layout noise. Four caps were set to measured + 10 B, rounded up to 0.01 KB, with dated ledger entries: frames 12.25 KB, compiled base 35.42 KB, and the two frozen floors in
floor-caps.json, base page 33.46 KB and live page 37.58 KB.Server hot paths: the parking and flip only run on document slot calls; paths without slots allocate nothing new.
Size-Exception: nested slot fills see the enclosing fill's context (+12 / +6 B minified on the two page floors; the brotli growth is layout noise). Accepted by @ryansolid, 2026-10-17.
CodSpeed: the one regression (
mount 4000 rows: memo + sync render effect only) is a signals-only bench this PR doesn't touch; known noise on unrelated PRs.🤖 Generated with Claude Code
https://claude.ai/code/session_012xU4iGQqRKP12d5Nkr4BA2