# Message actions

Add copy, delivery details, and supported commands to a message.

## Preview

message-actions-preview-1.jsx

```jsx
import { useState } from "react";
import { MessageActions } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
} from "@/components/ui/message";
import { CitationList, CitationProvider } from "@/components/ui/citation";

export default function Example() {
  const [vote, setVote] = useState(null);
  const [feedback, setFeedback] = useState("");
  const share = async () => {
    if (!navigator.share) {
      setFeedback("Sharing is not available in this browser.");
      return;
    }
    try {
      await navigator.share({
        title: "Rollout plan",
        text: "Move the rollout to Friday. Staging passed the retry check, and Priya owns the final coverage review.",
      });
    } catch {
      setFeedback("Sharing was cancelled.");
    }
  };
  const download = () => {
    const url = URL.createObjectURL(
      new Blob(
        [
          "Move the rollout to Friday. Staging passed the retry check, and Priya owns the final coverage review.",
        ],
        {
          type: "text/plain",
        },
      ),
    );
    const anchor = document.createElement("a");
    anchor.href = url;
    anchor.download = "rollout-answer.txt";
    anchor.click();
    URL.revokeObjectURL(url);
    setFeedback("Answer downloaded.");
  };
  return (
    <CitationProvider sources={sources} mode="provided">
      <div data-preview-wide>
        <Message actor="assistant">
          <MessageContent>
            <MessageBody>
              {
                "Move the rollout to Friday. Staging passed the retry check, and Priya owns the final coverage review."
              }
            </MessageBody>
            <MessageFooter>
              <MessageActions
                text={
                  "Move the rollout to Friday. Staging passed the retry check, and Priya owns the final coverage review."
                }
                vote={vote}
                onVote={setVote}
                onShare={() => void share()}
                onDownload={download}
                sources={<CitationList mode="provided" />}
              />
            </MessageFooter>
          </MessageContent>
        </Message>
        <span className="ui-sr-only" role="status">
          {feedback}
        </span>
      </div>
    </CitationProvider>
  );
}

var sources = [
  {
    id: "runbook",
    type: "url",
    title: "Release runbook",
    url: "https://example.com/runbook",
  },
  {
    id: "status",
    type: "url",
    title: "Staging status",
    url: "https://example.com/status",
  },
];

```

## Design guidance

Use MessageActions for Copy, command callbacks, and delivery recovery. Its toolbar and context menu call the same handlers. Supply timestamps, receipts, and citations as metadata. Place the actions in [Message](/ai-elements/message#footer-actions) to use its visibility and layout rules.

Use the same left-to-right reading order for every alignment. Human metadata is timestamp, delivery icon, commands, then saved reactions. Agent metadata is timestamp, commands, then citations. Recovery puts Retry before Delete in DOM and keyboard order. Supplied timestamps precede commands; supplied citations follow them. Use spacing between these items; automatic dividers can become orphaned when a footer wraps. Keep ordinary metadata in the footer. Inline metadata remains available for a deliberate compact composition.

### Conversation defaults

[Conversation](/ai-elements/conversation#context-defaults) supplies complete-roster defaults. The established one-human/one-agent case retains the full agent toolbar; group contexts can keep supplied citations and times visible while commands reveal. Explicit Message props still win.

Copy is built in when message text is supplied; other commands appear only when their callback is supplied. Copy feedback is announced. Context actions use the canonical Context menu keyboard and pointer behavior. Receipt details open in a named Popover.

## Installation

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

## Basic usage

```tsx
import { MessageActions } from "@/components/ui/message-actions";

export function MessageActionsExample() {
  return <MessageActions text="The staging check passed." />;
}
```

## Structures

MessageActions composes IconButton for commands, Toggle for votes, and ButtonGroup. It spaces the command, citation, and time groups without automatic dividers. MessageDelivery uses the canonical Separator between nonempty receipt groups. A selected vote uses a filled thumb with no persistent container background. Vote state and repeated-vote policy stay with the caller. MessageActionMenu wraps the caller's message content in canonical ContextMenu behavior. MessageEdit owns only a local draft. MessageDelivery displays only supplied runtime receipts.

- MessageActions
- MessageActionMenu
- MessageEdit
- MessageDelivery

## Examples

### Own user message

Hover, focus, or tap a non-interactive message to reveal its commands. The supplied timestamp follows Message metadata visibility; an own-human timestamp reveals on interaction by default.

message-actions-own-user-message-2.jsx

```jsx
import { useState } from "react";
import { MessageActions, MessageEdit } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
} from "@/components/ui/message";

export default function Example() {
  const [text, setText] = useState(
    "Friday works. I\u2019ll confirm with support.",
  );
  const [editing, setEditing] = useState(false);
  return editing ? (
    <MessageEdit
      defaultValue={text}
      onCancel={() => setEditing(false)}
      onSubmit={async (next) => {
        setText(next);
        setEditing(false);
      }}
    />
  ) : (
    <Message actor="user">
      <MessageContent>
        <MessageBody>{text}</MessageBody>
        <MessageFooter>
          <MessageActions
            text={text}
            onEdit={() => setEditing(true)}
            timestamp="10:44 AM"
          />
        </MessageFooter>
      </MessageContent>
    </Message>
  );
}

```

### Context actions

Right-click or use the platform context-menu gesture on the message. The menu includes only supplied callbacks.

message-actions-context-actions-3.jsx

```jsx
import { useState } from "react";
import {
  MessageActionMenu,
  MessageEdit,
} from "@/components/ui/message-actions";
import { Message, MessageBody } from "@/components/ui/message";

export default function Example() {
  const [text, setText] = useState("Move the rollout to Friday.");
  const [editing, setEditing] = useState(false);
  return editing ? (
    <MessageEdit
      defaultValue={text}
      onCancel={() => setEditing(false)}
      onSubmit={(next) => {
        setText(next);
        setEditing(false);
      }}
    />
  ) : (
    <MessageActionMenu text={text} onEdit={() => setEditing(true)}>
      <Message actor="user">
        <MessageBody>{text}</MessageBody>
      </Message>
    </MessageActionMenu>
  );
}

```

### Edit a message

The actual form is the [Composer edit surface](/ai-elements/composer#message-edit). Cancel restores caller-owned message state. A rejected submit keeps the draft and attachments available for correction. A plain edit saves the selected message. The host may instead edit one human item and regenerate its explicitly linked AI reply while preserving every later visible message; that is a branch for this turn, not a whole-conversation fork. Full conversation fork/restart is a separate host capability. This local example is deterministic and makes no backend or model call. Installed SDK helpers target their own current-history semantics and do not perform this arbitrary linked-reply transaction.

message-actions-edit-a-message-4.jsx

```jsx
import { useEffect, useRef, useState } from "react";
import { MessageActions, MessageEdit } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
} from "@/components/ui/message";
import { MessageParts } from "@/components/ui/message-parts";
import { Attachment } from "@/components/ui/attachment";
import { FileUpload } from "@/components/ui/file-upload";
import { ComposerAction, ComposerAttachments } from "@/components/ui/composer";
import { AudioRecorder } from "@/components/ui/audio-recorder";
import { Loader } from "@/components/ui/loader";
import { Mic, Plus } from "lucide-react";

export default function Example() {
  const [draftFiles, setDraftFiles] = useState([originalBrief]);
  const [messages, setMessages] = useState([
    {
      id: "request-17",
      actor: "user",
      author: {
        id: "rina",
        name: "Rina",
        kind: "human",
      },
      parts: [
        {
          type: "text",
          id: "request-text",
          text: "Move the rollout review to Friday.",
        },
        {
          type: "file",
          ...originalBrief,
        },
      ],
    },
    {
      id: "reply-18",
      actor: "assistant",
      author: {
        id: "analyst",
        name: "Launch analyst",
        kind: "agent",
      },
      parts: [
        {
          type: "text",
          id: "reply-text",
          text: "I\u2019ll update the review plan and notify the owners.",
        },
        {
          type: "file",
          id: "updated-plan",
          name: "review-plan.pdf",
          mediaType: "application/pdf",
          size: 92160,
          status: "ready",
        },
      ],
    },
    {
      id: "later-19",
      actor: "assistant",
      author: {
        id: "analyst",
        name: "Launch analyst",
        kind: "agent",
      },
      parts: [
        {
          type: "text",
          id: "later-text",
          text: "The staging check is still due before the review.",
        },
      ],
    },
    {
      id: "later-human-20",
      actor: "user",
      author: {
        id: "rina",
        name: "Rina",
        kind: "human",
      },
      parts: [
        {
          type: "text",
          id: "later-human-text",
          text: "I\u2019ll keep the regional coverage review on the calendar.",
        },
        {
          type: "file",
          id: "coverage-sheet",
          name: "regional-coverage.xlsx",
          mediaType:
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
          size: 53248,
          status: "ready",
        },
      ],
    },
    {
      id: "later-agent-21",
      actor: "assistant",
      author: {
        id: "analyst",
        name: "Launch analyst",
        kind: "agent",
      },
      parts: [
        {
          type: "text",
          id: "later-agent-text",
          text: "The existing coverage owners and follow-up date are unchanged.",
        },
        {
          type: "file",
          id: "coverage-summary",
          name: "coverage-summary.pdf",
          mediaType: "application/pdf",
          size: 65536,
          status: "ready",
        },
      ],
    },
  ]);
  const [editing, setEditing] = useState(true);
  const [phase, setPhase] = useState("idle");
  const [recordError, setRecordError] = useState("");
  const run = useRef(0);
  const activeTarget = useRef(null);
  const messagesRef = useRef(messages);
  messagesRef.current = messages;
  const objectUrls = useRef(/* @__PURE__ */ new Map());
  const files = useRef(/* @__PURE__ */ new Map());
  const draftOnlyIds = useRef(/* @__PURE__ */ new Set());
  const discardDraftFiles = () => {
    draftOnlyIds.current.forEach((id) => {
      const url = objectUrls.current.get(id);
      if (url) URL.revokeObjectURL(url);
      objectUrls.current.delete(id);
      files.current.delete(id);
    });
    draftOnlyIds.current.clear();
  };
  useEffect(
    () => () => {
      run.current += 1;
      objectUrls.current.forEach((url) => URL.revokeObjectURL(url));
      objectUrls.current.clear();
      files.current.clear();
    },
    [],
  );
  const userMessage = messages.find((message) => message.id === "request-17");
  const replyMessage = messages.find((message) => message.id === "reply-18");
  const laterMessage = messages.find((message) => message.id === "later-19");
  const laterHumanMessage = messages.find(
    (message) => message.id === "later-human-20",
  );
  const laterAgentMessage = messages.find(
    (message) => message.id === "later-agent-21",
  );
  const userText = userMessage.parts
    .filter((part) => part.type === "text")
    .map((part) => part.text)
    .join("\n");
  const userFiles = userMessage.parts
    .filter((part) => part.type === "file")
    .map(({ type: _type, ...file }) => file);
  const submitEdit = async (text, submission) => {
    if (
      activeTarget.current ||
      !messagesRef.current.some((message) => message.id === "request-17") ||
      !messagesRef.current.some((message) => message.id === "reply-18")
    )
      return;
    const generation = ++run.current;
    activeTarget.current = "request-17";
    await new Promise((resolve) => window.setTimeout(resolve, 350));
    if (
      run.current !== generation ||
      activeTarget.current !== "request-17" ||
      !messagesRef.current.some((message) => message.id === "request-17")
    ) {
      activeTarget.current = null;
      return;
    }
    const nextFiles = (submission?.attachments ?? draftFiles).map(
      (attachment) => {
        const file = files.current.get(attachment.id);
        return file
          ? {
              ...attachment,
              name: file.name,
              mediaType: file.type || attachment.mediaType,
              size: file.size,
            }
          : attachment;
      },
    );
    setMessages((current) =>
      current.map((message) => {
        if (message.id !== "request-17") return message;
        const pendingFiles = new Map(nextFiles.map((file) => [file.id, file]));
        let textWritten = false;
        const parts = [];
        for (const part of message.parts) {
          if (part.type === "text") {
            if (textWritten) continue;
            textWritten = true;
            parts.push({
              ...part,
              text,
            });
            continue;
          }
          if (part.type !== "file") {
            parts.push(part);
            continue;
          }
          const replacement = pendingFiles.get(part.id);
          if (!replacement) continue;
          pendingFiles.delete(part.id);
          parts.push({
            type: "file",
            ...replacement,
          });
        }
        if (!textWritten)
          parts.push({
            type: "text",
            id: "request-text",
            text,
          });
        parts.push(
          ...[...pendingFiles.values()].map((file) => ({
            type: "file",
            ...file,
          })),
        );
        return {
          ...message,
          parts,
        };
      }),
    );
    draftOnlyIds.current.forEach((id) => files.current.delete(id));
    draftOnlyIds.current.clear();
    setPhase("generating");
    setEditing(false);
    window.setTimeout(() => {
      if (
        run.current !== generation ||
        activeTarget.current !== "request-17" ||
        !messagesRef.current.some((message) => message.id === "request-17") ||
        !messagesRef.current.some((message) => message.id === "reply-18")
      )
        return;
      setMessages((current) =>
        current.map((message) => {
          if (message.id !== "reply-18") return message;
          let textWritten = false;
          const parts = [];
          for (const part of message.parts) {
            if (part.type !== "text") {
              parts.push(part);
              continue;
            }
            if (textWritten) continue;
            textWritten = true;
            parts.push({
              ...part,
              text: "I moved the rollout review to Friday and kept the staging check with its existing owner.",
            });
          }
          if (!textWritten)
            parts.push({
              type: "text",
              id: "reply-text",
              text: "I moved the rollout review to Friday and kept the staging check with its existing owner.",
            });
          return {
            ...message,
            status: "complete",
            parts,
          };
        }),
      );
      setPhase("updated");
      activeTarget.current = null;
    }, 700);
  };
  const recordFile = (file) => {
    const id = crypto.randomUUID();
    const url = URL.createObjectURL(file);
    files.current.set(id, file);
    objectUrls.current.set(id, url);
    draftOnlyIds.current.add(id);
    return {
      type: "file",
      id,
      name: file.name,
      mediaType: file.type || "application/octet-stream",
      size: file.size,
      url,
      status: "ready",
    };
  };
  const removeDraftFile = (attachment) => {
    const url = objectUrls.current.get(attachment.id);
    if (url) URL.revokeObjectURL(url);
    objectUrls.current.delete(attachment.id);
    files.current.delete(attachment.id);
    draftOnlyIds.current.delete(attachment.id);
    setDraftFiles((current) =>
      current.filter((file) => file.id !== attachment.id),
    );
  };
  const partText = (message) =>
    message.parts
      .filter((part) => part.type === "text")
      .map((part) => part.text)
      .join("\n");
  const compactFile = (part) =>
    part.type === "file" ? <Attachment file={part} size="sm" /> : null;
  return (
    <div
      data-preview-wide
      style={{
        display: "grid",
        gap: "var(--space-3)",
      }}
    >
      <Message actor="user" senderId="rina" data-message-id={userMessage.id}>
        <MessageContent>
          <MessageBody>
            <MessageParts
              parts={userMessage.parts}
              renderers={{
                file: compactFile,
              }}
            />
          </MessageBody>
          <MessageFooter>
            <MessageActions
              text={partText(userMessage)}
              busy={phase === "generating"}
              onEdit={() => {
                activeTarget.current = null;
                setDraftFiles(userFiles);
                setEditing(true);
                setPhase("idle");
              }}
            />
          </MessageFooter>
        </MessageContent>
      </Message>
      <Message
        actor="assistant"
        senderId="analyst"
        status={phase === "generating" ? "streaming" : "complete"}
        data-message-id={replyMessage.id}
      >
        <MessageBody>
          <MessageParts
            parts={replyMessage.parts}
            renderers={{
              file: compactFile,
            }}
          />
          {phase === "generating" && (
            <span role="status">
              <Loader size={14} />
              {" Regenerating the linked reply\u2026"}
            </span>
          )}
        </MessageBody>
      </Message>
      <Message
        actor="assistant"
        senderId="analyst"
        data-message-id={laterMessage.id}
      >
        <MessageBody>
          <MessageParts
            parts={laterMessage.parts}
            renderers={{
              file: compactFile,
            }}
          />
        </MessageBody>
      </Message>
      <Message
        actor="user"
        senderId="rina"
        data-message-id={laterHumanMessage.id}
      >
        <MessageBody>
          <MessageParts
            parts={laterHumanMessage.parts}
            renderers={{
              file: compactFile,
            }}
          />
        </MessageBody>
      </Message>
      <Message
        actor="assistant"
        senderId="analyst"
        data-message-id={laterAgentMessage.id}
      >
        <MessageBody>
          <MessageParts
            parts={laterAgentMessage.parts}
            renderers={{
              file: compactFile,
            }}
          />
        </MessageBody>
      </Message>
      {phase === "updated" && (
        <span role="status" aria-live="polite">
          Updated reply for Friday.
        </span>
      )}
      {recordError && <span role="alert">{recordError}</span>}
      {editing && (
        <FileUpload.Root
          multiple
          maxFiles={4}
          selectedCount={draftFiles.length}
          aria-label="Edit message attachments"
          onFilesSelect={({ accepted }) =>
            setDraftFiles((current) => [
              ...current,
              ...accepted.map(recordFile),
            ])
          }
        >
          <FileUpload.Input />
          <MessageEdit
            key={userMessage.id}
            defaultValue={userText}
            originalText={userText}
            originalAuthor="Original message"
            targetKey={userMessage.id}
            attachments={draftFiles}
            attachmentContent={
              <ComposerAttachments onRemove={removeDraftFile} />
            }
            submitLabel="Save & regenerate"
            onCancel={() => {
              discardDraftFiles();
              setDraftFiles(userFiles);
              setEditing(false);
            }}
            onSubmit={submitEdit}
            toolbarStart={
              <FileUpload.Trigger
                render={
                  <ComposerAction
                    aria-label="Add files"
                    icon={<Plus size={14} aria-hidden="true" />}
                  />
                }
              />
            }
            toolbarEnd={
              <AudioRecorder
                label="Voice note"
                appearance="embedded"
                onRecordingComplete={(blob) => {
                  const file = new File([blob], "Voice note.webm", {
                    type: blob.type || "audio/webm",
                  });
                  setDraftFiles((current) => [...current, recordFile(file)]);
                }}
                onError={(error) => setRecordError(error.message)}
              >
                <AudioRecorder.RecordButton
                  variant="ghost"
                  nativeButton
                  asChild
                >
                  <ComposerAction
                    aria-label="Record voice"
                    icon={<Mic size={14} aria-hidden="true" />}
                  />
                </AudioRecorder.RecordButton>
              </AudioRecorder>
            }
          />
        </FileUpload.Root>
      )}
    </div>
  );
}

var originalBrief = {
  id: "review-brief",
  name: "review-brief.pdf",
  mediaType: "application/pdf",
  size: 184320,
  status: "ready",
};

```

### Rejected edit

The first save is rejected. Keep the draft and retry after correcting the message.

message-actions-rejected-edit-5.jsx

```jsx
import { useState } from "react";
import { MessageEdit } from "@/components/ui/message-actions";
import { Message, MessageBody, MessageContent } from "@/components/ui/message";
import { MessageParts } from "@/components/ui/message-parts";
import { ComposerAttachments } from "@/components/ui/composer";

export default function Example() {
  const [attempts, setAttempts] = useState(0);
  const [saved, setSaved] = useState();
  if (saved)
    return (
      <Message actor="user">
        <MessageContent>
          <MessageBody>
            <MessageParts
              parts={[
                {
                  type: "text",
                  id: "saved-edit",
                  text: saved.text,
                },
                ...saved.attachments.map((file) => ({
                  type: "file",
                  ...file,
                })),
              ]}
            />
          </MessageBody>
        </MessageContent>
      </Message>
    );
  return (
    <MessageEdit
      defaultValue="Move the rollout review to Friday."
      originalText="Move the rollout review to Thursday."
      originalAuthor="Rina"
      attachments={[originalBrief]}
      attachmentContent={<ComposerAttachments />}
      submitLabel="Save changes"
      onCancel={() => setAttempts(0)}
      onSubmit={async (text, submission) => {
        if (attempts === 0) {
          setAttempts(1);
          throw new Error("Could not save. Check the time and try again.");
        }
        setSaved({
          text,
          attachments: submission?.attachments ?? [originalBrief],
        });
      }}
    />
  );
}

var originalBrief = {
  id: "review-brief",
  name: "review-brief.pdf",
  mediaType: "application/pdf",
  size: 184320,
  status: "ready",
};

```

### Read receipt

Supply recipient timestamps from the runtime. Rows include only the sent, delivered, and read timestamps actually supplied.

message-actions-read-receipt-6.jsx

```jsx
import { MessageDelivery } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageMeta,
} from "@/components/ui/message";

export default function Example() {
  const sentAt = new Date(Date.now() - 480000);
  const sent = sentAt.toISOString();
  return (
    <Message actor="user">
      <MessageContent>
        <MessageBody>Friday works for the rollout.</MessageBody>
        <MessageFooter>
          <MessageMeta>
            <time dateTime={sent}>
              {sentAt.toLocaleTimeString([], {
                hour: "numeric",
                minute: "2-digit",
              })}
            </time>
            <MessageDelivery
              delivery={{
                status: "read",
                recipients: [
                  {
                    id: "marta",
                    name: "Marta Chen, Director of Product Design and Research",
                    sentAt: sent,
                    deliveredAt: new Date(
                      sentAt.getTime() + 2000,
                    ).toISOString(),
                    readAt: new Date(sentAt.getTime() + 180000).toISOString(),
                  },
                  {
                    id: "priya",
                    name: "Priya Nair",
                    initials: "PN",
                    sentAt: sent,
                    deliveredAt: new Date(
                      sentAt.getTime() + 4000,
                    ).toISOString(),
                  },
                ],
              }}
            />
          </MessageMeta>
        </MessageFooter>
      </MessageContent>
    </Message>
  );
}

```

### Failed outgoing message

Keep the failed message and its attachment under the same stable ID while queued or retrying. MessageActions shows Retry/Delete only when those callbacks exist, announces active recovery, and reports a rejected action; the persistent idle Not sent fact belongs to MessageMeta. This local example keeps the same item and file through a rejected retry, a successful retry, or deletion; it does not infer delivery or delete persisted backend history.

message-actions-failed-outgoing-message-7.jsx

```jsx
import { useState } from "react";
import { MessageActions } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
  MessageMeta,
} from "@/components/ui/message";
import { MessageParts } from "@/components/ui/message-parts";

export default function Example() {
  const [deleted, setDeleted] = useState(false);
  const [sendState, setSendState] = useState("error");
  const [attempts, setAttempts] = useState(0);
  if (deleted) return <span role="status">Unsent message deleted.</span>;
  return (
    <Message
      actor="user"
      status={sendState}
      senderId={"failed-outgoing-17"}
      data-message-id={"failed-outgoing-17"}
      metadataAtRest
    >
      <MessageContent>
        <MessageBody
          appearance={sendState === "error" ? "critical" : undefined}
        >
          <MessageParts
            parts={[
              {
                type: "text",
                id: "failed-text",
                text: "Move the rollout review to Friday.",
              },
              {
                type: "file",
                id: "failed-file",
                name: "rollout-plan.pdf",
                mediaType: "application/pdf",
                size: 245760,
                status: "ready",
              },
            ]}
          />
        </MessageBody>
        <MessageFooter>
          {sendState === "complete" ? (
            <MessageMeta>
              <span role="status" data-delivery-status="sent">
                Sent
              </span>
            </MessageMeta>
          ) : (
            <>
              <MessageActions
                text={"Move the rollout review to Friday."}
                failed
                busy={sendState === "queued"}
                onRetry={async () => {
                  setSendState("queued");
                  await new Promise((resolve) =>
                    window.setTimeout(resolve, 400),
                  );
                  if (attempts === 0) {
                    setAttempts(1);
                    setSendState("error");
                    throw new Error(
                      "The server is still unavailable. Retry this message again.",
                    );
                  }
                  setSendState("complete");
                }}
                onDelete={() => setDeleted(true)}
              />
              <MessageMeta>
                <span
                  role="status"
                  data-delivery-status={
                    sendState === "queued" ? "pending" : "failed"
                  }
                >
                  {sendState === "queued" ? "Sending" : "Not sent"}
                </span>
              </MessageMeta>
            </>
          )}
        </MessageFooter>
      </MessageContent>
    </Message>
  );
}

```

### Metadata and reactions

Metadata and reaction selection are caller-owned; see the [Message footer composition](/ai-elements/message#footer-composition) and the current [picker toolbar example](/components/emoji-icon-picker#simple). They do not add MessageActions commands.

## API reference

### Message actions

Message actions properties

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| text (required) | string | — | Message text copied to the browser clipboard. |
| onEdit / onRetry / onShare / onDownload | () => void | — | Adds the matching action only when its callback is supplied. |
| onVote | (vote: 'up' \| 'down') => void | — | Adds helpful and not-helpful actions. |
| vote | up \| down \| null | — | Caller-owned pressed state for feedback controls. |
| timestamp | Date \| string \| ReactNode | — | Caller-owned timestamp. Inside Message, visibility follows explicit metadataAtRest, Conversation context, then the actor/self-derived fallback. |
| sources | ReactNode | — | Caller-owned source list, commonly CitationList. |
| metadataPlacement | "inline" \| "end" | "end" | Retained for existing compositions. It does not change timestamp/actions/citation reading order; MessageFooter and MessageToolbar own physical placement. |
| failed / onRetry / onDelete | boolean / () => void \| Promise<void> / () => void \| Promise<void> | — | Adds supplied Retry/Delete recovery actions; active work is announced and rejected callbacks retain the failed message. Show its persistent idle delivery fact in MessageMeta. |
| busy | boolean | false | Disables all message actions while work is active. |
| className | string | — | Adds a class to the action row. |

### MessageEdit and MessageDelivery

MessageActionMenu properties

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| children (required) | ReactNode | — | The message content that opens the context menu. |
| text (required) | string | — | Message text copied to the clipboard. |
| onEdit / onRetry / onShare / onDownload | () => void | — | Adds the matching menu action only when its callback is supplied. |
| onVote | (vote: 'up' \| 'down') => void | — | Adds helpful and not-helpful menu actions. |
| busy | boolean | false | Disables all menu actions while work is active. |

MessageEdit and MessageDelivery properties

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| MessageEdit.defaultValue | string | — | Initial local draft. |
| MessageEdit.onSubmit | (text: string, submission?: ComposerSubmission) => void \| Promise<void> | — | Requests caller-owned save or regeneration; rejection keeps the draft and attachments. Existing one-argument callbacks remain valid. |
| MessageEdit.originalText / originalAuthor | string / string | — | Supplies the reply context shown above the editor; originalText defaults to defaultValue. |
| MessageEdit.attachments | readonly AttachmentFile[] | — | Passes retained canonical attachment metadata to the edit Composer; acquisition and file upload stay with the host. |
| MessageEdit.toolbarStart / toolbarEnd | ReactNode | — | Adds caller-owned controls at either end of the Composer toolbar. |
| MessageEdit.submitLabel | string | "Save changes" | Visible submit button label. |
| MessageEdit.targetKey | string | — | Identifies the edit target so stale or duplicate asynchronous completion cannot update a different message. |
| MessageEdit.onCancel | () => void | — | Returns control to caller-owned original message state. |
| MessageDelivery.delivery | ChatDelivery | — | Explicit delivered/read status and recipient timestamps; never inferred by this component. |

MessageEdit also accepts the remaining ComposerProps except onSubmit, defaultValue, value, onValueChange, secondary, secondaryVisible, children, label, status, and error; its onSubmit uses (text, submission?). This includes native form attributes and ref is not forwarded. MessageActions accepts only its listed props plus className; MessageActionMenu accepts only its listed props. Neither action composition forwards a native root element or ref. MessageDelivery accepts only the required caller-supplied delivery value.
