Repository navigation
Conversation
…another React does not (red)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 1fc1f09 |
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Requesting changes: the icon registry fix is sound, but the release note also claims a theme fix that swizzled components never needed.
- The changeset (
.changeset/public-registries-swizzle-shared.md) and the title say swizzled copies could not find a theme by name, but no component thatastryx swizzleoffers copiestheme/themeRegistry.ts, because every copied theme lookup already importsgetRegisteredThemeorregisterThemefrom@astryxdesign/core/theme; limit the swizzle claim to icons in theIcon,CodeBlock,TableandTimestampcopies, and describe the theme change as sharing themes across Core bundles loaded on one React.
The code can stay as it is: the new tests fail before the change and pass after it, and no public API changes. Three new source comments run longer than the comment style allows (inline, non-blocking).
[Automated review]
…ten three comments
|
/approve-spec 6a423aa |
There was a problem hiding this comment.
Approved pending CI: the heavy CI jobs (build and tests) have not run on this head yet; they are deferred and run before merge.
The release note now matches the change: registered icons reach the swizzled Icon, CodeBlock, Table and Timestamp copies, and the theme registry is shared by Core bundles on one React. The new registry tests fail before the change and pass after it, and no public API changes.
[Automated review]
User impact
A product engineer who registers icons with
registerIcons()and then swizzlesIcon,CodeBlock,TableorTimestampgets a copy that cannot see them: those copies carry their own icon registry, which starts empty, so a product's registered icon, or a library key such asrichtext:bold, fell back to the default icon in the copy while the package showed the product's icon. After this change copies of Core on one React share the icon registry.The theme registry moves to the same per-React store. Swizzled components already read themes through
@astryxdesign/core/theme, so for them nothing changes; what changes is that themes registered by name are shared by every Core bundle loaded on one React.Problem and solution fit
Icon/globalIconRegistry.tsxandtheme/themeRegistry.tskeep their registries in module scope, and a swizzled copy carries its own copy of each.icons). A registry shared across two Reacts on one page would let one React render the other's elements, so both registries are one per React (spec:AST-110FR3: state that holds React components or elements is kept one per React).sharedForReactmoves out of the client-onlyutils/sharedContext.tsinto its own server-safe module,utils/sharedForReact.ts, and keys by React'screateElement, which both the client and the server builds export (it had no callers yet). The server and client builds of React are separate module instances, so a server registration and a client registration stay in separate stores, as each module's own state did before.The icon registry →
sharedForReact('icon/global-icon-registry/state', 1, …); the theme registry →sharedForReact('theme/theme-registry/themes', 1, …). The public functions and their behavior within one copy are unchanged. The source-check baseline loses the twoF8entries.Expected behavior and authority
spec:AST-110FR3 (approved,authority: draft).Evidence
theme/registries.shared.test.ts, first commit): a theme registered in one load isnullin a second load on the same React, and an icon registered in one load isundefinedin the other. Both pass after. A third case — a theme and an icon registered on one React, read from a second React on the same page — passes before and after: the second React sees neither, so no React renders another React's elements.sharedContexts.test.tsx's per-React case now loads the moved helper.tscpasses for the source and build configurations.Scope
Components: Icon, CodeBlock, Table, Timestamp (the swizzled copies that carry the icon registry)
Testing
pnpm exec vitest run --project ui packages/core/src/theme packages/core/src/Icon packages/core/src/Indicator packages/core/src/Layer/sharedContexts.test.tsx packages/core/src/utils/sharedRealm.test.tspnpm exec vitest run --project node scripts/shared-identity.test.mjstsc --noEmit -p packages/core(andtsconfig.build.json)