ComponentsAgent patterns

Message Rich Text

Renders the rich text a Chat Input sends, so a sent message looks the way it did in the composer. Apps, tagged agents, skills, and files keep their chips, hints, and previews, and a tagged file opens in the File Viewer.

SourceRegistry JSON

Installation

pnpm dlx shadcn@latest add https://sprout.tulipfarm.ai/r/message-rich-text.json

Copies Message Rich Text and the components it uses (File Viewer, Hover Card, Rich Text Editor, and Tooltip) into your app, installs the packages, and adds the styles. Then import it from @/components/ui/message-rich-text. Needs Tailwind CSS 4 and a components.json from shadcn init.

Usage

A sent messageTSX
import { ChatInput } from "@tulipfarm/sprout/chat-input";
import { MessageRichText } from "@tulipfarm/sprout/message-rich-text";
import { keywordAccounts } from "@tulipfarm/sprout/rich-text-editor";

function send() {
  addMessage({ value, accounts: keywordAccounts(value, integrations) });
}

<MessageBubble variant="secondary">
  <MessageRichText
    value={message.value}
    keywords={integrations}
    accounts={message.accounts}
    resolveReference={({ kind, id }) => lookup(kind, id)}
  />
</MessageBubble>

value is the Chat Input value. keywords takes the same list as Chat Input’sintegrations, so app names become the same chips. Paragraphs, headings, lists, quotes, code blocks, bold, italics, underline, strikethrough, inline code, and links are kept; a link is shown only when it is http, https, ormailto.

Accounts

An app chip names the account it used. Call keywordAccounts(value, integrations) when the message is sent and store the result with it. Pass it back as accounts and the chip keeps that account, even after the person switches accounts or disconnects the app. Without it, chips show the current account, and a disconnected app shows the same warning as the composer.

Agents, skills, and files

Tags keep their @, /, or # prefix. resolveReference returns the tagged item, the same shape as a Chat Input suggestion: media becomes the chip icon, andfile makes a file chip a button that opens the File Viewer. Hovering a CSV, TSV, text, or image file shows a preview. Return nothing for a file that no longer exists and its chip stays plain text. Agents and skills show their description on hover or focus.

Accessibility

Hints open on hover and on keyboard focus, and every chip with a hint can be reached with Tab. A file chip is a button named after the file and opens the viewer with Enter or Space. Chips use the composer’s colours, so their contrast is the same in every theme.