Repository navigation
fix(theme): preserve component overrides in type-scale adaptations - #6710
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
There was a problem hiding this comment.
This change fixes a real cascade bug: when a theme adaptation only changed the type scale, the regenerated Heading/Text defaults were emitted after the root theme and silently reset authored component styles — for example, a branded display font family reverting on narrow touch viewports. The fix resolves adaptations against the effective root component map and omits only the generated component leaves that already exist at root, so sizes and leading still adapt through the existing variable wiring while authored pins stay authoritative.
The important boundaries are preserved: generated scale tokens still write in rule order, authored rule overrides (including one that restores a root value) still win, themes without a root scale still receive the missing generated defaults, and built themes behave the same as source-defined themes. The new Core and CLI regression cases cover these paths, including child-theme inheritance.
No changes requested.
[Automated review]
There was a problem hiding this comment.
This change fixes a real cascade bug: when a theme adaptation only changed the type scale, the regenerated Heading/Text defaults were emitted after the root theme and silently reset authored component styles — for example, a branded display font family reverting on narrow touch viewports. The fix resolves adaptations against the effective root component map and omits only the generated component leaves that already exist at root, so sizes and leading still adapt through the existing variable wiring while authored pins stay authoritative. The important boundaries are preserved and covered by new Core and CLI regression cases: generated scale tokens still write in rule order, authored rule overrides (including one that restores a root value) still win, and themes without a root scale still receive the missing generated defaults.
Approval is not yet possible, because this pull request also intentionally changes the established spec: the current AST-012 FR4 wording says every produced leaf counts as a write by that rule, and FR6 gives the last matching write the win with no root-path exception. Approval needs a maintainer to update the existing spec for that intentional change — an eligible engineering owner giving spec-owner approval to this pull request's FR4/FR6 amendment on its current head, which is still pending. What must be settled is whether invariant generated type-scale component defaults at exact leaf paths already declared on the effective root components are not writes (with generated tokens and rule-authored leaves remaining writes), and whether a later scale-only rule preserves an earlier authored component leaf only when its exact path exists at root, while the generated leaf still wins when that path is absent.
No code changes are requested for this hold. Once a maintainer settles the spec update, the evidence in this change supports approval as it stands.
[Automated review]
|
/approve-spec bab2a3b |
User impact
Themes that combine
typography.scalewith authored Heading/Text component styles lose those styles when a scale-only adaptation matches. For example, a butter-shaped theme's display text switches from its Sarina stack tovar(--font-family-heading)on narrow touch viewports. This restores the authored component treatment while allowing sizes and leading to adapt.This is a separate Core fix discovered while reviewing #6699. It does not change that PR or any file under
packages/themes/butter.Problem and solution fit
resolveThemeAdaptationRulesresolves each rule without root components.resolveThemeValuesregenerates type-scale component rules and merges only that rule's authored components over them.generateAdaptationRuleRulesthen emits those defaults after the root at equal specificity.var()wiring is independent of the scale configuration.The resolver now receives the effective root component map from both
defineThemeand the built-metadata compiler path. After normal validation, it omits only generated type-scale component leaves whose exact root path already exists. It never removes an authored rule leaf. The existing root declaration therefore remains authoritative, while changed scale tokens flow through its existing variable references.Expected behavior and authority
AST-012, current, FR4–FR7 and IR2/IR4:
The prior FR4 wording says every produced generative-axis leaf counts as a write. This PR includes a narrow FR4/FR6 amendment making the exception explicit: invariant generated type-scale component defaults at exact paths already declared on the effective root are not writes; generated tokens and rule-authored component leaves remain writes. Consequently, an earlier authored component leaf survives a later scale-only rule only when that path exists at root. Without the root path, the later generated component leaf still wins. This does not make root token pins beat later generated token values.
The current-record amendment requires
spec-owner-approvalfrom an eligible engineering owner on the new exact head. Historicalapproved_by/approved_atand owners are unchanged; no new approval is claimed by this PR.Smallest restoration
Rejected alternatives:
Evidence
main.Outfit, sans-serifto the Sarina stack while keeping the adapted size at 42 px. The minimal probe's component CSS shrinks from 16,103 to 10,778 bytes.Scope
Testing
pnpm vitest run --project=ui packages/core/src/theme/— 22 files, 1,470 tests passed after the review follow-up.pnpm check:knowledgeandpnpm check:changesets— passed after the FR4/FR6 amendment and changeset citation.pnpm vitest run --project=node packages/cli/clients/cli/commands/build-theme.adaptations.test.mjs— 16 tests passed.pnpm build— passed; Core rebuilt again from the final implementation before CLI and Chromium checks.pnpm lint:strict— passed, 0 errors (82 existing warnings outside this change).pnpm test --maxWorkers=8on implementation commit8a2b26eecc(before the spec/test-only review follow-up) — 920 files passed, 3 skipped; 19,717 tests passed, 2 expected failures, 52 skipped. One unrelatedaccessibility-audit.integration.test.mjstest failed. Isolated runs on both this branch and a clean detached worktree at base commit665afc1a0cc94e468ef5fbd15922fdc7defb210areproduce this fixture's port-allocation failure (EADDRINUSE), affecting different cases. No accessibility test or production code is changed here.One patch changeset:
@astryxdesign/core,[fix],@imdreamrunner.Current global-baseline routing receipt
Authority base:
665afc1a0cc94e468ef5fbd15922fdc7defb210a. Trigger:theming; each claim matched its record'sreview-applicability:v1route.architecture:component-theming-surface: INV3–INV10, INV12, INV14, INV15.architecture:theme-application: INV1, INV2, INV3, INV7, INV8, INV9.architecture:theme-authoring-contract: INV1, INV3, INV8, INV9, INV11, INV12.architecture:theme-compilation: INV2, INV3, INV4, INV6, INV9, INV10.spec:AST-012: FR4, FR5, FR6, FR7.No target, enrollment, private-variable, or provider-boundary change. The direct restoration is in adaptation resolution; compiler/inheritance parity and unchanged surface/weight behavior are covered by the suites above.