Skip to content

Keep component icon slots in built themes - #7131

Closed
rubyycheung wants to merge 1 commit into
agent/component-icons-corefrom
agent/component-icons-build
Closed

rubyycheung wants to merge 1 commit into
agent/component-icons-corefrom
agent/component-icons-build

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

User need

A theme author who maps component icon slots with defineTheme({componentIcons}) and ships the theme through astryx theme build gets a built module without the map. When the built theme is passed to <Theme>, every slot falls back to its component default. A theme that extends the built module, which is how the shipped ./built subpaths are consumed, inherits no slot mappings either. The same theme then behaves differently depending on whether it is used from source or from its build.

Problem and solution fit

The generated theme module now inlines the normalized componentIcons map, the same way it already carries components, media surfaces, and adaptation metadata for extending themes. The map holds only shared icon names and null, so JSON serialization reproduces it exactly:

  • same keys, in resolved order;
  • the same IconName values;
  • every null kept;
  • undefined entries left out, matching defineTheme normalization, including for a raw theme object that skips defineTheme.

The map contributes nothing to the generated CSS. Family builds serialize each member's flattened map.

Stacked on the static componentIcons Core implementation, which is stacked on #7117.

Current specification

  • architecture:theme-compilation INV15: component icon slot maps pass through to the built module unchanged, with the same keys and values including null, and a theme extending a built theme inherits the same map it inherits from source.
  • architecture:theme-authoring-contract INV3/INV13 own the normalized map this build saves.
  • architecture:icon-resolution-and-component-slots owns what an entry means; this PR does not change resolution.

Public delta and caller burden

  • The astryx theme build JavaScript output gains a componentIcons field whenever the resolved source theme has one. It is absent when the source has none, and {} when the source map is empty.
  • Generated CSS and .d.ts output are unchanged. The declaration already types the theme as DefinedTheme, which includes componentIcons.
  • Themes without componentIcons produce byte-identical output.
  • Callers no longer need to keep the source theme around for slot mappings. The temporary icons-doc caveat that told them to do so is removed.

Design and alternatives

The map is serialized inline, not imported, because it is plain data, unlike the icon registry, which holds React elements. The serializer follows defineTheme normalization rather than copying the field blindly, so a raw theme object and its defineTheme form produce the same built map.

Evidence

New fixtures in packages/cli/api/theme/build/build.test.mjs (themeBuild() — componentIcons) build real theme files, import the generated module, and compare it with the runtime result of the same source:

  • the built map equals the source map: keys, order, names, and null; the CSS carries no slot data;
  • a child extending a source base is built with its flattened map (null replacement, name replacement, and undefined inheritance);
  • a child extending the built base gets the same runtime map as a child extending the source base, and that child's own build carries the same map;
  • a raw theme object with an undefined entry is saved as defineTheme would normalize it;
  • the field is absent when the source has no map and {} when the source map is empty;
  • check mode reports a built module whose slot map drifted from the source as stale;
  • a family build saves each member's map, flattened through its parent.

Disabling the serializer makes all seven new tests fail.

Scope

  • One capability is added: built-theme preservation of the static slot map.
  • Unrelated fixes, cleanup, and policy changes were removed or split. No older-Core policy, AST-054 state/variant/size resolvers, component slot metadata, or component consumers.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Writing rubric results

This PR edits one knowledge record, docs/architecture/theme-compilation.md: it deletes the paragraph under "Known conformance and verification gaps" that described componentIcons preservation as unshipped.

  • R1 narration: one paragraph described INV15 as unshipped, which no longer describes the system; deleted. The remaining gap paragraphs are accurate and outside this change.
  • R2 research: none.
  • R3 evidence: none; the INV15 verification row names the build.test.mjs component-icon and runtime/build comparison fixtures, which now exist.
  • R4 rejected alternatives: none.
  • R5 change references: none.
  • R6 open questions: none.

Testing

  • pnpm exec vitest run packages/cli/api/theme/build/build.test.mjs: 60 tests passed, including the 7 new ones;
  • theme-focused run over packages/cli/api/theme, packages/cli/clients/cli/commands, packages/core/src/theme, packages/core/src/Icon, scripts/check-theme-template.test.mjs, and scripts/check-knowledge.test.mjs: 136 files, 3,284 tests passed;
  • full Core and CLI suites: 759 of 761 files passed (17,209 tests). The 4 failing tests are in packages/cli/api/build/build.test.mjs and packages/cli/clients/cli/commands/search.test.mjs, which this PR does not touch, and both files pass when rerun on their own (77 tests);
  • Core typecheck; CLI typecheck:json-api, typecheck:template-docs, and typecheck:authoring;
  • strict ESLint on changed source; Prettier on changed .mjs, .md, and changeset files;
  • pnpm check:repo, including check:sync, check:knowledge, and check:changesets;
  • git diff --check.

CLI typecheck:strict reports the same two errors with and without this change: unchanged page templates import @astryxdesign/theme-neutral/built, which is not built in this checkout. icons.doc.mjs has four pre-existing category: indentation lines that Prettier would reformat; they are left untouched to keep the diff focused.

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

vercel Bot commented Oct 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 Oct 7, 2026 8:23pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 8, 2026, 1:44 AM UTC

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

The generated theme module now inlines the normalized componentIcons map,
so a built theme and its source expose the same slot mappings, including
null entries, and a theme extending a built theme inherits the same map
it inherits from source. The map adds no CSS. Removes the resolved
built-theme gap note from architecture:theme-compilation and the
matching caveat from the icons docs.

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

Built themes now keep their component icon slot mappings, so a built theme resolves each slot the same way its source theme does — including slots intentionally hidden — and a theme extending a built theme inherits the same mappings. Themes without a slot map produce unchanged output, and the map adds nothing to the generated CSS.

I checked the serializer against theme definition's own normalization (names and hidden slots kept, unmapped entries dropped, key order preserved) and ran the build test file locally: all 60 tests pass, including the new parity, inheritance, staleness, and family-build fixtures. No changes are needed.

One sequencing note for maintainers: the detailed parity wording for this behavior is still landing in the stacked spec change beneath this stack. The preservation direction is already in the current icon-resolution architecture record, so this does not block the fix, but if that stacked wording is amended, the parity details are worth a final recheck against it.

[Automated review]

@rubyycheung

Copy link
Copy Markdown
Contributor Author

Closing this PR because its build support belongs to the superseded static-only #7117 → #7122 direction.

Source/built-theme parity remains mandatory and is moving into the first focused replacement implementation PR, so no theme field can silently disappear during a build. The corrected AST-054 model is in #6891 and its authority projection is in #7116. This PR remains available as historical context; none of it landed. Replacement links will be added to #6891 and #7116 as each focused PR opens.

@rubyycheung rubyycheung closed this Oct 9, 2026
@github-actions
github-actions Bot deleted the agent/component-icons-build branch October 9, 2026 06:25

This branch was successfully deployed

1 active deployment
Preview — 43a4fe92 Deployed Oct 7, 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