# Message actions

Copy, retry and rate under an agent's reply. Each action appears only when its handler is given. Copy reports what the clipboard did: the icon stays a copy icon until the write settles, then becomes a tick (or a cross when the clipboard refused). A rating is the caller's state, so it shows only what the service recorded.

- Registry name: `message-actions` (`@candor/message-actions`)
- Tier: Free (MIT). No licence key needed.
- Docs: https://candor.themethodic.com/docs/message-actions

## Install

```bash
npx candor-ui add message-actions
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/message-actions`.
It brings in: locale, tooltip, use-copy, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import * as React from "react"
import { MessageActions, type Rating } from "@/components/message-actions"

export default function Example() {
  const [rating, setRating] = React.useState<Rating>(null)
  return <MessageActions text="It shipped this morning." rating={rating} onRate={setRating} onRetry={() => {}} meta="claude-sonnet-5-5 · $0.003" />
}
```

## <MessageActions>

Props:

- `text?: string | undefined`: What Copy copies; without it there's no Copy.
- `onRetry?: (() => void) | undefined`: Shows Retry.
- `rating?: Rating | undefined`: The current rating: up, down or none.
- `onRate?: ((rating: Rating) => void) | undefined`: Shows thumbs up and down.
- `meta?: React.ReactNode | undefined`: Facts after the actions, e.g. the model and cost.
- `className?: string | undefined`

## Strings (`messageActions`)

The fixed words, English by default. Override any of them under `messageActions` in `<LocaleProvider strings={{ messageActions: { … } }}>`; the table is exported as `messageActionsStrings`.

- `copy`: Copy
- `copied`: Copied
- `copyFailed`: Couldn’t copy
- `retry`: Retry
- `good`: Good answer
- `bad`: Bad answer

## Types

### Rating

```ts
"up" | "down" | null
```

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
