UI

Message actions

Copy, retry, feedback with inline reasons, and custom icon buttons under an assistant reply.

import { MessageActions } from '@uthereal/ui/message-actions'

Message actions playground

Loading interactive preview…

Overview

MessageActions renders the action row under an assistant reply: copy, retry, thumbs up and down with an inline feedback panel, and product-specific icon buttons. Pressing thumbs down opens an inline panel with reason chips and an optional note; pressing thumbs up opens a compact follow-up strip. Submitting details shows a short thank-you confirmation before folding back into the row.

Place MessageActions below a reply inside an <article> or an element marked with data-reveal-scope. For full formatted replies with citations, use Answer.

Usage

'use client'
import { MessageActions } from '@uthereal/ui/message-actions'

export function ReplyFooter({ id, text }: { id: string; text: string }) {
  return (
    <MessageActions
      messageId={id}
      copyText={text}
      reveal="always"
      items={[
        { kind: 'copy', id: 'copy' },
        { kind: 'retry', id: 'retry', action: 'retry_message' },
        { kind: 'feedback_up', id: 'good' },
        { kind: 'feedback_down', id: 'bad' },
      ]}
      onAction={(action) => {
        if (action === 'retry_message') retryReply(id)
      }}
      onFeedbackChange={(rating) => updateLocalRating(id, rating)}
      onFeedbackSubmit={async (event, { signal }) => {
        await fetch('/api/feedback', {
          method: 'POST',
          body: JSON.stringify(event),
          signal,
        })
      }}
    />
  )
}

Examples

Feedback flows

Host-owned error retry state (feedbackStatus="error" with defaultFeedbackOpen) and bare instant-toggle thumbs (feedbackPanel={false}). The default inline feedback panel is live in the playground above.

What went wrong?

Reveal, sizes, and custom actions

Hover-revealed row (the default) and compact xs buttons with tooltips and a custom Share action.

Three invoices are unpaid, totaling €6,340 across Q3. Hover or focus to reveal actions.

Item kinds

Each item requires a unique id (passed as itemId to onAction), an optional label, and an optional icon from the icon set. Allow at most six items total, and at most one of each built-in kind.

KindDefault labelDefault iconBehavior
copyCopycopyCopies copyText with drawn-check confirmation; hidden when copyText is omitted. Optional action.
retryRetryrotate-cwCompact outline pill with visible label beside the icon. Requires action.
feedback_upGood responsethumbs-upToggle button; fills on press and opens the positive chip strip unless positiveReasons is [].
feedback_downBad responsethumbs-downToggle button; fills on press and opens the negative reason panel and note field.
custom(required)(required)Circular icon-only button for product-specific actions (for example, Share). Requires label and action.

Feedback panel lifecycle

Thumbs ratings are controlled via feedback / onFeedbackChange or uncontrolled via defaultFeedback. Pressing the active thumb clears the rating to null and folds the panel.

Stage / statusTriggerBehavior
ratingPressing thumbs up, thumbs down, or active thumbUpdates rating, fires the item's action, and calls onFeedbackSubmit({ stage: 'rating', ... }). Rejecting rolls the rating back.
detailsClicking Submit / Send, or Cmd/Ctrl + EnterValidates non-empty reasons or note, fires onFeedbackSubmit({ stage: 'details', ... }) and feedbackAction.
submittingIn-flight promise or feedbackStatus="submitting"Disables chips and textarea; shows a spinner on Submit / Send. Aborts stale calls on close or rating switch.
errorRejected promise or feedbackStatus="error"Crossfades the inline error (feedbackError or "Couldn't send") and relabels the primary button to Try again.
thanksResolved submit (or 700 ms local simulation)Crossfades to the 280 ms drawn check, thanksTitle, and thanksMessage, then folds after thanksDuration ms.

Set feedbackPanel={false} for bare instant-toggle thumbs without a follow-up panel, or pass positiveReasons={[]} to collect details on thumbs down only. Below 400px of container width, privacyNote and Cancel hide so the error message and Try again stay on one row. On coarse pointers, reason chips grow to 32px tall.

Hover reveal

reveal="hover" (the default) hides the row until the pointer hovers an ancestor <article> or [data-reveal-scope], any button inside receives keyboard focus, or the inline feedback panel is open. On touch devices without hover, the row stays visible at 0.7 opacity. Use reveal="always" for the latest reply.

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Message actions"Accessible name of the button group, e.g. "Answer actions". Not shown.
itemsMessageActionItem[]Default: [{"kind":"copy","id":"copy","label":"Copy"},{"kind":"feedback_up","id":"good","label":"Good response"},{"kind":"feedback_down","id":"bad","label":"Bad response"}]Up to six icon buttons, each with a unique id: copy (copies copyText), retry (an action; Arc's outline pill with its label beside the icon), feedback_up and feedback_down (toggles, one at a time), and custom (label, icon and action). Each has a label, its accessible name (shown as a tooltip when tooltip is on, and as the text of retry), and an optional icon; at most one of each kind except custom.
copyTextstring—The text the copy button writes to the clipboard, usually the answer. Without it the copy button is not shown.
copiedLabelstringDefault: "Copied"Shown and announced after a successful copy.
failedLabelstringDefault: "Copy failed"Shown and announced when the browser refuses clipboard access.
defaultFeedbackup | down—Feedback given on first render: up or down. Later edits do not reset an existing instance.
defaultFeedbackOpenbooleanDefault: falseOpen the inline feedback panel on initial render when defaultFeedback or feedback is set.
feedbackPanelbooleanDefault: trueFollow-up panel under the thumbs: reason chips and an optional note after a thumbs down, a light "What was good" strip on a thumbs up. Pass false for bare instant-toggle thumbs.
negativeReasonsstring[]Default: ["Inaccurate","Not helpful","Too long","Unsafe","Other"]Reason chips offered after a thumbs down. Keep the labels short (one or two words) so they stay on one or two lines at 360px.
positiveReasonsstring[]Default: ["Accurate","Easy to follow","Good examples","Saved me time"]Chips offered after a thumbs up; pass an empty array to skip the follow-up.
allowCommentbooleanDefault: trueShow the optional note field after a thumbs down. Pressing the "Other" chip moves focus to it.
commentPlaceholderstringDefault: "Add details (optional)"Placeholder of the optional note field; it changes to "Tell us what went wrong" while the Other chip is picked.
commentMaxLengthintegerDefault: 1000Most characters the optional note accepts, 40 to 2000.
privacyNotestringDefault: "Shares this reply for review"Quiet note beside Submit for what gets shared; hidden below 400px.
thanksTitlestringDefault: "Thanks for the feedback"First line of the thank-you state after sending.
thanksMessagestringDefault: "It helps improve future replies."Second line of the thank-you state after sending.
thanksDurationintegerDefault: 1600How long the thank-you state holds before the panel folds away, in milliseconds, 400 to 5000.
feedbackActionstring—Host-registered action name sent with the submitted feedback details; collected by collectActions alongside the item actions, so a composition rejects it while it is not registered.
feedbackStatusidle | submitting | errorDefault: "idle"Send state of the details form, owned by the host: idle, submitting, or error (error shows the inline message and Try again).
feedbackErrorstring—Host-owned error message shown in the panel; omitted uses "Couldn’t send".
messageIdstring—Forwarded with every feedback event so the host can attach it to a message.
revealalways | hoverDefault: "hover"hover (the default, as in Arc) hides the buttons until the surrounding message (any article, or an element with data-reveal-scope) is hovered or a button has keyboard focus; on touch screens they show at .7 opacity. always shows them.
sizexs | sm | mdDefault: "xs"Button size: xs (the default: Arc's 28px round chat buttons with a 16px icon), sm (36) or md (44 pixels).
tooltipbooleanDefault: falseShow each icon button's name in a tooltip on hover and keyboard focus. Off by default, as Arc's chat buttons, which are named for assistive technology only.
disabledbooleanDefault: falseMake every button unavailable, e.g. while the answer streams.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeMessageActionsTheme—Color mode, accent, and tokens, emitted on the root and passed to every button and the inline feedback panel. See Theming.
motionnone | subtle | expressiveDefault: "subtle"Copy confirmation, hover reveal fade, thumb fill crossfade, and inline feedback panel height spring; the row buttons answer a press with color only, as Arc's chat buttons. Reduced motion keeps the 160ms reveal fade and crossfades the panel; none makes everything immediate.
motionOptionsMessageActionsMotionOptions—Press scale (1 by default, as in Arc) and label swap of the buttons.
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

MessageActionItem is a discriminated union on kind: { kind, id, label?, icon?, action? }, where retry and custom require action, and custom requires label and icon.

React integration

PropPurpose
onAction(action, itemId)Called for item actions (copy: after write) and feedbackAction (itemId is 'up' or 'down').
onCopyResult(copied)Called after every copy attempt with the clipboard write result.
feedback, onFeedbackChangeControlled rating ('up' | 'down' | null). onFeedbackChange fires in both controlled and uncontrolled modes.
onFeedbackSubmit(event, { signal })Async handler for stage: 'rating' and stage: 'details'; reject to trigger inline error and Try again.
trailingReact content pinned to the inline-end of the action row (for example, a timestamp or token count).
renderIcon(name, context)Custom icon renderer; context provides { size, slot: 'icon', itemId }.
presetApplication defaults layered below explicit instance props.
tokens--ui-* CSS variable overrides applied to the root, panel, and every child button.
ref, className, styleForwarded to the root role="group" container.
Native attributesStandard div attributes (id, aria-*, data-*) forwarded to the root container.

Keyboard & accessibility

KeyInteraction
TabMove through the action row and into the open inline feedback panel.
Enter, SpaceActivate copy, retry, custom action, thumb toggle, reason chip, or panel footer button.
Cmd/Ctrl + EnterSubmit feedback details directly from the note textarea.
EscapeFold the open feedback panel and return focus to its thumb while preserving the rating.
  • Thumb semantics: Thumbs expose aria-pressed, plus aria-expanded and aria-controls pointing at the open panel whenever a follow-up panel is enabled.
  • Focus management: A keyboard press on thumbs down moves focus to the first reason chip (or note field); pointer presses keep focus on the thumb. Clicking the "Other" chip moves focus to the note field and updates its placeholder. After a keyboard submit, focus lands on the thank-you message and returns to the thumb when the panel folds.
  • Live announcements: A pre-mounted role="status" live region announces rating updates, sending, thank-you confirmations, errors, and copy outcomes.
  • RTL and forced colors: All spacing and alignments use logical CSS properties (dir="rtl" supported). Under forced-colors: active, borders, pressed chips, active thumbs, and focus outlines map to system colors.

Motion and theming

The panel opens, closes, and resizes between the form and thank-you state on a bounce-free 0.24s measured height spring (ResizeObserver mounts only while open). The filled thumb fades over the outline in 160ms with zero layout shift, the form-to-thank-you transition crossfades (100ms out, 160ms in), and the success check draws in 280ms. Under prefers-reduced-motion: reduce, height changes cut immediately, press scales stop, and the hover reveal keeps its 160ms opacity fade. Setting motion="none" makes every transition 0ms immediate.

MessageActions emits all resolved --ui-* tokens inline on its root so it works standalone without a global stylesheet or provider.

TokenRole
--ui-surface, --ui-highlightPanel background, chip surface, and hover fills.
--ui-text, --ui-text-secondary, --ui-mutedActive thumbs, headings, chip labels, privacy note, meta.
--ui-border, --ui-border-strongPanel frame, chip edges, note focus edge, Retry pill hover.
--ui-accent, --ui-accent-foregroundPrimary Submit, Send, and Try again buttons.
--ui-danger, --ui-success, --ui-focus-ringInline error text, drawn check icon, keyboard focus rings.
--ui-radius, --ui-font, --ui-font-sizePanel and input corner radii and inherited typography.

Composition

In an agent composition, MessageActions is a leaf component. Every item action and feedbackAction is collected by collectActions and must name a host-registered action. Rating state persists at /components/instance-<id>/feedback and reconciles against the configured items. See Building with agents.

{
  "type": "MessageActions",
  "props": {
    "messageId": "msg_42",
    "copyText": "Three invoices are unpaid.",
    "feedbackAction": "submit_feedback",
    "items": [
      { "kind": "copy", "id": "copy" },
      { "kind": "retry", "id": "retry", "action": "retry_message" },
      { "kind": "feedback_up", "id": "good" },
      { "kind": "feedback_down", "id": "bad" }
    ]
  },
  "children": []
}

On this page