An open source design system that's fully customizable and agent ready
TypeScript
feat(Icon): require upload in complete IconRegistry (AST-032) (#7329)
Cindy Zhang4ec1f4ea6d8d
diff --git a/.changeset/breaking-icon-registry-require-upload.md b/.changeset/breaking-icon-registry-require-upload.mdnew file mode 100644index 0000000000..8874c532f0--- /dev/null+++ b/.changeset/breaking-icon-registry-require-upload.md@@ -0,0 +1,18 @@+---+'@astryxdesign/core': minor+---++[breaking] Require `upload` on complete `IconRegistry` types+@rubyycheung @cixzhang @Geervan++Old usage:+A custom complete icon registry typed as `IconRegistry` that omitted the `upload` key.++Replacement:+`IconRegistry` now requires all semantic `IconName` keys, including `upload`.++Migration:+Add an `upload` entry drawn in your registry's icon style to complete icon registries typed as `IconRegistry`.++Codemod:+No `astryx upgrade` codemod applies (spec:AST-017 FR8) because icon artwork is bespoke design artwork tailored to each theme and cannot be automatically synthesized.diff --git a/docs/specs/AST-032/spec.md b/docs/specs/AST-032/spec.mdindex 72828c7ead..0b056ec7e3 100644--- a/docs/specs/AST-032/spec.md+++ b/docs/specs/AST-032/spec.md@@ -65,11 +65,8 @@ shared icon.- **FR6 — Every shipped registry draws upload.** The default registry, eachbundled theme, and each CLI theme template MUST supply `upload` artwork inthat registry's own style. The public `IconRegistry` type describes a complete- registry and MUST require `upload` like every other shared name, starting in- the next minor scheduled under `spec:AST-017/FR47`. Until that minor,- `IconRegistry` MUST accept a complete registry that omits `upload`, and the- omitted entry resolves the default artwork. A consumer migrates by adding an- `upload` entry drawn in its registry's style.+ registry and MUST require `upload` like every other shared name. A consumer+ migrates by adding an `upload` entry drawn in its registry's style.- **IR1 — Owner surfaces stay synchronized.** For upload: `IconName`, thedefault registry, every bundled theme and CLI theme template, the documentedlists of shared icon names, FileInput source and docs, and focused registry@@ -104,19 +101,18 @@ FileInput stops following a theme's `arrowUp` artwork: a theme restyles itthrough `upload`, and a theme without `upload` artwork shows the default uploadartwork there. ChatSendButton keeps its default artwork and resolves its ownslot once that slot is implemented. Every Astryx-shipped registry gains an-`upload` entry, and consumer registries keep compiling until the minor that-requires `upload` (FR6).+`upload` entry, and complete registries require `upload` (FR6).## Verification-| Contract | Verification | Representative states | Mutation or failure expectation |-| -------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |-| FR1 | Icon public-type and registry tests; rendered FileInput tests | default registry, theme `icons.upload`, input and dropzone modes | `upload` missing from `IconName`, FileInput reading another name, or theme `upload` artwork not reaching FileInput fails. |-| FR2–FR3 | component-slot type and resolver tests; rendered ChatSendButton precedence tests | default theme, mapped name, explicit `null`, explicit `sendIcon` | A missing or misspelled slot, direct `arrowUp` lookup, ignored mapping, or a theme overriding caller content fails. |-| FR4 | registry resolution tests with independent theme overrides | theme drawing only `upload`; theme mapping only the send slot | Theme `upload` artwork that changes `arrowUp` or another name, or a send mapping that changes `upload`, fails. |-| FR5 | focused FileInput and ChatSendButton tests; existing Table tests; real-browser visual evidence | unthemed and shipped themes; light and dark; input, dropzone, send, and sort | Changed geometry or accessible output, an `upload` default identical to `arrowUp`, or any changed `arrowUp` consumer fails. |-| FR6 | public-type tests; registry completeness tests over the default registry, bundled themes, and CLI theme templates; theme fallback test | complete registry with and without `upload`; theme without `upload` artwork | A shipped registry without `upload`, a complete registry that stops compiling before the minor, or an omitted `upload` that renders nothing fails. |-| IR1 | `pnpm check:knowledge`, focused docs/source consistency assertions | shared icon-name lists, component docs, current contracts, public types | A stale owner surface or an undocumented shared name blocks the implementation. |+| Contract | Verification | Representative states | Mutation or failure expectation |+| -------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |+| FR1 | Icon public-type and registry tests; rendered FileInput tests | default registry, theme `icons.upload`, input and dropzone modes | `upload` missing from `IconName`, FileInput reading another name, or theme `upload` artwork not reaching FileInput fails. |+| FR2–FR3 | component-slot type and resolver tests; rendered ChatSendButton precedence tests | default theme, mapped name, explicit `null`, explicit `sendIcon` | A missing or misspelled slot, direct `arrowUp` lookup, ignored mapping, or a theme overriding caller content fails. |+| FR4 | registry resolution tests with independent theme overrides | theme drawing only `upload`; theme mapping only the send slot | Theme `upload` artwork that changes `arrowUp` or another name, or a send mapping that changes `upload`, fails. |+| FR5 | focused FileInput and ChatSendButton tests; existing Table tests; real-browser visual evidence | unthemed and shipped themes; light and dark; input, dropzone, send, and sort | Changed geometry or accessible output, an `upload` default identical to `arrowUp`, or any changed `arrowUp` consumer fails. |+| FR6 | public-type tests; registry completeness tests over the default registry, bundled themes, and CLI theme templates; theme fallback test | complete registry; theme without `upload` artwork | A shipped registry without `upload`, a complete registry without `upload` that compiles, or an omitted `upload` that renders nothing fails. |+| IR1 | `pnpm check:knowledge`, focused docs/source consistency assertions | shared icon-name lists, component docs, current contracts, public types | A stale owner surface or an undocumented shared name blocks the implementation. |## Decision log@@ -149,17 +145,14 @@ shared name can carry it.Rejected: a `file-input-upload` component slot, because a slot maps only to anexisting shared name and so cannot give upload artwork of its own.-### DEC-3 — Complete registries require upload from the next minor+### DEC-3 — Complete registries require upload**Reference:** `spec:AST-032/DEC-3`**Decider:** `cixzhang`, `2026-10-05`A complete registry lists every shared name, so `IconRegistry` requires`upload` like the rest: a complete theme registry that type-checks draws upload-in its own style instead of silently borrowing the default artwork. Requiring a-key breaks released complete registries, so the requirement takes effect in a-scheduled minor (`spec:AST-017/FR1`, `FR47`, `FR48`); until then `upload` is-the one key a complete registry may omit.+in its own style instead of silently borrowing the default artwork.Rejected: a permanently optional `upload`, because it would be the only sharedname a complete registry could leave out.diff --git a/packages/core/src/Icon/globalIconRegistry.test.tsx b/packages/core/src/Icon/globalIconRegistry.test.tsxindex f6e1bb0836..2a21710352 100644--- a/packages/core/src/Icon/globalIconRegistry.test.tsx+++ b/packages/core/src/Icon/globalIconRegistry.test.tsx@@ -57,11 +57,14 @@ describe('iconRegistry (global, RSC-compatible)', () => {);});- it('keeps complete registries authored before upload assignable', () => {- const {upload: _upload, ...legacyIcons} = defaultIcons;- const legacyRegistry: IconRegistry = legacyIcons;-- expect(legacyRegistry.search).toBe(defaultIcons.search);+ it('requires all IconNames including upload in complete icon registries', () => {+ const {upload: _upload, ...incompleteIcons} = defaultIcons;+ // @ts-expect-error IconRegistry requires all IconNames including upload+ const incompleteRegistry: IconRegistry = incompleteIcons;+ expect(incompleteRegistry).toBeDefined();++ const completeRegistry: IconRegistry = defaultIcons;+ expect(completeRegistry.upload).toBe(defaultIcons.upload);});it('lets a theme draw upload without changing arrowUp', () => {diff --git a/packages/core/src/Icon/globalIconRegistry.tsx b/packages/core/src/Icon/globalIconRegistry.tsxindex 37fb60f2e3..55f9e8fce9 100644--- a/packages/core/src/Icon/globalIconRegistry.tsx+++ b/packages/core/src/Icon/globalIconRegistry.tsx@@ -85,14 +85,8 @@ export type ExtendedIconName = IconName | (string & {});/*** A complete icon registry: every semantic name mapped to a React node.- *- * `upload` is the one name a complete registry may still omit. Requiring it- * would break registries written before it existed, so it becomes required in- * the next scheduled minor (`spec:AST-032` FR6). An omitted `upload` resolves- * the default artwork, so resolved registry snapshots are always complete.*/-export type IconRegistry = Record<Exclude<IconName, 'upload'>, ReactNode> &- Partial<Record<'upload', ReactNode>>;+export type IconRegistry = Record<IconName, ReactNode>;export type IconRegistrySource = DefinedTheme | string | null | undefined;diff --git a/scripts/check-theme-icon-coverage.test.mjs b/scripts/check-theme-icon-coverage.test.mjsindex d932119c34..2387da219f 100644--- a/scripts/check-theme-icon-coverage.test.mjs+++ b/scripts/check-theme-icon-coverage.test.mjs@@ -4,12 +4,11 @@* @file Every bundled theme draws every shared icon name.** `spec:AST-032` FR6: the default registry, each bundled theme, and each CLI- * theme template supply `upload` artwork in their own style. Until the next- * scheduled minor makes `upload` a required `IconRegistry` key, the type- * checker cannot see a theme that leaves it out, and that theme would quietly- * render the default glyph inside its own icon family. The CLI templates are- * byte-pinned copies of these sources (`check-cli-theme-bundle.test.mjs`), so- * checking the packages covers both.+ * theme template supply `upload` artwork in their own style. `IconRegistry`+ * requires every shared `IconName`. This test verifies at runtime that every+ * bundled theme package exports a complete registry with no missing entries.+ * The CLI templates are byte-pinned copies of these sources+ * (`check-cli-theme-bundle.test.mjs`), so checking the packages covers both.*/import path from 'node:path';