Repository navigation
chore(ChatMessage): give the avatar offset variable a private literal name - #9602
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Changes requested. The rename is right, and the built stylesheet is otherwise unchanged, but derivedVarRegistry.test.ts now fails because --_chat-avatar-offset is not listed in Chat.doc.mjs. To fix it, add a private: true entry for the variable to theming.vars[] in packages/core/src/Chat/Chat.doc.mjs, and add the name with its reason to VARS_WITHOUT_DERIVED_MAPPING in packages/core/src/theme/derivedVarRegistry.test.ts, as --_tree-focus-z does. Optionally, split the long sentence in the reworded chatMessage.vars.stylex.ts comment (see the inline note).
[Automated review]
| */ | ||
| export const chatMessageVars = stylex.defineVars({ | ||
| avatarOffset: '0px', | ||
| '--_chat-avatar-offset': '0px', |
There was a problem hiding this comment.
derivedVarRegistry.test.ts ("Chat: all source vars are in doc file") now sees this literal name, and it fails on this head. Document the variable as private in Chat.doc.mjs theming.vars[]:
{name: '--_chat-avatar-offset', description: 'Top offset of a message avatar: the name row spacing when a bubble in the message shows a name, else 0px. Each message sets it from its own content. Not a theming lever.', default: '0px', private: true},Then add '--_chat-avatar-offset', with its reason, to VARS_WITHOUT_DERIVED_MAPPING in packages/core/src/theme/derivedVarRegistry.test.ts, as --_tree-focus-z does. With both changes the test passes.
| * `--_chat-avatar-offset` is the avatar's top spacing: the name row's spacing | ||
| * when a bubble in this message renders a name, else none. Each article sets | ||
| * it from its own `:has([data-chat-name])`, a parent-relative rule: a | ||
| * sibling-relative `:has(~ …)` in the global stylesheet makes WebKit re-check | ||
| * every earlier sibling on each insertion into any container, so filling one | ||
| * grows quadratically. A message nested in another sets its own value, so it | ||
| * never inherits the outer message's. |
There was a problem hiding this comment.
Non-blocking: the sentence starting "Each article sets it" runs to 35 words and covers several topics. The repository's comment style caps a description sentence at 25 words, with one topic each. A shorter version:
* `--_chat-avatar-offset` is the avatar's top spacing. It is the name row's
* spacing when a bubble in this message shows a name, else 0. Each article
* sets it from its own `:has([data-chat-name])`. A sibling-relative `:has(~ …)`
* in the global stylesheet makes WebKit re-check every earlier sibling on each
* insertion. Filling a container then takes quadratic time. A nested message
* sets its own value and does not inherit the outer one.There was a problem hiding this comment.
Approval recommended. The private name --_chat-avatar-offset leaves the built stylesheet unchanged apart from the variable name, and the new private: true entry in Chat.doc.mjs, with its VARS_WITHOUT_DERIVED_MAPPING reason, fixes the theming-docs test failure from the earlier review. Optionally, the long sentence in the chatMessage.vars.stylex.ts comment can still be split, as the earlier inline note suggests.
[Automated review]
Why
Internal CSS variables are private. ChatMessage's avatar offset is an internal variable, but StyleX hashed its name, so the published stylesheet declares it as a plain
--x…name that looks like a public custom property and appears in the public API report. A private variable uses a--_*name so consumers can tell it is not for them to set or read.What
chatMessage.vars.stylex.ts: the internal variable is now the literal private name--_chat-avatar-offset(StyleX's literal-name form, so nothing is hashed). Its explanatory comment stays, updated to the new name.ChatMessage.tsx: its two references use the new name.Chat.doc.mjs: the variable is listed intheming.varsasprivate: true, like the other private Chat variables, andderivedVarRegistry.test.tslists it as a variable with no derived mapping (content state, not a theming lever).[chore]Changeset.Risk
Low. The variable is internal and not exported from the package entry point. Built CSS is the same rule for rule: only the variable name and the generated class names change.
Testing
@astryxdesign/corebefore and after.astryx.cssnow declares--_chat-avatar-offset(default0px,var(--spacing-5)when the message holds a name row, read by the avatar'smargin-top) and no hashed variable.:has([data-chat-name])rule, and the:has()rule has higher specificity, so the computed avatar offset is the same with and without a name row.vitest run packages/core/src/Chat packages/core/src/theme: 2063 passed.tsc, ESLint, and Prettier clean.CI impact
None. The next API report regeneration drops the hashed variable row.