Skip to content

feat: Float style resources and Context.Consumer decision (executes #711 decisions) - #712

Merged
trueadm merged 1 commit into
mainfrom
feat/react19-decisions-tranche
Aug 11, 2026
Merged

trueadm merged 1 commit into
mainfrom
feat/react19-decisions-tranche

Conversation

@trueadm

@trueadm trueadm commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

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 resources: <style href precedence> at a component's body root hoists to document.head as plain CSS keyed by href — sharing the stylesheet dedupe namespace AND precedence-group ordering with link resources (data-precedence/data-href marked), 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 </style fails closed in SSR with a dev diagnostic (raw-text serialization cannot escape it; the client's textContent insert is always safe and warns in dev for symmetry).
  • Context.Consumer, modern-only with teeth: accessing .Consumer in development logs a one-time-per-context migration diagnostic and still returns undefined (feature probes behave exactly as production; prod object shape untouched — the getter is dev-only), on both octane and octane/server. The nine upstream Consumer scenarios that protect observable behavior (defaults :343, multi-branch :381, propagation bailout ReactContextPropagation:299, sibling propagation :892, hidden subtree :706, no-bailouts-above :1135, suspended-boundary context update ReactSuspense.internal:1410, plus the two already evidenced in context-bailout.test.ts) are ported as useContext-reading conformance tests and flipped to covered with evidence records; the two render-prop-surface-only cases ("warns when passed a consumer", "can read other contexts inside consumer render prop") are non_goal.
  • Ledger + docs: 17 dispositions total (9 Consumer covered + 2 Consumer non-goal + 5 Float covered + 1 style-merge divergence), coverage report regenerated, differences-from-react.md updated 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 — headResourceKind gains the 'style' kind (JSXStyleElement with static href + precedence); the scoped-CSS claim sites skip resource styles (applyCssScoping collect, annotateRootWithHash strip); normalizeChildren partitions them to HeadHoist; requiresTemplateNormalization admits them for value-position bodies (gated on allowHeadHoists, like <title>/<script> — SVG has its own <style>); emitters route to styleResource/ssrStyleResource with the StyleSheet re-rendered unscoped as the CSS argument.
  • packages/octane/src/runtime.ts — styleResource + factored insertPrecedenced (shared group ordering), seed scan extended to style[data-precedence] with data-href identity; dev-only Consumer warning getter in createContext.
  • packages/octane/src/runtime.server.ts — ssrStyleResource with the </style fail-closed guard; the same dev Consumer getter.
  • packages/octane/src/{index,server/index}.ts — exports.
  • packages/octane/audit/react-conformance-ledger.json + docs/react-parity-coverage.md — 17 dispositions, regenerated report.
  • Tests: style-resource client/SSR/hydration/guard/scoped-control cases in 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:check
  • pnpm typecheck
  • pnpm test (full suite)
  • node scripts/react-parity/check.mjs (full — executes the new evidence records) and --validate-only
  • targeted: float-resources (24), context-consumer-adapted (18), context/head/scoped/activity/suspense neighbor sweep (1,096)
  • Pre-fix failures observed: the style-resource tests go red when the classifier's '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

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Touches compiler head-hoist classification and SSR/client Float resource insertion (including fail-closed </style handling), 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.Consumer decision 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 from data-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 .Consumer in development warns once per context and still returns undefined (client and server), so feature probes match production. Observable Consumer scenarios are ported as useContext-reading conformance tests; render-prop-surface-only cases are ledger non_goals.

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

…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]>
@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 Aug 11, 2026
@trueadm
trueadm marked this pull request as ready for review August 11, 2026 22:52
@trueadm
trueadm merged commit 4c1ecd1 into main Aug 11, 2026
50 of 53 checks passed
@trueadm
trueadm deleted the feat/react19-decisions-tranche branch August 11, 2026 23:06
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.

1 participant