Repository navigation
feat: Float style resources and Context.Consumer decision (executes #711 decisions) - #712
Merged
Merged
Conversation
…ncrete <style href precedence> at a component's body root is now a React Float style resource — plain CSS keyed by href, sharing the stylesheet dedupe namespace and precedence-group ordering with link resources, SSR-emitted and hydration-deduped, retained after unmount. Bare <style> keeps scoped CSS. Accessing Context.Consumer now logs a one-time dev migration diagnostic (still undefined, matching production); the nine upstream Consumer behavior scenarios are ported as useContext-reading conformance tests and 17 ledger cases are dispositioned. Executes the decisions section of #711 with the maintainer's style-resource reversal. Co-Authored-By: Claude Fable 5 <[email protected]>
23 of 27 tasks
trueadm
marked this pull request as ready for review
August 11, 2026 22:52
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
Executes the "Decisions locked in" section of #711, with one decision reversed by the maintainer:
<style href precedence>is now implemented as a React Float style resource rather than documented as a non-goal.<style href precedence>at a component's body root hoists todocument.headas plain CSS keyed by href — sharing the stylesheet dedupe namespace AND precedence-group ordering with link resources (data-precedence/data-hrefmarked), SSR-emitted into the grouped head fold, hydration-deduped via the client's DOM seed, retained after unmount. Every other<style>keeps scoped-CSS behavior (control test pins the hash-scoping path). Adaptations vs React, documented: one tag per resource (no same-precedence merging into a single tag), and CSS containing</stylefails closed in SSR with a dev diagnostic (raw-text serialization cannot escape it; the client'stextContentinsert is always safe and warns in dev for symmetry)..Consumerin development logs a one-time-per-context migration diagnostic and still returnsundefined(feature probes behave exactly as production; prod object shape untouched — the getter is dev-only), on bothoctaneandoctane/server. The nine upstream Consumer scenarios that protect observable behavior (defaults:343, multi-branch:381, propagation bailoutReactContextPropagation:299, sibling propagation:892, hidden subtree:706, no-bailouts-above:1135, suspended-boundary context updateReactSuspense.internal:1410, plus the two already evidenced incontext-bailout.test.ts) are ported asuseContext-reading conformance tests and flipped tocoveredwith evidence records; the two render-prop-surface-only cases ("warns when passed a consumer", "can read other contexts inside consumer render prop") arenon_goal.differences-from-react.mdupdated for both areas.Why
Issue #711's decision section, plus the maintainer's reversal on style resources ("if a style tag has href + precedence then it should be considered like React"). Landing the Consumer decision as ledger dispositions + a targeted diagnostic stops those 11 cases from being re-litigated as gaps.
Changes
packages/octane/src/compiler/compile.js—headResourceKindgains the'style'kind (JSXStyleElement with static href + precedence); the scoped-CSS claim sites skip resource styles (applyCssScopingcollect,annotateRootWithHashstrip);normalizeChildrenpartitions them to HeadHoist;requiresTemplateNormalizationadmits them for value-position bodies (gated onallowHeadHoists, like<title>/<script>— SVG has its own<style>); emitters route tostyleResource/ssrStyleResourcewith the StyleSheet re-rendered unscoped as the CSS argument.packages/octane/src/runtime.ts—styleResource+ factoredinsertPrecedenced(shared group ordering), seed scan extended tostyle[data-precedence]withdata-hrefidentity; dev-onlyConsumerwarning getter increateContext.packages/octane/src/runtime.server.ts—ssrStyleResourcewith the</stylefail-closed guard; the same devConsumergetter.packages/octane/src/{index,server/index}.ts— exports.packages/octane/audit/react-conformance-ledger.json+docs/react-parity-coverage.md— 17 dispositions, regenerated report.float-resources.test.ts(+fixtures),conformance/context-consumer-adapted.test.ts(+fixture) with per-case upstream citations, Consumer-diagnostic cases for client and server.docs/differences-from-react.md, changeset.Contract and hot paths
All additions are pay-per-use: the style-resource path costs one classifier check at compile time per
<style>element and nothing at runtime for components without resources; the Consumer getter is defined only in development (production context objects are byte-identical to before); scoped CSS behavior and output are untouched (control test + scoped/head/context neighbor sweeps, 1,096 tests green). No benchmarks were run and none are claimed — no hot path changed.Validation
pnpm format:checkpnpm typecheckpnpm test(full suite)node scripts/react-parity/check.mjs(full — executes the new evidence records) and--validate-onlyfloat-resources(24),context-consumer-adapted(18), context/head/scoped/activity/suspense neighbor sweep (1,096)'style'kind is disabled (6 failures, dev+prod projects); the Consumer-diagnostic tests fail without the getter by construction (zero warnings recorded). The seven adapted conformance ports are evidence tests pinning existing propagation behavior, not regression fixes.Risk / follow-ups
ReactDOMFloatplanned cases (late/streamed stylesheets, prop-conflict warnings, the truncated-title link triple) stay planned — see React 19 parity: outstanding gaps and follow-ups after #709 #711.Provenance
agent-authored)Note
Medium Risk
Touches compiler head-hoist classification and SSR/client Float resource insertion (including fail-closed
</stylehandling), plus the public context object shape in development. Scoped CSS and production context objects are intentionally unchanged.Overview
Implements
<style href precedence>as a React Float style resource and makes the no-Context.Consumerdecision concrete with a migration diagnostic and adapted conformance coverage.Style resources. A body-root
<style href precedence>now hoists unscoped CSS by href identity, sharing the stylesheet dedupe namespace and precedence-group ordering with link resources (data-precedence/data-href). Client and SSR emitters (styleResource/ssrStyleResource) retain resources after unmount and seed hydration fromdata-href. Bare<style>tags keep Octane's scoped-CSS path. Documented adaptations: one tag per resource (no same-precedence merge) and SSR fail-closed skip when CSS contains</style.Context.Consumer. Accessing
.Consumerin development warns once per context and still returnsundefined(client and server), so feature probes match production. Observable Consumer scenarios are ported asuseContext-reading conformance tests; render-prop-surface-only cases are ledgernon_goals.Reviewed by Cursor Bugbot for commit 03808da. Bugbot is set up for automated code reviews on this repo. Configure here.