# BranchSwitcher

Move between versions of a conversation created by edits and retries.

- **Use it for**: Moving between branches created by edits and regenerations.
- **Not for**: Separate conversations. Try [ThreadList](https://unseenui.com/components/thread-list/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { BranchSwitcher } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<BranchSwitcher variant="segmented" branches={branches} value={branchId} onValueChange={selectBranch} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `branches` (required) | `readonly ConversationBranch[]` |  |
| `changeGuard` | `BranchChangeGuard` |  |
| `className` | `string` | Added to the root element, after the component's own classes. |
| `connection` | `"unknown" \| ConnectionState` |  |
| `context` | `ConversationContext` |  |
| `disabled` | `boolean` |  |
| `onPageChange` | `((index: number) => void)` |  |
| `onReconcile` | `((operation: NavigationOperation) => void)` |  |
| `onRequestPage` | `((request: ConversationPageRequest) => void)` |  |
| `onRequestSelect` | `((request: BranchSelectionRequest) => void)` |  |
| `onValueChange` | `((branch: ConversationBranch) => void)` |  |
| `operation` | `NavigationOperation` |  |
| `pagination` | `ConversationPagination` |  |
| `status` | `NavigationAvailability` |  |
| `value` | `string` |  |
| `variant` | `"select" \| "cards" \| "segmented"` |  |

## Keyboard

Tab reaches controls; Enter or Space activates buttons. Accordions use arrow keys, Home and End. Select menus support arrows and typeahead; Escape closes menus and dialogs and restores focus.

## Works with

[Reasoning](https://unseenui.com/components/reasoning/), [SuggestTextarea](https://unseenui.com/components/suggest-textarea/), [Checkpoint](https://unseenui.com/components/checkpoint/), [SlashCommandMenu](https://unseenui.com/components/slash-command-menu/), [ThreadList](https://unseenui.com/components/thread-list/), [MessageQueue](https://unseenui.com/components/message-queue/), [PromptInput](https://unseenui.com/components/prompt-input/), [Message](https://unseenui.com/components/message/), [MessageActions](https://unseenui.com/components/message-actions/), [StreamingResponse](https://unseenui.com/components/streaming-response/), [Suggestions](https://unseenui.com/components/suggestions/), [FollowUps](https://unseenui.com/components/follow-ups/)

Page: https://unseenui.com/components/branch-switcher/
