feat(chat): fork ChatMessage into a local sandbox-ui component#47
feat(chat): fork ChatMessage into a local sandbox-ui component#47vutuanlinh2k2 wants to merge 1 commit into
Conversation
Stop re-exporting ChatMessage from @tangle-network/ui/chat and provide a local implementation in src/chat/chat-message.tsx instead. This lets sandbox-ui own the component's markup and styling independently of the upstream package. The local component is styled with inline Tailwind utilities backed by CSS-variable theming tokens (radius/font/avatar/accent), so it needs no companion globals.css rules. It supports user/assistant/system roles, optional avatar (default or custom), role label + timestamp, markdown rendering for assistant content, a streaming cursor, and a tool-calls slot. chat/index.ts now sources ChatMessage, ChatMessageProps, and MessageRole locally while continuing to re-export the rest of the chat surface from @tangle-network/ui/chat. The re-export identity test is updated: since ChatMessage is no longer forwarded, the identity assertion is replaced with a presence check that sandbox-ui provides its own ChatMessage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
✅ No Blockers —
|
tangletools
left a comment
There was a problem hiding this comment.
✅ Approved — 2 non-blocking findings — 701c8627
I read all three changed files, the upstream source in node_modules/@tangle-network/ui/src/chat/chat-message.tsx, and verified build + 292 passing tests. The new ChatMessage is a near-identical fork of the upstream component with valid CSS fallbacks and a welcome aria-hidden improvement, but it introduces a minor timestamp styling regression. Missing JSDoc on props and the absence of component-lev
Full findings and scores: review summary
tangletools · 2026-05-22T06:27:49Z · trace
Summary
Stops re-exporting
ChatMessagefrom@tangle-network/ui/chatand provides a local implementation insrc/chat/chat-message.tsx. This givessandbox-uiownership of the component's markup and styling, independent of the upstream@tangle-network/uipackage, while the rest of the chat surface continues to be re-exported from upstream.What changed
src/chat/chat-message.tsx— a self-containedChatMessagecomponent:user/assistant/systemroles (user messages mirror layout to the right).User/Boticons or a caller-suppliedavatarnode; can be hidden viahideAvatar.userLabel/assistantLabel, defaults"You"/"Agent") + optionaltimestamp, both hideable viahideRoleLabel.Markdown; user content rendered as pre-wrapped plain text.isStreamingis set, plus atoolCallsslot.src/chat/index.ts—ChatMessage,ChatMessageProps, andMessageRolenow come from the local module; all other chat exports (ChatContainer,ChatInput,MessageList,ThinkingIndicator,UserMessage, etc.) still forward to@tangle-network/ui/chat.src/__tests__/re-export-identity.test.ts— sinceChatMessageis no longer a forwarded re-export, its identity assertion against the upstream component is removed and replaced with a presence check thatsandbox-uiprovides its ownChatMessage.Styling approach
The component uses inline Tailwind utility classes backed by CSS-variable theming tokens (
--radius-*,--font-size-*,--avatar-size,--accent-*,--brand-cool,--chat-message-*), each with sensible fallbacks. As a result it needs no companionglobals.cssrules — there are no stylesheet changes in this PR.Testing
npx vitest run src/__tests__/re-export-identity.test.ts→ 13 passed.🤖 Generated with Claude Code