Skip to content

spec(native): augmentable variants on Swift are open types the theme extends - #8039

Merged
cixzhang merged 1 commit into
mainfrom
spec/native-swift-augmentable-variants
Oct 24, 2026
Merged

cixzhang merged 1 commit into
mainfrom
spec/native-swift-augmentable-variants

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Exact decision needed

How augmentable component props (values a theme adds to a visual axis, such as a new button variant) work in Swift: an open, string-backed type instead of a closed enum, static members for each theme's added values, per-theme style data, and a by-name lookup that falls back to the default. Draft until the owner approves; nothing is built from it before then.

Existing authority searched

  • spec:AST-082 FR4 (portable props). The native form for augmentable props is decided: a string-backed value with built-in constants, extended by the theme generator, decoding any name, with unknown names drawn in the base look. This spec applies it. FR10 (native component theming through platform entries), FR18 (component overrides keyed by web targets are the web part).
  • Web augmentation: a theme's components keys such as 'variant:primary-muted' generate a type augmentation in the theme build.
  • The Swift theme generator spec (approved) is extended with the variants file and style data; the Swift component API spec (approved) sets the names.

Decision

  • V1 Augmentable props generate as a string-backed struct with built-ins as static constants; decoding accepts any string; the wire carries the raw string. Swift keywords are written in backticks (Card's default is .`default`).
  • V2 Each theme's added values become static members, declared once per run in a generated Variants.swift.
  • V3 Native style data comes from defineNativeTheme platform entries for the platform being built (platforms.ios, platforms.macos), as components.<target>['<axis>:<value>'] style maps; entries keep their version ranges and resolve at run time by AST-082 FR10's rule (running platform and OS version; later entry wins); web component overrides are never read.
  • V4 Built-in values keep their built-in look (a platform entry may restyle them); an added value nothing styles draws the component's base look as AST-082 FR4 says: no value style at all, while a platform entry's style for the component's own target still applies; logs once in development.
  • V5 A custom value changes only what V3 carries (paint, shape, font, padding), never behavior; accessibility comes from the core contract.

Rejected alternatives

None recorded in the spec.

Claim scope and non-goals

Which props are augmentable is set by the AST-082 FR4 amendment. Style data comes only from native platform entries, as AST-082 FR10/FR18 and AST-093 FR4 require.

Landing order

Applies the AST-082 FR4 amendment for augmentable props (docs/specs/AST-082-native-first-surfaces/spec.md, #8070) and extends packages/native/specs/swift/library/theme-generator.md (#8031). Lands after both.

Evidence and implementation relationship

One file: packages/native/specs/swift/library/augmentable-variants.md. Published themes style built-in and added values on augmentable axes (for example variant:muted).

Writing rubric results

  • R1 narration: none.
  • R2 research in the record: none.
  • R3 evidence naming a change: none.
  • R4 rejected alternatives: none.
  • R5 pull request or issue references remaining: none in the record.
  • R6 ruled open questions still listing options: none. The earlier OQ1 (style data source) is ruled by AST-082 FR10/FR18 and AST-093 FR4: platform entries; it is removed and Open questions reads None.

Scope

  • Specification only; no implementation.
  • Every changed file is under packages/native/.
  • Public text contains no internal context.

@vercel

vercel Bot commented Oct 24, 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 Oct 24, 2026 10:38am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 24, 2026, 10:57 AM UTC

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

46 of 496 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang marked this pull request as ready for review October 24, 2026 04:52
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 3170c9f

@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.

Requesting changes before this record merges: V3 has Swift read style data from a theme's web component overrides, which current AST-082 FR18/FR10 and AST-093 FR4 keep in the web part and route through native platform entries, and the record's own OQ1 still calls that source undecided. Please keep V3 source-neutral (or point it at platform-entry components) until the AST-082 amendment lands, or land that amendment first and cite it.

  • V4's fallback also covers built-in values a theme leaves unstyled, so under neutral a Swift primary or ghost Button would draw the default secondary look; limit it to values with no built-in look and make the baseline independent of the active theme.
  • The Relation line and V1–V3 cite rules that are not on main yet (an augmentable form in AST-082 FR4, a core-contract augmentable marker, and the theme generator's G1, G7, name rule and drift check); merge after those records or name them as pending dependencies.

[Automated review]

Comment on lines +44 to +46
weight, and padding. Values come from the theme's own style declarations,
resolved per mode with references to tokens replaced by the token's value
(theme generator G1, G7). A style key Swift does not draw is reported and

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.

This makes the theme's web component overrides the Swift style source, but current AST-082 FR18 keeps overrides keyed by web theme targets in the web part and sends native component theming through platform entries (FR10), and AST-093 FR4 lists only tokens and defineNativeTheme as native brand sources. OQ1 below also says the source is still open. Could V3 stay source-neutral, or name platform-entry components, until the AST-082 amendment lands?

Comment on lines +49 to +51
augmentable prop from the theme in the environment, by raw value. A value the
theme does not style draws the component's base look, the style of the
prop's default value; a development build logs that fallback once, naming

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.

As written, this fallback also covers built-in values a theme leaves unstyled: neutral declares only Button variant:destructive, so .primary and .ghost would draw the default secondary look and log. Suggest limiting the fallback to values with no built-in look and stating that the base look does not depend on the active theme.

Comment on lines +4 to +7
- Relation: applies the native form of the AST-082 FR4 rule for augmentable
props (a string-backed value with built-in constants, extended by the theme
generator, that decodes any name and draws an unknown name in the base look)
to Swift, and extends the theme generator spec. Web augmentation: a theme adds a

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.

AST-082 FR4 on main lists closed string sets but no open or augmentable form, and the theme generator record (G1, G7, its name rule and drift check) is not on main yet. Merging after those records, or naming them here as pending dependencies, keeps this citation accurate.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 08eb7d2

@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.

This revision resolves the earlier review's two main points (V3 now reads native platform entries and V4 keeps built-in looks), but approval now waits on an engineering owner's decision: the draft requirements V1–V5 and their acceptance checks need an approval on the current head, because the earlier /approve-spec named the previous commit, and spec:AST-082 FR4 must carry the open string-set form V1 relies on before this record merges. An engineering owner records that decision by commenting /approve-spec 08eb7d2c8a6c2ad9de7f8b98ada7b53090b9a3b6 on this pull request; the author may do so as an engineering owner. Before merge, please also address:

  • V3 and V4 keep one style per value and mode, so a platform entry scoped by minVersion/maxVersion or under platforms.macos has no place, while AST-082 FR10 applies each entry only on its platform and inside its range.
  • The Relation line, V1, V3 and the Drift row cite an AST-082 FR4 rule and theme-generator clauses that are not on main; land after #8070 and #8031 or mark them as pending dependencies.
  • V4's base look (the default value's built-in look) is undefined for Heading type, which has no default and falls back to its level's look per architecture:component-theming-surface INV14.

[Automated review]

Comment on lines +39 to +41
- **V3 — Native style data comes from platform entries.** Each theme file
carries, per mode, the style its native theme's platform entries give a
value on an augmentable axis (`platforms.ios[].components`, keyed by the

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.

This table holds one style per value and mode, read from platforms.ios. AST-082 FR10 lets a platform entry carry minVersion/maxVersion and says it “applies only on its platform and inside its range”, with a later matching entry replacing an earlier one (as resolveNativeTheme does). The Swift binding also builds for macOS. Could V3 keep each entry's platform and range and resolve them against the running OS, say what a macOS build reads, and add a ranged entry and a macOS row to the V3 check?

- **V3 — Native style data comes from platform entries.** Each theme file
carries, per mode, the style its native theme's platform entries give a
value on an augmentable axis (`platforms.ios[].components`, keyed by the
component's target and the value, such as `'variant:primary-muted'`), added

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.

Which shape is this? Read as a component target holding a 'variant:…' key that holds the style map, it is one level deeper than today's PlatformEntry.components (Record<string, Record<string, string | number>>), and a fixture written that way fails to type-check (TS2322). Giving the exact entry shape, and the type change if it is the nested one, would make the V3 check writable.

Comment on lines +53 to +55
restyle. A value with no built-in look that the theme does not style draws
the component's base look: the built-in look of the prop's default value in
the core contract, which does not depend on the active theme; a development

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.

Heading type is backed by core's augmentable HeadingTypeMap but has no default value; on the web an unknown type keeps the level's look, and architecture:component-theming-surface INV14 names Heading.level as its baseline. Defining the base look as the component's look with the prop absent would cover it.

Comment on lines +4 to +7
- Relation: applies the native form of the AST-082 FR4 rule for augmentable
props (a string-backed value with built-in constants, extended by the theme
generator, that decodes any name and draws an unknown name in the base look)
to Swift, and extends `packages/native/specs/swift/library/theme-generator.md`.

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.

On main, AST-082 FR4 lists closed string sets only, and theme-generator.md (with the name rule, G1, G7 and the drift check cited below) does not exist yet. Merging after those records land, or naming them here as pending dependencies, keeps these citations accurate.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 8c3c4da

@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.

Requesting changes before this record merges: the direction in V1–V5 is approved for this head, but V1 needs the open string-set form that AST-082 FR4 on main does not have yet (#8070), and the record extends a theme-generator record that is not on main (#8031). Please land those first and rebase, and also:

  • add a Current state line saying PlatformEntry.components takes only flat string | number values today, since V3 needs the nested '<axis>:<value>' map;
  • say whether V4's base look follows a platform entry's restyle of the default value, and add a check for that case.

A rebase changes the head, so an engineering owner then records approval again by commenting /approve-spec <full head SHA>; the author may do so as an engineering owner.

[Automated review]

`components`, a target holds, beside its own style keys, a key
`'<axis>:<value>'` whose value is that value's style map
(`components.button['variant:primary-muted'] = {backgroundColor: …}`); the
`PlatformEntry.components` type allows that nested map. Each theme file keeps

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.

PlatformEntry.components is Readonly<Record<string, Readonly<Record<string, string | number>>>> today (packages/native/src/theme/defineNativeTheme.ts), so a 'variant:primary-muted' style map fails to type-check (TS2322). Could Current state say the type takes only flat string | number values today, so readers see that V3 widens it?

Comment on lines +60 to +62
the component's base look: its look with the prop absent, which does not
depend on the active theme. For a prop with a default in the core contract
that is the default value's built-in look; for a prop with no default, such

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.

When an applying platform entry restyles the default value (Button's variant:secondary), a Button with the prop absent draws that restyle, so "its look with the prop absent" depends on the theme and differs from "the default value's built-in look". Could this say the base look is the built-in look before any platform-entry restyle, and add a V4 check with an entry that restyles the default?

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 6b596e5

@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.

Requesting changes before this record merges: V1–V5 are approved for this exact revision, but the record still rests on two records that are not on main yet, the AST-082 FR4 open string-set form (#8070) and the Swift theme-generator record whose name rule, G1, G7 and drift check it cites (#8031). Please land those first and rebase, and fix V5, which says a custom value changes only paint and shape while V3 also gives it font and padding values. A rebase changes the head, so an engineering owner then records approval again by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.

[Automated review]

Comment on lines +67 to +68
- **V5 — Accessibility does not depend on the variant.** A custom value changes
only paint and shape. Name, role, and state come from the core contract, as

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.

V3 (lines 47–49) gives a custom value font family, size, weight and padding, which are not paint or shape. Saying the value changes only its V3 style keys keeps a V5 check from asserting that text size and spacing stay fixed.

@cixzhang
cixzhang force-pushed the spec/native-swift-augmentable-variants branch from 6b596e5 to dfe19fa Compare October 24, 2026 07:54
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d97b4a3

@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.

Requesting changes before this record merges: V1–V5 are approved for this exact revision and the records it builds on are now on main, but V4's fallback does not match AST-082 FR4, which says a native platform draws a name it has no rule for in the component's base look “as the web does”. On the web, a Button, Card or Badge value that a theme adds but does not style draws with no value style at all, while V4 and its check draw the default value's look (Button's filled secondary), so please align V4 and its check with the web's no-match look, or amend FR4 first if the default look is the intended fallback. Two smaller fixes:

  • V5 says a custom value changes only paint and shape, but V3 also gives it font and padding values.
  • V1 names built-in constants by “the theme generator's name rule”, but G3 allows the keyword default while G6 fails the run on it, which decides whether Card's built-in default generates.

A new commit changes the head, so an engineering owner then records approval again by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.

[Automated review]

Comment on lines +59 to +63
restyle. A value with no built-in look that no applying entry styles draws
the component's base look: its look with the prop absent, including an
applying platform entry's restyle of that look, so an unstyled added value
matches the brand's default. For a prop with a default in the core contract
that is the default value's built-in look; for a prop with no default, such

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.

AST-082 FR4 says a native platform draws a name it has no rule for in the component's base look “as the web does for an augmented name with no built-in style”. On the web, Button, Card and Badge look their value style up by name (Button.tsx:734, Card.tsx:306, Badge.tsx:211), so an added value with no theme rule draws with no value style, not the default value's look; Heading keeps the prop-absent look on purpose (Heading.tsx:251–254). Could V4, and the check at line 78, define the base look as what the web draws, or should FR4 be amended first if the default look is the intended fallback?

Comment on lines +67 to +68
- **V5 — Accessibility does not depend on the variant.** A custom value changes
only paint and shape. Name, role, and state come from the core contract, as

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.

V3 (lines 47–49) also gives a custom value font family, size, weight and padding, which are neither paint nor shape. Saying the value changes only its V3 style keys would keep V5 consistent with V3.

Comment on lines +25 to +26
of a closed `enum`. Each built-in value is a static constant named by the
theme generator's name rule (`.primary`, `.ghost`). Decoding accepts any

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.

theme-generator.md has two naming rules: G3 allows the keyword default (lines 49–51) and G6 fails the run on any keyword (lines 78–79). Card's built-in default generates under one and fails under the other; naming the clause, or saying a keyword built-in is escaped as today's contract generator does, would settle it.

@cixzhang
cixzhang force-pushed the spec/native-swift-augmentable-variants branch from d97b4a3 to f054792 Compare October 24, 2026 08:54
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 23fb1d6

@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.

Requesting changes for one sentence: V1–V5 are approved for this exact revision, the records it builds on are on main, and V4 and its check now match AST-082 FR4's base look, but the Summary (lines 16–17) still says a variant name nothing styles "draws the component's default look", which for Button, Card and Badge is another value's look (Button's filled secondary), the fallback V4 now rules out. Please reword it to the base look, for example "A variant name nothing styles draws the component's base look, with no value style, instead of failing." A new commit changes the head, so an engineering owner then records approval again by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.

[Automated review]

Comment on lines +16 to +17
styled as the brand's native theme defines it. A variant name nothing styles
draws the component's default look instead of failing.

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.

This still promises the default look, which for Button, Card and Badge is another value's look (a Button with no variant draws secondary). V4 (lines 61–63), its check (line 78) and AST-082 FR4 say the base look with no value style. Suggested wording: "A variant name nothing styles draws the component's base look, with no value style, instead of failing."

@cixzhang
cixzhang force-pushed the spec/native-swift-augmentable-variants branch from 23fb1d6 to 5ebb4fd Compare October 24, 2026 09:33
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 5ebb4fd

@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.

No changes needed: an engineering owner approved V1–V5 and their checks for this exact revision, the AST-082 FR4 open string set and the Swift theme-generator record they build on are on main, and the Summary now gives an unstyled added value the same base look as V4 and FR4. One optional clarification: V2 does not say where a theme adds a value, and read with V3 only native platform entries can, so a value a theme adds only in its web overrides, such as neutral's Badge gray, would get no Swift constant until its native theme declares it. If you edit the record, the new commit needs a fresh /approve-spec <full head SHA> from an engineering owner, which you may record yourself as one.

[Automated review]

encodes and decodes the raw string unchanged. Code never switches over every
value.
- **V2 — Each theme's added values become static members.** For each
augmentable axis, the theme generator collects the values a theme adds and

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.

Optional clarification: this does not say which declaration adds a value. Read with V3 ("The theme's web component overrides are never read", line 55) and the theme generator's G1, only native platform entries can, so a value a theme adds only in its web overrides, such as neutral's Badge gray, would get no Swift constant until its native theme declares it. Naming the source here, and the kind of fixture in the V2 check (line 76), would settle it.

@cixzhang
cixzhang force-pushed the spec/native-swift-augmentable-variants branch from 5ebb4fd to 4b38f3c Compare October 24, 2026 10:30
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 4b38f3c

@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.

No changes needed: an engineering owner approved V1–V5 and their checks for this exact head, the AST-082 FR4 open string set and the Swift theme-generator record they build on are on main, and the record stays consistent with the unprefixed Theme names and the theme-environment record now on main. Two optional clarifications would help implementers: V2 could name which theme declaration adds a value (read with V3, a value a theme adds only in its web overrides, such as neutral's Badge gray, gets no Swift constant), and V3 could say whether a later platform entry replaces an earlier one per member, as resolveNativeTheme does today, or per value style. If you edit the record, the new commit needs a fresh /approve-spec <full head SHA> from an engineering owner, which you may record yourself as one.

[Automated review]

Comment on lines +53 to +55
style is chosen by AST-082 FR10's entry rule: only entries for the running
platform whose range holds the running OS version apply, and a later
matching entry replaces an earlier one. The theme's web component overrides

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.

Optional clarification: resolveNativeTheme applies this rule per member, so a later matching entry that carries any components replaces the earlier entry's whole components map (packages/native/src/theme/defineNativeTheme.ts:220–221). Read that way, a version-scoped entry that styles only card drops the Button value styles an earlier entry gave on those OS versions. Saying whether Swift resolves per member, as the TypeScript resolver does, or per value style, and adding that case to the V3 check (line 77), would keep the two resolvers from diverging.

@cixzhang
cixzhang merged commit 0ade0dd into main Oct 24, 2026
70 checks passed
@github-actions
github-actions Bot deleted the spec/native-swift-augmentable-variants branch October 25, 2026 06:20

This branch was successfully deployed

1 active deployment
Preview — 4b38f3ca Deployed Oct 24, 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.

1 participant