Repository navigation
refactor(studio): render message avatars with the Avatar primitive - #2351
Merged
Merged
Conversation
Pins the accessible name, fallback icons and colours, and frame size of MessageAvatar, including the loading and failed-picture states. Refs #2338 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
MessageAvatar now builds on Avatar, AvatarImage and AvatarFallback with the same frame, colours, icons and accessible names. The fallback carries the speaker's name while a configured picture loads or after it fails, so the avatar keeps one accessible name in every state. The transcript avatar test stubs an already-loaded Image: happy-dom never loads pictures, and AvatarImage renders only once one has loaded. Closes #2338 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
kantord
approved these changes
Oct 15, 2026
kantord
left a comment
Member
There was a problem hiding this comment.
Thanks for this, the Avatar swap is clean and the accessible name holds in all three states (loading, loaded, failed), and the pixel differences are honestly disclosed. Approving, with a few non-blocking nits:
- The PR text names
chat-workspace.tsxas a caller ofMessageAvatar. That may be stale now that #2322 movedMessageout of it, so it is worth re-checking the description. - The tests stub
window.Image(complete,naturalWidth,EventTarget), which couples them to how Radix Avatar detects image load. Acceptable, but a Radix change could break every picture test. message-bubble.pinning.test.tsxleans on class names. The role and name assertions are the valuable ones.- Worth a quick look in a browser:
AvatarImagerenders nothing until the image has loaded, so a first network load shows the fallback circle for a moment. It is probably invisible for cached images, but I did not run it.
Fully or partially written by an AI agent.
Merged
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Message avatars now use the Avatar primitive (
components/ui/avatar.tsx) instead of a hand-rolled<img>or<span>. This is the Avatar's first call site in Studio. Size, colours, icons, and accessible names stay the same. Six of the eight captures are pixel-identical; the other two differ only in the anti-aliasing of the circle's edge (details under No regression).Closes #2338
Part of #2201
Part of #2210
What changed
features/chat/message-bubble.tsx:MessageAvatarkeeps its props (avatarUrl,fallback,name), so its two callers (chat-transcript.tsxandchat-workspace.tsx, both in other open PRs) don't change.Avatarkeeps thesize-7 lg:size-9frame.size-8is the primitive's default, andtailwind-mergedrops it.AvatarImagerenders it withalt={name}andobject-cover. The Root'soverflow-hidden rounded-fullcrops it to the circle.AvatarFallbackdraws the brand circle with the bot icon for the agent, or the muted circle with the person icon for the user. These are the same classes and icons as before.aria-hidden, as the old<span>was. The author line beside it already names the speaker.features/chat/transcript-alignment.test.tsx: one existing test changed. The reason is under No regression.The prototype (
stack-08,features/chat/message-bubble.tsx) also hand-rolls this avatar, as a localAvatarfunction. The frame, colours, and icons here match it.Behaviour differences
These come from the primitive's standard behaviour. Neither affects the captured surfaces:
In both states the fallback has
role="img"andaria-label={name}, so the avatar keeps the speaker's name as its accessible name, as the old<img alt>did.No regression
Pins first (
59454e715, passing on the unchanged code and unchanged after the swap).message-bubble.pinning.test.tsxhas 5 tests:aria-hiddenand noimgrole when no picture is configured;<img>named after the speaker, with itssrc, cropped round;The class checks read the whole avatar subtree, so they hold whether the frame and the colours sit on one element or on a Root and its Fallback.
Modified test, justified:
transcript-alignment.test.tsx› "shows the configured avatars beside each speaker" readsrcsynchronously. happy-dom never loads images, andAvatarImagerenders only after the image loads. The test now stubs an already-loadedImagewithvi.stubGlobaland waits for both images. Every assertion is unchanged, and the test passes on the old code too.Mutation proof. Each mutation was applied alone and the focused tests rerun. Every one fails at least one test:
aria-hiddenwhen no picture is configuredsize-8AvatarImageremovedalt=""on the imagePixels: 8 captures (2 states × desktop and 390px × light and dark), with a second Before capture as the noise floor.
pixel-report.txtin the asset folder has the counts.overflow-hidden rounded-fullclipping a Fallback that is itselfrounded-full. The composites box it in red.Base check: the pins and the modified transcript test pass on the code from
59454e715(24/24) and on the head.Screenshots
Before is
origin/main(1210721be), After is this branch (6412e7fcf), and Prototype isstack-08. Red boxes mark pixels that differ between Before and After. After matches the prototype's frame, colours and icons; the prototype's transcript has no configured pictures, so its column shows the fallback in both states.Fallback avatars, desktop, light (the boxed avatar is the edge anti-aliasing difference described above)
Configured pictures, desktop, light (identical)
Desktop dark and 390px, light and dark
Fallback avatars, desktop, dark (edge anti-aliasing only):
Configured pictures, desktop, dark (identical):
Fallback avatars, 390px, light and dark (identical):
Configured pictures, 390px, light and dark (identical):
Gates
On the head rebased onto
origin/main(1210721be):task studio:check: passed. Web 1493 tests in 172 files, server 210 tests in 26 files.task studio:browser: passed. 124 passed, 30 skipped.🤖 Generated with Claude Code