Skip to content

feat(theme): add shared component adaptation infrastructure - #6127

Closed
imdreamrunner wants to merge 1 commit into
feat/component-adaptations-specfrom
feat/component-adaptations-infra
Closed

imdreamrunner wants to merge 1 commit into
feat/component-adaptations-specfrom
feat/component-adaptations-infra

Conversation

@imdreamrunner

Copy link
Copy Markdown
Contributor

Summary

  • add shared ComponentAdaptations<T> types and a private theme-aware resolver
  • extract one condition compiler used by both theme CSS and component policies
  • resolve named width points through the nearest Theme, registered root, or defaults
  • use one useSyncExternalStore subscription keyed by compiled query strings
  • move AppShell behind the same effective-breakpoint accessor without behavior change
  • emit no CSS and add no React context

Validation

  • Core/UI/AppShell and resolver suites
  • Core typecheck and docs typecheck
  • ESLint and repository guardrails
  • Core build
  • theme/compiler byte-equivalence probe

This is draft infrastructure stacked on #6123, which is stacked on #5543. It does not change a component's public behavior.

@vercel

vercel Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 9, 2026 4:53am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 7, 2026
@imdreamrunner
imdreamrunner force-pushed the feat/component-adaptations-infra branch from 47fab13 to fd9005a Compare September 7, 2026 18:57
@imdreamrunner
imdreamrunner force-pushed the feat/component-adaptations-spec branch from b7df64c to 9a2f061 Compare September 7, 2026 21:56
@imdreamrunner
imdreamrunner force-pushed the feat/component-adaptations-infra branch from fd9005a to f1100aa Compare September 7, 2026 21:56
@imdreamrunner
imdreamrunner force-pushed the feat/component-adaptations-spec branch from 9a2f061 to 02ad5e4 Compare September 7, 2026 23:07
@imdreamrunner
imdreamrunner force-pushed the feat/component-adaptations-infra branch from f1100aa to f5f7b46 Compare September 7, 2026 23:07
@imdreamrunner
imdreamrunner force-pushed the feat/component-adaptations-spec branch from 02ad5e4 to eb67cdb Compare September 8, 2026 23:03
@imdreamrunner
imdreamrunner force-pushed the feat/component-adaptations-infra branch from f5f7b46 to 689b632 Compare September 8, 2026 23:03
Extract AST-012 condition normalization and media-query compilation into a
package-internal module shared by theme CSS generation and a new component
adaptation resolver (spec:AST-031 IR1). Theme output and diagnostics are
byte-identical.

Add package-internal ComponentAdaptations/ComponentAdaptationRule/
ComponentAdaptationCondition value types, a useComponentAdaptations resolver
(server default, last matching rule wins), and an effective-width-point
accessor that AppShell now uses instead of reading DefinedTheme.__adaptations.
AST-031 is still a draft, so nothing here is exported from the package entry
point and there is no public behavior to release.

The resolver separates the per-render store handle from the shared connection
that owns the MediaQueryLists: only subscribe registers a connection, so a
server or abandoned render leaves the registry empty; subscribe re-registers,
so identical policies still share after a StrictMode remount; and attachment
is tracked explicitly, so a connection opened before matchMedia exists still
attaches once it does.

ComponentAdaptations.rules is required and may be empty; an empty policy
resolves to default everywhere and subscribes to nothing.

No component behavior changes.
@astracat-bot

astracat-bot Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 8, 2026, 1:47 PM UTC

@github-actions
github-actions Bot deleted the branch feat/component-adaptations-spec October 1, 2026 06:25

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval of this draft waits on a maintainer decision: no spec on main governs the shared component-adaptation layer (ComponentAdaptations<T> and useComponentAdaptations), because the AST-031 proposal in #6123 was closed without merging and AST-012 keeps component behavior separately owned. A maintainer needs to provide or identify that spec, including whether this layer should exist alongside the presentation prop that AST-043 and Selector's spec already use to choose a surface. Whatever the answer, these changes are needed:

  • Split the 3,222-line change so the AppShell width-point accessor can land on its own, apart from the component layer.
  • Keep the condition vocabulary and validation in themeAdaptations.ts, which architecture:theme-authoring-contract names as their owner, or have that record updated first.
  • Replace the AST-031 citations, because that id now belongs to an unrelated record on main, and retarget the PR onto main, because its base branch no longer exists.

[Automated review]

@@ -468,7 +470,9 @@ export function AppShell({
...rest
}: AppShellProps) {
const t = useTranslator();
const activeTheme = useThemeDefinition();
// Named width points resolve through the shared accessor (spec:AST-031 FR5),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spec:AST-031 on main is the runtime-integration feature composition spec, and its FR5 is about CLI gap-report handlers. This lookup is governed by AST-012 FR8 and architecture:theme-application INV10; please cite those instead.

* @input Authored adaptation conditions and width-breakpoint maps
* @output Package-internal condition vocabulary, normalization, and media-query
* compilation shared by every adaptation consumer
* @position Shared owner of AST-012 condition semantics (spec:AST-031 IR1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

architecture:theme-authoring-contract names themeAdaptations.ts as the owner of the breakpoint/condition vocabulary and its validation. Either keep these definitions there and import them into componentAdaptations.ts, or update that record before moving ownership here.

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

(Posted by Cindy's agent.) Thank you, @imdreamrunner! This shared adaptation layer existed to serve the DateInput and Selector adaptations, and both now ship through each component's presentation prop (DateInput's in your #6628). Closing this one since nothing else depends on it.

@cixzhang cixzhang closed this Nov 8, 2026
@github-actions
github-actions Bot deleted the feat/component-adaptations-infra branch November 9, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 68e51bfe Deployed Sep 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants