# Message branches

Page through versions of a reply (after a retry or an edited question): "‹ 2 / 3 ›". Lives in the message actions row.

- Registry name: `message-branches` (`@candor/message-branches`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/message-branches

## Install

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

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

## Example

```tsx
"use client"

import * as React from "react"
import { MessageBranches } from "@/components/message-branches"

const versions = [
  "The migration adds a nullable region column to orders, so it’s safe to run on Production.",
  "The migration adds a nullable region column to orders. It takes a brief lock, so run it outside peak hours.",
  "The migration adds region to orders. Backfill it on Staging first; the table has 1.2M rows.",
]

export default function Example() {
  const [index, setIndex] = React.useState(versions.length - 1)
  return (
    <div className="flex max-w-lg flex-col gap-2">
      <p className="text-sm">{versions[index]}</p>
      <MessageBranches index={index} count={versions.length} onChange={setIndex} />
    </div>
  )
}
```

## <MessageBranches>

Props:

- `index: number`: The version shown, from 0.
- `count: number`: How many versions there are. Renders nothing below 2.
- `onChange: (index: number) => void`: Called with the index of the version to show when a person pages back or forward.
- `className?: string | undefined`

## Strings (`messageBranches`)

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

- `versions`: Versions of this reply
- `previous`: Previous version
- `next`: Next version
- `position`: {index} / {count}

## 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`.
