Repository navigation
Closed
Description
Render one message and its surroundings as small composable parts: author, time, content, delivery state, actions, reactions and replies.
Part of #94.
Why
A chat message carries more than text: who wrote it, when, whether it was delivered, actions, reactions and replies. Small parts let each app choose what to show, and markdown stays the host's choice through a render prop.
What
src/ui/message.tsx:Message(from: agent, person or own;status;onRetry),MessageAvatar,MessageHeader,MessageContent(therenderprop for markdown),MessageFooter. The own-message bubble is built here.src/ui/message-fold.tsx:MessageFold, which folds a long answer.src/ui/message-actions.tsx:MessageActions,MessageAction, and an overflow menu for extras.src/ui/message-reactions.tsx:MessageReactions.src/ui/message-replies.tsx:MessageReplies(count, and last reply time viarelative-time.ts).src/hooks/use-copy.ts:useCopy.stories/chat/message.stories.tsx: agent, person, own, no avatars, actions, reactions, replies, sending, failed and a very long answer, using the shared samples from Add sample conversations for the chat stories #96.e2e/fixtures.tsx: scenarios for the fold and the overflow menu, withe2e/message.spec.ts.src/hooks/use-copy.test.ts,src/ui/message.test.tsx,src/ui/message-fold.test.tsx; exports insrc/index.ts.
Requirements
- R16:
Messagewith avatar, header, content (onerenderslot, no separate response part) and footer; own messages in a bubble; avatars and names optional. - R17:
MessageFoldfolds past a length threshold and keeps the reader's place when folding from inside. - R18: actions with an overflow menu, reactions, replies, and
useCopy. - R19:
sendingshows it is on its way;failedshows the error and a retry that callsonRetry. - R5–R12: the shared component rules.
Constraints
- Reuse the existing
AvatarandButton. The oldMessageBubblestays until Remove the old chat components #110. - No bubble on agent replies when avatar and header are left out; own messages sit in a bubble on the right.
- The overflow menu doesn't import
ui/menu; build it onuseDismissablePopover. MessageFoldkeeps the reader's place with its own measurement (scroll the nearest scroll container by the height delta). It doesn't importuseConversationor need aConversationancestor.- The shared rules in Replace the chat components with a stateless Conversation family #94 apply: no new dependency or peer, no optional-peer import, token-only styling, no change to existing modules, additions only to
src/index.tsande2e/fixtures.tsx.
Done when
- Unit tests cover:
useCopy:copiedturns on after copy and off after the timeout; the timer is cleared on unmount; a rejected clipboard write leavescopiedfalse.MessageFold: under the threshold there is no toggle; over it, it folds by default and toggles; streaming content never folds.Message:sendingshows its state;failedshows the error and a retry control that callsonRetryonce;MessageContentpasses its text throughrender.
- Browser spec covers:
- Folding
MessageFoldfrom inside the folded answer keeps the fold control at the same viewport offset (±1px). - The overflow menu opens from the keyboard, arrow keys move between items, Escape closes it and focus returns to the trigger.
- Folding
- No serious or critical axe violation in the new stories, in light or dark.
bun run check,bun run build,bun run test:e2eandbun run dep-guardpass.
Metadata
Metadata
Assignees
Labels
No labels
Activity