# Inbox frame

A mail client with an agent in it: it sorts the inbox into labels, writes a summary over the open thread and drafts the reply.

Example: An agent works the inbox. Labels type onto five threads, the one that needs a reply opens with a summary, the reply drafts at 60% ink and turns full ink when ready, then it is sent and the row closes. Loops. Preview: https://chatcn.dev/preview/inbox-frame-demo

## Installation

```bash
npx shadcn@latest add https://chatcn.dev/r/inbox-frame.json
```

## Usage

```tsx
import { InboxFrame } from "@/components/ui/chatcn/inbox-frame"

<InboxFrame
  threads={[
    {
      id: "oak",
      from: "Ilse Varga",
      subject: "Revised quote for the Hollis Street oak",
      snippet: "The mill can hold the white oak until Friday at noon…",
      time: "9:41 AM",
      labels: ["Needs reply"],
    },
    { id: "visit", from: "Dmitri Sokol", subject: "Site visit moved to Wednesday", snippet: "…", time: "9:12 AM", unread: true },
  ]}
  selectedId="oak"
  summary={["The oak quote rose to $4,630.", "Ilse needs an answer by Thursday."]}
  body={<p>Hi Jonas, the mill came back on the white oak…</p>}
  draft={{ text: "Hi Ilse, let’s take the revised quote…", state: "ready" }}
  onSend={() => send()}
/>
```

The client lays out at a true 1280 by 800 viewport and scales to fit, with a browser bar (`chrome="none"` hides it): a rail of mailboxes, a 400 px list of 76 px rows and the reading pane. Unread threads are shown by weight alone, the sender in semibold and the subject in medium, never with a dot. The list is a `listbox`: arrow keys, Home and End move through it and open the thread under focus. Under a 900 px viewport one pane shows at a time and the open thread slides over the list with a back button.

A label added after the list first paints types onto its row, 16 ms a letter. Its slot holds the finished width from the first frame, so the subject beside it never moves. That is the only sign of the agent in the list.

A summary that arrives on an open thread unfolds: the block reveals from the top while the message under it slides down by the block's height, so nothing jumps. The draft streams word by word at 60% ink with the words still to come laid out but invisible, so the box is its final height from the first word; at `ready` it turns full ink and Send, Edit and Discard take the place of the writing label. At `sent` the thread's row closes from the bottom while the rows below slide up the same distance, and a Sent toast shows at the foot of the frame for 1.6 s. All of it moves with `transform`, `opacity` and `clip-path` only; under reduced motion it fades without moving.

## Examples

### States

Sorted, a summary on the open thread, a draft ready to send, a phone viewport and dark.

Example: Inbox frame states. Sorted, a summary on the open thread, a draft ready to send, a phone viewport and dark. Preview: https://chatcn.dev/preview/inbox-frame-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `threads` | `{ id, from, subject, snippet, time, unread?, labels? }[]` | Labels are outline chips after the subject |
| `selectedId`, `defaultSelectedId`, `onSelect` | `string | null` | Controlled or not; `onSelect(null)` from the narrow back button |
| `summary` | `string[]` | Two or three short lines over the open thread |
| `body` | `ReactNode` | The open thread's message |
| `draft` | `{ text, state: writing | ready | sent }` | At `sent` the open thread leaves the list |
| `onSend`, `onEdit`, `onDiscard` | `() => void` | The draft's buttons |
| `chrome`, `address` | `browser | none`, `string` | The browser bar and its address |
| `account` | `string` | Initials at the foot of the rail |
| `clearing` | `boolean` | Fades the list and pane out before a loop restarts |
| `viewport`, `width`, `bezel`, `radius` | Frame props | Default 1280 by 800, `hairline`, 12 |

Source: https://chatcn.dev/docs/components/inbox-frame