# Conversation

Show a conversation with participant names, grouped messages, and earlier history.

## Preview

conversation-preview-1.jsx

```jsx
import { Fragment } from "react";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import { ActivityTitle } from "@/components/ui/activity";
import { MessageSender } from "@/components/ui/message-sender";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const items = [
    message(
      "review-own",
      "user",
      "Can you confirm the retry check before we send the rollout note?",
      0,
      {
        id: "rina",
        name: "Rina",
        kind: "human",
      },
    ),
    message(
      "review-human",
      "user",
      "The patch is in staging. Priya is checking the final run now.",
      1,
      {
        id: "marta",
        name: "Marta Chen",
        kind: "human",
      },
    ),
    {
      ...message(
        "review-agent",
        "assistant",
        "The retry check is the remaining launch risk. Priya owns the fix; wait for her confirmation before sending the note.",
        2,
        {
          id: "launch-analyst",
          name: "Launch analyst",
          kind: "agent",
        },
      ),
      parts: [
        {
          type: "activity",
          id: "review-work",
          event: {
            id: "review-check",
            kind: "review",
            state: "complete",
            label: "Checked the retry status",
            description:
              "Staging is ready; the final retry confirmation is still pending.",
          },
        },
        {
          type: "text",
          text: "The retry check is the remaining launch risk. Priya owns the fix; wait for her confirmation before sending the note.",
        },
      ],
    },
  ];
  return (
    <div data-preview-wide>
      <Conversation
        label="Launch review"
        currentUserId="rina"
        participants={REVIEW_PARTICIPANTS}
      >
        <ConversationContent>
          {items.map((item) => (
            <ConversationItem key={item.id} id={item.id} message={item}>
              <ConversationMessageView
                item={item}
                renderActivityLabel={activitySpeaker}
              />
            </ConversationItem>
          ))}
        </ConversationContent>
      </Conversation>
    </div>
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

var REVIEW_PARTICIPANTS = [
  {
    id: "rina",
    name: "Rina",
    kind: "human",
  },
  {
    id: "marta",
    name: "Marta Chen",
    kind: "human",
  },
  {
    id: "launch-analyst",
    name: "Launch analyst",
    kind: "agent",
  },
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function activitySpeaker(label) {
  return <MessageHeader render={<ActivityTitle />}>{label}</MessageHeader>;
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ConversationMessageView({ renderActivityLabel, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      identity={messageIdentity(props.item, renderActivityLabel)}
      renderTimestamp={messageTimestamp}
    />
  );
}

```

## Design guidance

Pass the current user and participant list to Conversation. It uses them to group messages and decide when to show names, avatars, and actions. Use [Message](/ai-elements/message#presentation) to style a single turn and [Message actions](/ai-elements/message-actions#conversation-defaults) for commands and receipts. Your app supplies the roster, saved history, and transport.

A complete roster needs unique, non-empty IDs and valid participant kinds. It must include a human current user and the author of the message being rendered. With an incomplete roster, Conversation uses fallback presentation. A matching currentUserId and author ID can still identify your own message.

In a two-person conversation with two humans, Conversation hides repeated identities for both people. Explicit Message or part props override these defaults.

### Context defaults

| Supplied roster | Identity and item surface | Commands and supplied metadata |
| --- | --- | --- |
| One human + one agent | Own human right/subtle, no identity; agent left/plain, no redundant identity. | Supplied agent time and citations persist. Own-human commands and metadata reveal on interaction. |
| Humans only | Own human right/subtle; other humans left/subtle alternative. Omit both identities in a two-human conversation; show remote identities at group starts in a larger human group. | Supplied human time and valid delivery persist in the footer; reactions persist. Conversation supplies participant defaults while Message owns the presentation. Commands use interaction or context-menu access. |
| Multiple humans + one agent | Own human has no identity; remote humans and the agent are identified at group starts; agent is left/plain. | Supplied human/agent time, valid human delivery and agent citations persist; commands reveal. |
| One human + multiple agents | Own human has no identity; agents are left/plain and individually identified at group starts. | Supplied human/agent time and agent citations persist; commands reveal. |
| Multiple humans + multiple agents | Own human has no identity; remote senders are identified at group starts; agent is left/plain. | Human/agent time, valid human delivery and agent citations persist; commands reveal. |

**Also known as**

Thread.

## Installation

```sh
npx shadcn@latest add https://ghost-ui.com/r/conversation.json
```

```text
src/components/ui/chat-model.ts
src/components/ui/message.tsx
src/components/ui/message.css
src/components/ui/conversation.tsx
src/components/ui/conversation.css
src/components/ui/conversation-grouping.ts
src/components/ui/message-scroller.tsx
```

## Basic usage

Provide a stable row ID for each ConversationItem. Supply message, currentUserId, and a complete participants roster only when those facts are authoritative.

```tsx
import { Conversation, ConversationContent, ConversationItem } from "@/components/ui/conversation";

export function ConversationExample() {
  return (
    <Conversation aria-label="Support conversation">
      <ConversationContent>
        <ConversationItem id="message-1">Receipt found.</ConversationItem>
      </ConversationContent>
    </Conversation>
  );
}
```

Keep message records and callbacks in the consuming application. Use [Message scroller](/ai-elements/message-scroller) when the application owns row rendering and needs only the shared viewport behavior.

## Structures

- Conversation
  - ConversationContent
    - ConversationItem (one stable transcript row)
    - ConversationEmpty (optional)
    - ConversationStatus (optional)
  - ConversationScrollButton (optional viewport control)

Conversation composes one scroller and orders stable rows. Its default Preview is a three-message, two-human/one-agent roster: the current user has no repeated identity, the other human uses the human Avatar, and the agent Activity carries its sender identity. Message body parts and action controls remain caller-composed. When an Activity part is present, Conversation passes the same MessageHeader identity into its summary; one-to-one context hides that identity while preserving event, model, and duration details.

## Examples

Context examples come first so sender defaults are visible before reading and history behavior.

### One human and one agent

Keep the full established agent toolbar while omitting redundant one-to-one identities.

conversation-one-human-and-one-agent-2.jsx

```jsx
import { Fragment, useState } from "react";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import { ActivityTitle } from "@/components/ui/activity";
import {
  MessageActions,
  MessageActionMenu,
} from "@/components/ui/message-actions";
import { MessageSender } from "@/components/ui/message-sender";
import { CitationList, CitationProvider } from "@/components/ui/citation";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const participants = [
    {
      id: "rina",
      name: "Rina",
      kind: "human",
    },
    {
      id: "support",
      name: "Support agent",
      kind: "agent",
    },
  ];
  const [vote, setVote] = useState(null);
  const [feedback, setFeedback] = useState("");
  const items = [
    message(
      "dm-user",
      "user",
      "Can you check the delivery estimate?",
      20,
      participants[0],
    ),
    {
      ...message(
        "dm-agent",
        "assistant",
        "The carrier expects it before 8 PM.",
        21,
        participants[1],
      ),
      parts: [
        {
          type: "activity",
          id: "carrier-check",
          event: {
            id: "carrier-check",
            kind: "lookup",
            state: "complete",
            label: "Checked carrier updates",
            meta: "14s",
            description: "The latest estimate remains before 8 PM.",
          },
        },
        {
          type: "text",
          text: "The carrier expects it before 8 PM.",
        },
        {
          type: "source",
          id: "delivery-policy",
          source: {
            id: "delivery-policy",
            type: "document",
            title: "Delivery policy",
            document: {
              name: "delivery-policy.md",
            },
          },
        },
      ],
    },
  ];
  const download = () => {
    const url = URL.createObjectURL(
      new Blob(["The carrier expects it before 8 PM."], {
        type: "text/plain",
      }),
    );
    const link = document.createElement("a");
    link.href = url;
    link.download = "delivery-estimate.txt";
    link.click();
    URL.revokeObjectURL(url);
  };
  const share = async () => {
    if (!navigator.share) {
      setFeedback("Sharing is unavailable.");
      return;
    }
    try {
      await navigator.share({
        text: "The carrier expects it before 8 PM.",
      });
    } catch {
      setFeedback("Sharing was cancelled.");
    }
  };
  return (
    <div data-preview-wide>
      <Conversation
        label="One-to-one support conversation"
        currentUserId="rina"
        participants={participants}
      >
        <ConversationContent>
          {items.map((item) => (
            <ConversationItem key={item.id} id={item.id} message={item}>
              <ActionConversationMessageView
                item={item}
                renderTimestamp={messageTimestamp}
                renderActivityLabel={activitySpeaker}
                actions={
                  item.actor === "assistant"
                    ? {
                        vote,
                        onVote: setVote,
                        onShare: () => void share(),
                        onDownload: download,
                      }
                    : undefined
                }
              />
            </ConversationItem>
          ))}
        </ConversationContent>
      </Conversation>
      <span className="ui-sr-only" role="status">
        {feedback}
      </span>
    </div>
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function activitySpeaker(label) {
  return <MessageHeader render={<ActivityTitle />}>{label}</MessageHeader>;
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ActionConversationMessageFrame({ actions, sources, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      renderActions={
        actions || sources
          ? (text, timestamp) => (
              <MessageActions
                text={text}
                {...actions}
                timestamp={timestamp}
                metadataPlacement={actions?.metadataPlacement ?? "inline"}
                sources={sources}
              />
            )
          : undefined
      }
      renderMenu={
        actions
          ? (text, content) => (
              <MessageActionMenu text={text} {...actions}>
                {content}
              </MessageActionMenu>
            )
          : undefined
      }
    />
  );
}

function ActionConversationMessageView({
  item,
  renderActivityLabel,
  ...props
}) {
  const sources = item.parts.flatMap((part) =>
    part.type === "source" ? [part.source] : [],
  );
  return (
    <ActionConversationMessageFrame
      {...props}
      item={item}
      identity={messageIdentity(item, renderActivityLabel)}
      sources={
        sources.length ? (
          <CitationProvider sources={sources} mode="provided">
            <CitationList mode="provided" />
          </CitationProvider>
        ) : undefined
      }
    />
  );
}

```

### Humans only

Show remote-human identity at group starts and supplied time or valid delivery at rest. In a two-human conversation, omit both repeated identities.

conversation-humans-only-3.jsx

```jsx
import {
  Conversation,
  ConversationContent,
  ConversationItem,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import { MessageSender } from "@/components/ui/message-sender";

export default function Example() {
  const participants = [
    ...REVIEW_PARTICIPANTS,
    {
      id: "leon",
      name: "Leon",
      kind: "human",
    },
  ];
  const items = [
    message(
      "group-marta",
      "user",
      "I own regional coverage.",
      22,
      participants[1],
    ),
    message(
      "group-rina",
      "user",
      "I will confirm the decision after staging passes.",
      23,
      participants[0],
    ),
    message(
      "group-leon",
      "user",
      "I can prepare the support handoff.",
      24,
      participants[3],
    ),
  ];
  return (
    <div data-preview-wide>
      <Conversation
        label="Launch review group"
        currentUserId="rina"
        participants={participants}
      >
        <ConversationContent>
          {items.map((item) => (
            <ConversationItem key={item.id} id={item.id} message={item}>
              <Message actor="user" senderId={item.author?.id}>
                <MessageAvatar>
                  <MessageSender
                    name={item.author?.name}
                    kind="human"
                    seed={item.author?.id}
                    showName={false}
                  />
                </MessageAvatar>
                <MessageContent>
                  <MessageHeader>{item.author?.name}</MessageHeader>
                  <MessageBody>
                    {item.parts.map((part) =>
                      part.type === "text" ? part.text : null,
                    )}
                    {messageTimestamp(new Date(item.createdAt), true)}
                  </MessageBody>
                </MessageContent>
              </Message>
            </ConversationItem>
          ))}
        </ConversationContent>
      </Conversation>
    </div>
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

var REVIEW_PARTICIPANTS = [
  {
    id: "rina",
    name: "Rina",
    kind: "human",
  },
  {
    id: "marta",
    name: "Marta Chen",
    kind: "human",
  },
  {
    id: "launch-analyst",
    name: "Launch analyst",
    kind: "agent",
  },
];

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

```

### Multiple humans and one agent

Human metadata and the agent's supplied citations/time persist, while the agent commands reveal on interaction.

conversation-multiple-humans-and-one-agent-4.jsx

```jsx
import { Fragment, useState } from "react";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import {
  MessageActions,
  MessageActionMenu,
} from "@/components/ui/message-actions";
import { MessageSender } from "@/components/ui/message-sender";
import { CitationList, CitationProvider } from "@/components/ui/citation";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const participants = [
    {
      id: "rina",
      name: "Rina",
      kind: "human",
    },
    {
      id: "marta",
      name: "Marta Chen",
      kind: "human",
    },
    {
      id: "leon",
      name: "Leon",
      kind: "human",
    },
    {
      id: "launch-analyst",
      name: "Launch analyst",
      kind: "agent",
    },
  ];
  const items = [
    message(
      "human-agent-rina",
      "user",
      "Keep the rollout paused until regional coverage is confirmed.",
      34,
      participants[0],
    ),
    message(
      "human-agent-marta",
      "user",
      "Coverage is confirmed for the first cohort.",
      35,
      participants[1],
    ),
    {
      ...message(
        "human-agent-launch",
        "assistant",
        "The retry check passed; the release runbook is ready.",
        36,
        participants[3],
      ),
      parts: [
        {
          type: "text",
          text: "The retry check passed; the release runbook is ready.",
        },
        {
          type: "source",
          id: "human-agent-runbook",
          source: {
            id: "human-agent-runbook",
            type: "document",
            title: "Release runbook",
            document: {
              name: "release-runbook.md",
            },
          },
        },
      ],
    },
  ];
  return (
    <ConversationContextExample
      label="Multi-human review with one agent"
      currentUserId="rina"
      participants={participants}
      items={items}
    />
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ActionConversationMessageFrame({ actions, sources, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      renderActions={
        actions || sources
          ? (text, timestamp) => (
              <MessageActions
                text={text}
                {...actions}
                timestamp={timestamp}
                metadataPlacement={actions?.metadataPlacement ?? "inline"}
                sources={sources}
              />
            )
          : undefined
      }
      renderMenu={
        actions
          ? (text, content) => (
              <MessageActionMenu text={text} {...actions}>
                {content}
              </MessageActionMenu>
            )
          : undefined
      }
    />
  );
}

function ActionConversationMessageView({
  item,
  renderActivityLabel,
  ...props
}) {
  const sources = item.parts.flatMap((part) =>
    part.type === "source" ? [part.source] : [],
  );
  return (
    <ActionConversationMessageFrame
      {...props}
      item={item}
      identity={messageIdentity(item, renderActivityLabel)}
      sources={
        sources.length ? (
          <CitationProvider sources={sources} mode="provided">
            <CitationList mode="provided" />
          </CitationProvider>
        ) : undefined
      }
    />
  );
}

function ConversationContextExample({
  label,
  items,
  currentUserId,
  participants,
}) {
  const [vote, setVote] = useState(null);
  const [feedback, setFeedback] = useState("");
  const actionsForAgent = (text) => ({
    vote,
    onVote: setVote,
    onShare: async () => {
      if (!navigator.share) {
        setFeedback("Sharing is unavailable.");
        return;
      }
      try {
        await navigator.share({
          text,
        });
      } catch {
        setFeedback("Sharing was cancelled.");
      }
    },
    onDownload: () => {
      const url = URL.createObjectURL(
        new Blob([text], {
          type: "text/plain",
        }),
      );
      const link = document.createElement("a");
      link.href = url;
      link.download = "conversation-reply.txt";
      link.click();
      URL.revokeObjectURL(url);
    },
  });
  return (
    <div data-preview-wide>
      <Conversation
        label={"Multi-human review with one agent"}
        currentUserId={"rina"}
        participants={participants}
      >
        <ConversationContent>
          {items.map((item) => (
            <ConversationItem key={item.id} id={item.id} message={item}>
              <ActionConversationMessageView
                item={item}
                renderTimestamp={messageTimestamp}
                actions={
                  item.actor === "assistant"
                    ? actionsForAgent(
                        item.parts
                          .flatMap((part) =>
                            part.type === "text" ? [part.text] : [],
                          )
                          .join("\n"),
                      )
                    : undefined
                }
              />
            </ConversationItem>
          ))}
        </ConversationContent>
      </Conversation>
      <span className="ui-sr-only" role="status">
        {feedback}
      </span>
    </div>
  );
}

```

### One human and multiple agents

Supplied timestamps and agent citations stay visible. Commands appear on hover, focus or touch. The footer reads left to right: timestamp, actions, then citations.

conversation-one-human-and-multiple-agents-5.jsx

```jsx
import { Fragment, useState } from "react";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import {
  MessageActions,
  MessageActionMenu,
} from "@/components/ui/message-actions";
import { MessageSender } from "@/components/ui/message-sender";
import { CitationList, CitationProvider } from "@/components/ui/citation";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const participants = [
    {
      id: "rina",
      name: "Rina",
      kind: "human",
    },
    {
      id: "launch-analyst",
      name: "Launch analyst",
      kind: "agent",
    },
    {
      id: "risk-reviewer",
      name: "Risk reviewer",
      kind: "agent",
    },
  ];
  const items = [
    message(
      "multi-rina",
      "user",
      "Review the rollout before we expand access.",
      25,
      participants[0],
    ),
    {
      ...message(
        "multi-launch",
        "assistant",
        "The retry check is the remaining blocker.",
        26,
        participants[1],
      ),
      parts: [
        {
          type: "text",
          text: "The retry check is the remaining blocker.",
        },
        {
          type: "source",
          id: "multi-runbook",
          source: {
            id: "multi-runbook",
            type: "document",
            title: "Release runbook",
            document: {
              name: "release-runbook.md",
            },
          },
        },
      ],
    },
    {
      ...message(
        "multi-risk",
        "assistant",
        "Keep the rollout paused until the error-rate sample is complete.",
        27,
        participants[2],
      ),
      parts: [
        {
          type: "text",
          text: "Keep the rollout paused until the error-rate sample is complete.",
        },
        {
          type: "source",
          id: "multi-risk-sample",
          source: {
            id: "multi-risk-sample",
            type: "document",
            title: "Error-rate sample",
            document: {
              name: "error-rate-sample.csv",
            },
          },
        },
      ],
    },
  ];
  return (
    <ConversationContextExample
      label="Multi-agent launch review"
      currentUserId="rina"
      participants={participants}
      items={items}
    />
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ActionConversationMessageFrame({ actions, sources, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      renderActions={
        actions || sources
          ? (text, timestamp) => (
              <MessageActions
                text={text}
                {...actions}
                timestamp={timestamp}
                metadataPlacement={actions?.metadataPlacement ?? "inline"}
                sources={sources}
              />
            )
          : undefined
      }
      renderMenu={
        actions
          ? (text, content) => (
              <MessageActionMenu text={text} {...actions}>
                {content}
              </MessageActionMenu>
            )
          : undefined
      }
    />
  );
}

function ActionConversationMessageView({
  item,
  renderActivityLabel,
  ...props
}) {
  const sources = item.parts.flatMap((part) =>
    part.type === "source" ? [part.source] : [],
  );
  return (
    <ActionConversationMessageFrame
      {...props}
      item={item}
      identity={messageIdentity(item, renderActivityLabel)}
      sources={
        sources.length ? (
          <CitationProvider sources={sources} mode="provided">
            <CitationList mode="provided" />
          </CitationProvider>
        ) : undefined
      }
    />
  );
}

function ConversationContextExample({
  label,
  items,
  currentUserId,
  participants,
}) {
  const [vote, setVote] = useState(null);
  const [feedback, setFeedback] = useState("");
  const actionsForAgent = (text) => ({
    vote,
    onVote: setVote,
    onShare: async () => {
      if (!navigator.share) {
        setFeedback("Sharing is unavailable.");
        return;
      }
      try {
        await navigator.share({
          text,
        });
      } catch {
        setFeedback("Sharing was cancelled.");
      }
    },
    onDownload: () => {
      const url = URL.createObjectURL(
        new Blob([text], {
          type: "text/plain",
        }),
      );
      const link = document.createElement("a");
      link.href = url;
      link.download = "conversation-reply.txt";
      link.click();
      URL.revokeObjectURL(url);
    },
  });
  return (
    <div data-preview-wide>
      <Conversation
        label={"Multi-agent launch review"}
        currentUserId={"rina"}
        participants={participants}
      >
        <ConversationContent>
          {items.map((item) => (
            <ConversationItem key={item.id} id={item.id} message={item}>
              <ActionConversationMessageView
                item={item}
                renderTimestamp={messageTimestamp}
                actions={
                  item.actor === "assistant"
                    ? actionsForAgent(
                        item.parts
                          .flatMap((part) =>
                            part.type === "text" ? [part.text] : [],
                          )
                          .join("\n"),
                      )
                    : undefined
                }
              />
            </ConversationItem>
          ))}
        </ConversationContent>
      </Conversation>
      <span className="ui-sr-only" role="status">
        {feedback}
      </span>
    </div>
  );
}

```

### Multiple humans and agents

Keep each remote sender distinct, human delivery truthful, and supplied agent citations visible. The default renderer keeps supplied timestamps for humans and agents in the footer. Read left to right for every alignment: human timestamp, delivery icon, commands, saved reactions; agent timestamp, commands, citations. Missing time or delivery data is not inferred.

conversation-multiple-humans-and-agents-6.jsx

```jsx
import { Fragment, useState } from "react";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import {
  MessageActions,
  MessageActionMenu,
} from "@/components/ui/message-actions";
import { MessageSender } from "@/components/ui/message-sender";
import { CitationList, CitationProvider } from "@/components/ui/citation";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const participants = [
    {
      id: "rina",
      name: "Rina",
      kind: "human",
    },
    {
      id: "marta",
      name: "Marta Chen",
      kind: "human",
    },
    {
      id: "launch-analyst",
      name: "Launch analyst",
      kind: "agent",
    },
    {
      id: "risk-reviewer",
      name: "Risk reviewer",
      kind: "agent",
    },
  ];
  const items = [
    message(
      "multi-party-rina",
      "user",
      "Review the rollout and keep staging on hold until the owners confirm.",
      30,
      participants[0],
    ),
    message(
      "multi-party-marta",
      "user",
      "I\u2019ll confirm regional coverage before the review.",
      31,
      participants[1],
    ),
    {
      ...message(
        "multi-party-analyst",
        "assistant",
        "The retry check is the remaining blocker; Priya owns the next update.",
        32,
        participants[2],
      ),
      parts: [
        {
          type: "text",
          text: "The retry check is the remaining blocker; Priya owns the next update.",
        },
        {
          type: "source",
          id: "group-runbook",
          source: {
            id: "group-runbook",
            type: "document",
            title: "Release runbook",
            document: {
              name: "release-runbook.md",
            },
          },
        },
      ],
    },
    {
      ...message(
        "multi-party-risk",
        "assistant",
        "Keep the rollout paused until the error-rate sample is complete.",
        33,
        participants[3],
      ),
      parts: [
        {
          type: "text",
          text: "Keep the rollout paused until the error-rate sample is complete.",
        },
        {
          type: "source",
          id: "group-status",
          source: {
            id: "group-status",
            type: "document",
            title: "Error-rate sample",
            document: {
              name: "error-rate-sample.csv",
            },
          },
        },
      ],
    },
  ];
  return (
    <ConversationContextExample
      label="Multi-human, multi-agent launch review"
      currentUserId="rina"
      participants={participants}
      items={items}
    />
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ActionConversationMessageFrame({ actions, sources, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      renderActions={
        actions || sources
          ? (text, timestamp) => (
              <MessageActions
                text={text}
                {...actions}
                timestamp={timestamp}
                metadataPlacement={actions?.metadataPlacement ?? "inline"}
                sources={sources}
              />
            )
          : undefined
      }
      renderMenu={
        actions
          ? (text, content) => (
              <MessageActionMenu text={text} {...actions}>
                {content}
              </MessageActionMenu>
            )
          : undefined
      }
    />
  );
}

function ActionConversationMessageView({
  item,
  renderActivityLabel,
  ...props
}) {
  const sources = item.parts.flatMap((part) =>
    part.type === "source" ? [part.source] : [],
  );
  return (
    <ActionConversationMessageFrame
      {...props}
      item={item}
      identity={messageIdentity(item, renderActivityLabel)}
      sources={
        sources.length ? (
          <CitationProvider sources={sources} mode="provided">
            <CitationList mode="provided" />
          </CitationProvider>
        ) : undefined
      }
    />
  );
}

function ConversationContextExample({
  label,
  items,
  currentUserId,
  participants,
}) {
  const [vote, setVote] = useState(null);
  const [feedback, setFeedback] = useState("");
  const actionsForAgent = (text) => ({
    vote,
    onVote: setVote,
    onShare: async () => {
      if (!navigator.share) {
        setFeedback("Sharing is unavailable.");
        return;
      }
      try {
        await navigator.share({
          text,
        });
      } catch {
        setFeedback("Sharing was cancelled.");
      }
    },
    onDownload: () => {
      const url = URL.createObjectURL(
        new Blob([text], {
          type: "text/plain",
        }),
      );
      const link = document.createElement("a");
      link.href = url;
      link.download = "conversation-reply.txt";
      link.click();
      URL.revokeObjectURL(url);
    },
  });
  return (
    <div data-preview-wide>
      <Conversation
        label={"Multi-human, multi-agent launch review"}
        currentUserId={"rina"}
        participants={participants}
      >
        <ConversationContent>
          {items.map((item) => (
            <ConversationItem key={item.id} id={item.id} message={item}>
              <ActionConversationMessageView
                item={item}
                renderTimestamp={messageTimestamp}
                actions={
                  item.actor === "assistant"
                    ? actionsForAgent(
                        item.parts
                          .flatMap((part) =>
                            part.type === "text" ? [part.text] : [],
                          )
                          .join("\n"),
                      )
                    : undefined
                }
              />
            </ConversationItem>
          ))}
        </ConversationContent>
      </Conversation>
      <span className="ui-sr-only" role="status">
        {feedback}
      </span>
    </div>
  );
}

```

### Reading, stream, and history

Start with history without following future output.

conversation-reading-stream-and-history-7.jsx

```jsx
import { Fragment } from "react";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
  ConversationScrollButton,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import { MessageSender } from "@/components/ui/message-sender";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  return (
    <div data-preview-wide>
      <Transcript
        items={BASIC_MESSAGES}
        initialPosition="start"
        follow="never"
      />
    </div>
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

var SUPPORT_PARTICIPANTS = [
  {
    id: "rina",
    name: "Rina",
    kind: "human",
  },
  {
    id: "support",
    name: "Support",
    kind: "agent",
  },
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ConversationMessageView({ renderActivityLabel, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      identity={messageIdentity(props.item, renderActivityLabel)}
      renderTimestamp={messageTimestamp}
    />
  );
}

function Transcript({
  items,
  initialPosition = "end",
  follow = "when-at-end",
  children,
  announcement,
}) {
  return (
    <Conversation
      label="Support conversation"
      initialPosition={"start"}
      follow={"never"}
      announcement={undefined}
      currentUserId="rina"
      participants={SUPPORT_PARTICIPANTS}
    >
      <ConversationContent>
        {items.map((item) => (
          <ConversationItem key={item.id} id={item.id} message={item}>
            <ConversationMessageView item={item} />
          </ConversationItem>
        ))}
        {undefined}
      </ConversationContent>
      <ConversationScrollButton />
    </Conversation>
  );
}

```

#### Stream and stop

Stop generation without removing the partial assistant item. Message status names the state; Conversation owns the stop/follow interaction.

conversation-stream-and-stop-8.jsx

```jsx
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
  ConversationScrollButton,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import { MessageSender } from "@/components/ui/message-sender";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const [phase, setPhase] = useState("idle");
  const [chunkCount, setChunkCount] = useState(0);
  const timer = useRef(undefined);
  const run = useRef(0);
  const streamChunks = [
    "I am checking the receipt details",
    "\nThe total is confirmed now.",
    "\nThe receipt is ready to send.",
  ];
  const streamText = streamChunks.slice(0, chunkCount).join("");
  useEffect(
    () => () => {
      run.current += 1;
      if (timer.current) window.clearTimeout(timer.current);
    },
    [],
  );
  useEffect(() => {
    if (
      phase !== "streaming" ||
      chunkCount === 0 ||
      chunkCount >= streamChunks.length
    )
      return;
    const currentRun = run.current;
    timer.current = window.setTimeout(() => {
      if (currentRun !== run.current) return;
      setChunkCount((value) => {
        const next = Math.min(streamChunks.length, value + 1);
        if (next >= streamChunks.length) setPhase("complete");
        return next;
      });
    }, 420);
    return () => {
      if (timer.current) window.clearTimeout(timer.current);
    };
  }, [chunkCount, phase, streamChunks.length]);
  const items = useMemo(
    () => [
      ...BASIC_MESSAGES,
      ...(chunkCount > 0
        ? [
            message("streaming", "assistant", streamText, 2, {
              id: "support",
            }),
          ]
        : []),
    ],
    [chunkCount, streamText],
  );
  return (
    <div data-preview-wide>
      <Transcript
        items={items.map((item) =>
          item.id === "streaming"
            ? {
                ...item,
                status:
                  phase === "streaming"
                    ? "streaming"
                    : phase === "complete"
                      ? "complete"
                      : "stopped",
              }
            : item,
        )}
        announcement={
          phase === "streaming"
            ? "Assistant is checking the receipt."
            : phase === "complete"
              ? "Assistant response is ready."
              : phase === "stopped"
                ? "Assistant response stopped."
                : ""
        }
      />
      <div className="ui-row">
        <Button
          onClick={() => {
            run.current += 1;
            setChunkCount(1);
            setPhase("streaming");
          }}
          disabled={phase === "streaming"}
        >
          Start response
        </Button>
        <Button
          variant="outline"
          onClick={() => {
            run.current += 1;
            if (timer.current) window.clearTimeout(timer.current);
            setPhase("stopped");
          }}
          disabled={phase !== "streaming"}
        >
          Stop
        </Button>
      </div>
    </div>
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

var SUPPORT_PARTICIPANTS = [
  {
    id: "rina",
    name: "Rina",
    kind: "human",
  },
  {
    id: "support",
    name: "Support",
    kind: "agent",
  },
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ConversationMessageView({ renderActivityLabel, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      identity={messageIdentity(props.item, renderActivityLabel)}
      renderTimestamp={messageTimestamp}
    />
  );
}

function Transcript({
  items,
  initialPosition = "end",
  follow = "when-at-end",
  children,
  announcement,
}) {
  return (
    <Conversation
      label="Support conversation"
      initialPosition={"end"}
      follow={"when-at-end"}
      announcement={announcement}
      currentUserId="rina"
      participants={SUPPORT_PARTICIPANTS}
    >
      <ConversationContent>
        {items.map((item) => (
          <ConversationItem key={item.id} id={item.id} message={item}>
            <ConversationMessageView item={item} />
          </ConversationItem>
        ))}
        {undefined}
      </ConversationContent>
      <ConversationScrollButton />
    </Conversation>
  );
}

```

#### Read earlier and jump

Keep the reader's offset when new output arrives away from the live edge.

conversation-read-earlier-and-jump-9.jsx

```jsx
import { Fragment, useState } from "react";
import { Button } from "@/components/ui/button";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
  ConversationScrollButton,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import { MessageSender } from "@/components/ui/message-sender";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const [extra, setExtra] = useState(0);
  const items = [
    ...BASIC_MESSAGES,
    ...Array.from(
      {
        length: 16 + extra,
      },
      (_, index) =>
        message(
          `later-${index}`,
          index % 2 ? "assistant" : "user",
          `Later update ${index + 1} is ready.`,
          index + 3,
        ),
    ),
  ];
  return (
    <div data-preview-wide>
      <Transcript items={items}></Transcript>
      <div className="ui-row">
        <Button onClick={() => setExtra((value) => value + 1)}>
          Add newer reply
        </Button>
      </div>
    </div>
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

var SUPPORT_PARTICIPANTS = [
  {
    id: "rina",
    name: "Rina",
    kind: "human",
  },
  {
    id: "support",
    name: "Support",
    kind: "agent",
  },
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ConversationMessageView({ renderActivityLabel, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      identity={messageIdentity(props.item, renderActivityLabel)}
      renderTimestamp={messageTimestamp}
    />
  );
}

function Transcript({
  items,
  initialPosition = "end",
  follow = "when-at-end",
  children,
  announcement,
}) {
  return (
    <Conversation
      label="Support conversation"
      initialPosition={"end"}
      follow={"when-at-end"}
      announcement={undefined}
      currentUserId="rina"
      participants={SUPPORT_PARTICIPANTS}
    >
      <ConversationContent>
        {items.map((item) => (
          <ConversationItem key={item.id} id={item.id} message={item}>
            <ConversationMessageView item={item} />
          </ConversationItem>
        ))}
        {undefined}
      </ConversationContent>
      <ConversationScrollButton />
    </Conversation>
  );
}

```

#### New-turn anchor

Anchor one supplied turn boundary without re-anchoring every token update.

conversation-new-turn-anchor-10.jsx

```jsx
import { Fragment, useState } from "react";
import { Button } from "@/components/ui/button";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
  ConversationScrollButton,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import { MessageSender } from "@/components/ui/message-sender";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const [turn, setTurn] = useState(0);
  const [growth, setGrowth] = useState(0);
  const items = [
    ...BASIC_MESSAGES,
    ...(turn
      ? [
          message(
            `turn-${turn}`,
            "user",
            `New question ${turn} starts here.`,
            4 + turn,
            {
              id: "rina",
              name: "Rina",
            },
          ),
          message(
            `turn-answer-${turn}`,
            "assistant",
            `I will keep this turn at the reading edge.${" More detail arrives.".repeat(growth)}`,
            5 + turn,
          ),
        ]
      : []),
  ];
  return (
    <div data-preview-wide>
      <Conversation label="Anchored support conversation">
        <ConversationContent>
          {items.map((item) => (
            <ConversationItem
              key={item.id}
              id={item.id}
              message={item}
              anchor={item.id === `turn-${turn}`}
            >
              <ConversationMessageView item={item} />
            </ConversationItem>
          ))}
        </ConversationContent>
        <ConversationScrollButton />
      </Conversation>
      <div className="ui-row">
        <Button
          onClick={() => {
            setGrowth(0);
            setTurn((value) => value + 1);
          }}
        >
          Start new turn
        </Button>
        <Button
          variant="outline"
          onClick={() => setGrowth((value) => value + 1)}
          disabled={!turn}
        >
          Add stream detail
        </Button>
      </div>
    </div>
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ConversationMessageView({ renderActivityLabel, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      identity={messageIdentity(props.item, renderActivityLabel)}
      renderTimestamp={messageTimestamp}
    />
  );
}

```

#### Load earlier history

Prepend chronological history and preserve the first visible row's offset.

conversation-load-earlier-history-11.jsx

```jsx
import { Fragment, useState } from "react";
import { Button } from "@/components/ui/button";
import {
  Conversation,
  ConversationContent,
  ConversationItem,
  ConversationScrollButton,
} from "@/components/ui/conversation";
import {
  Message,
  MessageAvatar,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageHeader,
  MessageMeta,
} from "@/components/ui/message";
import { MessageSender } from "@/components/ui/message-sender";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const [history, setHistory] = useState(() =>
    Array.from(
      {
        length: 16,
      },
      (_, index) =>
        message(
          `history-${index}`,
          "assistant",
          `Earlier note ${index + 1} is already in the transcript.`,
          index - 16,
        ),
    ),
  );
  const current = [...history, ...BASIC_MESSAGES];
  return (
    <div data-preview-wide>
      <Transcript items={current} />
      <div className="ui-row">
        <Button
          onClick={() =>
            setHistory((value) => [
              ...Array.from(
                {
                  length: 3,
                },
                (_, index) =>
                  message(
                    `history-${value.length + index}`,
                    "user",
                    `Earlier note ${value.length + index + 1}.`,
                    -(value.length + index + 3),
                  ),
              ),
              ...value,
            ])
          }
        >
          Load earlier history
        </Button>
      </div>
    </div>
  );
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

var SUPPORT_PARTICIPANTS = [
  {
    id: "rina",
    name: "Rina",
    kind: "human",
  },
  {
    id: "support",
    name: "Support",
    kind: "agent",
  },
];

function ConversationMessageFrame({
  item,
  self,
  metadataAtRest,
  identity,
  editor,
  pendingIndicator,
  renderTimestamp,
  renderActions,
  renderMenu,
}) {
  const text = item.parts
    .flatMap((part) => (part.type === "text" ? [part.text] : []))
    .join("\n");
  const inlineHumanText =
    item.actor === "user" &&
    item.parts.length > 0 &&
    item.parts.every((part) => part.type === "text");
  const timestamp =
    renderTimestamp && item.createdAt ? new Date(item.createdAt) : undefined;
  const validTimestamp =
    timestamp && Number.isFinite(timestamp.getTime()) ? timestamp : undefined;
  const canRenderActions =
    item.status !== "queued" &&
    item.status !== "streaming" &&
    item.status !== "stopped";
  const footerActions =
    !editor && canRenderActions ? renderActions?.(text, validTimestamp) : null;
  const footerMetadata =
    !editor && validTimestamp && !footerActions
      ? renderTimestamp?.(validTimestamp)
      : null;
  const showFooter =
    !editor && (item.status === "stopped" || footerMetadata || footerActions);
  const waiting =
    item.actor === "assistant" &&
    item.status === "streaming" &&
    !item.parts.some(
      (part) =>
        part.type !== "source" && (part.type !== "text" || part.text.trim()),
    );
  const hasActivity = item.parts.some((part) => part.type === "activity");
  const content = (
    <Message
      actor={item.actor}
      self={self}
      metadataAtRest={metadataAtRest}
      senderId={item.author?.id}
      status={item.status}
    >
      {identity?.avatar}
      <MessageContent>
        {!hasActivity && identity?.header}
        {editor ?? (
          <MessageBody>
            {waiting && pendingIndicator ? (
              pendingIndicator
            ) : inlineHumanText ? (
              item.parts.map((part, index) =>
                part.type === "text" ? (
                  <Fragment key={part.id ?? `text-${index}`}>
                    {part.text}
                  </Fragment>
                ) : null,
              )
            ) : (
              <MessageParts
                parts={item.parts}
                sourceList={false}
                activityLabel={identity?.activityLabel}
              />
            )}
            {item.status === "streaming" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Assistant response is in progress.
              </span>
            ) : null}
            {item.status === "queued" ? (
              <span className="ui-sr-only" role="status" aria-live="polite">
                Message is being sent.
              </span>
            ) : null}
          </MessageBody>
        )}
        {showFooter ? (
          <ConversationMessageFooter
            status={
              item.status === "stopped" ? (
                <span role="status">Generation stopped.</span>
              ) : null
            }
            metadata={footerMetadata}
            actions={footerActions}
          />
        ) : null}
      </MessageContent>
    </Message>
  );
  return renderMenu && !editor ? renderMenu(text, content) : content;
}

function ConversationMessageFooter({ status, metadata, actions }) {
  return (
    <MessageFooter>
      {metadata}
      {status}
      {actions}
    </MessageFooter>
  );
}

function messageTimestamp(timestamp, inline = false) {
  return (
    <MessageMeta placement={inline ? "inline" : undefined}>
      <time dateTime={timestamp.toISOString()}>
        {timestamp.toLocaleTimeString([], {
          hour: "numeric",
          minute: "2-digit",
        })}
      </time>
    </MessageMeta>
  );
}

function messageIdentity(item, renderActivityLabel) {
  if (!item.author) return;
  const { name, id, avatarUrl } = item.author;
  const kind =
    item.author.kind ?? (item.actor === "assistant" ? "agent" : "human");
  const label = name ?? (kind === "agent" ? "Agent" : "Unknown speaker");
  return {
    kind,
    avatar: (
      <MessageAvatar>
        <MessageSender
          name={name}
          kind={kind}
          seed={id ?? name ?? "unknown"}
          avatarUrl={avatarUrl}
          showName={false}
        />
      </MessageAvatar>
    ),
    header: <MessageHeader>{label}</MessageHeader>,
    activityLabel: item.parts.some((part) => part.type === "activity")
      ? renderActivityLabel?.(label)
      : undefined,
  };
}

function ConversationMessageView({ renderActivityLabel, ...props }) {
  return (
    <ConversationMessageFrame
      {...props}
      identity={messageIdentity(props.item, renderActivityLabel)}
      renderTimestamp={messageTimestamp}
    />
  );
}

function Transcript({
  items,
  initialPosition = "end",
  follow = "when-at-end",
  children,
  announcement,
}) {
  return (
    <Conversation
      label="Support conversation"
      initialPosition={"end"}
      follow={"when-at-end"}
      announcement={undefined}
      currentUserId="rina"
      participants={SUPPORT_PARTICIPANTS}
    >
      <ConversationContent>
        {items.map((item) => (
          <ConversationItem key={item.id} id={item.id} message={item}>
            <ConversationMessageView item={item} />
          </ConversationItem>
        ))}
        {undefined}
      </ConversationContent>
      <ConversationScrollButton />
    </Conversation>
  );
}

```

### Long rich content

Keep long prose and structured content readable within the conversation width.

conversation-long-rich-content-12.jsx

```jsx
import {
  Conversation,
  ConversationContent,
  ConversationItem,
  ConversationScrollButton,
} from "@/components/ui/conversation";
import { Message, MessageBody } from "@/components/ui/message";
import { MessageParts } from "@/components/ui/message-parts";
import { useSyncExternalStore } from "react";

export default function Example() {
  const workspacePhotoUrl = useDemoAssetUrl("/attachments/workspace.jpg");
  const shippingPolicyUrl = useDemoSourceUrl("receipt-policy.html");
  const receiptMessages = [
    {
      id: "receipt-request",
      actor: "user",
      author: {
        id: "rina",
        name: "Rina",
      },
      createdAt: new Date(Date.UTC(2026, 9, 2, 9, 14, 0)).toISOString(),
      parts: [
        {
          type: "text",
          id: "receipt-request-text",
          text: "Can you confirm when order **R-1048** will arrive? I attached a workspace photo and the receipt for reference.",
        },
        {
          type: "file",
          id: "delivery-photo",
          name: "workspace.jpg",
          url: workspacePhotoUrl,
          mediaType: "image/jpeg",
          status: "ready",
        },
        {
          type: "file",
          id: "order-receipt",
          name: "order-R-1048.pdf",
          mediaType: "application/pdf",
          size: 53248,
          status: "ready",
        },
      ],
    },
    {
      id: "receipt-check",
      actor: "assistant",
      author: {
        id: "support",
        name: "Support",
      },
      createdAt: new Date(Date.UTC(2026, 9, 2, 9, 15, 0)).toISOString(),
      parts: [
        {
          type: "text",
          id: "receipt-check-text",
          text: "I found the order and checked the latest carrier scan. It is **out for delivery today**, with an expected arrival before 8:00 PM.",
        },
        {
          type: "activity",
          id: "receipt-activity",
          event: {
            id: "receipt-activity-event",
            kind: "lookup",
            state: "complete",
            label: "Checked order R-1048",
            description: "Matched the receipt to the carrier scan.",
          },
        },
        {
          type: "tool",
          id: "carrier-lookup",
          name: "Carrier tracking",
          state: "output-ready",
          input: {
            orderId: "R-1048",
          },
          output: {
            status: "out-for-delivery",
            eta: "Today before 8:00 PM",
          },
        },
        {
          type: "source",
          id: "shipping-policy",
          source: {
            id: "shipping-policy",
            type: "url",
            title: "Delivery estimates",
            url: shippingPolicyUrl,
            domain: "Support guide",
            snippet: "Carrier estimates can change during the delivery day.",
          },
        },
        {
          type: "citation-anchor",
          id: "shipping-policy-citation",
          sourceIds: ["shipping-policy"],
          label: "Delivery estimate guidance",
        },
      ],
    },
    {
      id: "receipt-follow-up",
      actor: "user",
      author: {
        id: "rina",
        name: "Rina",
      },
      createdAt: new Date(Date.UTC(2026, 9, 2, 9, 17, 0)).toISOString(),
      parts: [
        {
          type: "text",
          id: "receipt-follow-up-text",
          text: "Thanks. Please let me know if the scan changes.",
        },
      ],
    },
    {
      id: "receipt-confirmation",
      actor: "assistant",
      author: {
        id: "support",
        name: "Support",
      },
      createdAt: new Date(Date.UTC(2026, 9, 2, 9, 18, 0)).toISOString(),
      parts: [
        {
          type: "text",
          id: "receipt-confirmation-text",
          text: "I will keep the order details here. Your receipt remains available in the attached PDF.",
        },
      ],
    },
  ];
  return (
    <div data-preview-wide>
      <Conversation
        label="Long rich conversation"
        currentUserId="rina"
        participants={SUPPORT_PARTICIPANTS}
      >
        <ConversationContent>
          {receiptMessages.map((item) => (
            <ConversationItem key={item.id} id={item.id} message={item}>
              <Message
                actor={item.actor}
                status={item.status}
                label={`${item.author?.name ?? item.actor} message`}
              >
                <MessageBody>
                  <MessageParts parts={item.parts} />
                </MessageBody>
              </Message>
            </ConversationItem>
          ))}
        </ConversationContent>
        <ConversationScrollButton />
      </Conversation>
    </div>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

function message(id, actor, text, minute, author) {
  const createdAt = new Date(Date.UTC(2026, 9, 2, 9, minute, 0)).toISOString();
  return {
    id,
    actor,
    author,
    createdAt,
    parts: [
      {
        type: "text",
        text,
      },
    ],
  };
}

var BASIC_MESSAGES = [
  message(
    "basic-user",
    "user",
    "Could you send the latest receipt to my email?",
    0,
    {
      id: "rina",
      name: "Rina",
    },
  ),
  message(
    "basic-assistant",
    "assistant",
    "Yes. I found the receipt and can send it to the address on the account.",
    1,
    {
      id: "support",
      name: "Support",
    },
  ),
];

var SUPPORT_PARTICIPANTS = [
  {
    id: "rina",
    name: "Rina",
    kind: "human",
  },
  {
    id: "support",
    name: "Support",
    kind: "agent",
  },
];

```

## API reference

Conversation properties

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| currentUserId | string | — | Identifies a human member of the supplied roster. Conversation derives self/alignment only for known author IDs. |
| participants | readonly ConversationParticipant[] | — | Complete roster of unique, nonempty stable IDs and human/agent kinds; currentUserId must identify a human member. Incomplete or duplicate rosters do not derive one-to-one defaults. |
| label | string | "Conversation" | Names the transcript region and its viewport. |
| follow | "when-at-end" \| "never" | "when-at-end" | Follows content growth only when the reader is at the live edge. |
| initialPosition | "start" \| "end" | "end" | Sets the first visible position before paint. |
| groupWindowMs | number | 300000 | Limits automatic grouping when both messages have valid timestamps. |
| getGroupKey | (message: ChatMessage) => string \| null | — | Supplies an optional grouping identity; null creates a boundary. |
| live | boolean | false | Marks a caller-owned live transcript without creating token announcements. |
| announcement | string | — | Supplies the one explicit polite announcement channel. |

ConversationItem properties

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| id (required) | string | — | Stable row identity used for anchoring and history preservation. |
| message | ChatMessage \| undefined | — | Enables automatic grouping for this contiguous item. |
| anchor | boolean | false | Places this explicit new-turn row at the viewport start once. |

Conversation forwards section attributes and an HTMLElement ref. ConversationContent, ConversationItem, ConversationEmpty, and ConversationStatus forward div attributes and HTMLDivElement refs. ConversationScrollButton accepts Button props and an HTMLButtonElement ref; it defaults to the icon-sm size and “Jump to latest” accessible label. Content, item, empty, and status accept caller children. Empty has no added semantics; Status defaults to role="status" and aria-live="off", both overrideable. Item requires a stable id; it forwards that identity to the scroller and uses tabIndex="-1" on the rendered row.
