# Chat History

> Conversation history sidebar: a New chat button with ⌘⇧O, search that highlights hits in titles and shows a matched snippet from the chat, a Pinned section and date groups. Each row's menu renames in place, pins (the row slides between sections), shares, archives or deletes behind an Undo strip. Live chats show a spinner, and arrow keys move between rows.

- Slug: `chat-history`
- Category: [AI chat](https://www.assembli.design/category/ai-chat.md)
- Type: block
- Tags: chat, history, sidebar, search, conversations
- npm dependencies: motion, lucide-react
- shadcn/ui dependencies: button, dropdown-menu, @assembli/avatar
- Live preview: https://www.assembli.design/preview/chat-history
- Page: https://www.assembli.design/components/chat-history

![Chat History preview](https://www.assembli.design/thumbnails/chat-history-light.png)

## Props

Other props pass through to the root element.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `conversations` (required) | `Conversation[]` |  |  |
| `activeId` | `string` |  | The open chat. Leave undefined to let the sidebar track it. |
| `defaultActiveId` | `string` |  |  |
| `onSelect` | `(id: string) => void` |  |  |
| `onNewChat` | `() => void` |  |  |
| `onRename` | `(id: string, title: string) => void` |  |  |
| `onPin` | `(id: string, pinned: boolean) => void` |  |  |
| `onShare` | `(id: string) => void` |  |  |
| `onArchive` | `(id: string) => void` |  | Called once the undo window closes. |
| `onDelete` | `(id: string) => void` |  | Called once the undo window closes. |
| `account` | `ChatHistoryAccount` |  |  |
| `now` | `Date` |  | Reference time for the date groups. Defaults to now. |
| `undoMs` | `number` | `5000` | How long Undo stays offered, in ms. |

## Install

One-time setup (needs a subscription):

1. Add the registry to the project's `components.json`: `{"@assembli":{"url":"https://www.assembli.design/r/{name}.json","headers":{"Authorization":"Bearer ${ASSEMBLI_API_KEY}"}}}` (merge into `"registries"`).
2. Put an API key from https://www.assembli.design/account in `.env.local` as `ASSEMBLI_API_KEY=asm_…`.

Then install with the shadcn CLI (writes `components/chat-history/chat-history.tsx` and installs dependencies):

```bash
npx shadcn@latest add @assembli/chat-history
```

Registry item JSON: https://www.assembli.design/r/chat-history.json (send `Authorization: Bearer <api key>`)

## Code

> Component source needs an Assembli subscription ($12/month or $96/year) and an API key sent as `Authorization: Bearer <key>`. To get one without copying anything, POST https://www.assembli.design/api/agent/login (or call the MCP tool connect_account), show the user the link it returns, and poll https://www.assembli.design/api/agent/token for the key. Or subscribe at https://www.assembli.design/pricing and create a key at https://www.assembli.design/account.
