# Phone island

Agent status in the phone's cutout. A pill with a spinner and the step while an agent works, a card when it is done or needs a yes, and the assistant dropping out of it to answer. One black shape that grows out of the cutout on a spring.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Phone island. An agent finds a table in the background: the cutout widens with a spinner and the step, grows into a card that asks for a yes, shows the booking, then goes back to rest. Preview: https://chatcn.dev/preview/phone-island-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/phone-island
```

## Usage

```tsx
import { PhoneFrame } from "@/components/ui/chatcn/pro/phone-frame"
import { PhoneIsland } from "@/components/ui/chatcn/pro/phone-island"

<PhoneFrame
  width={320}
  cutout={
    <PhoneIsland
      status={task.status}
      step={`${task.done} of ${task.total}`}
      title={task.title}
      subtitle={task.detail}
      progress={task.done / task.total}
      actions={[
        { label: "Book", primary: true, onPress: task.confirm },
        { label: "Not now", onPress: task.dismiss },
      ]}
    />
  }
>
  <App />
</PhoneFrame>
```

Pass it as the phone frame's `cutout`: it replaces the drawn cutout and draws in the screen's own 393 px wide coordinates, above the content and the status bar. At rest it is the cutout, lens and all, so a phone with an idle island looks exactly like one without.

With `form="auto"` the status picks the form. `idle` rests. `working` widens into a pill with a spinner and the `step`; a press opens the card with the progress bar and a second press closes it. `needs-input` opens the card at once and keeps it open until an action is pressed. `done` shows a check for 2.4 s, held while the pointer or focus is on it, then rests. `error` opens the card with a red mark and your retry action. An `assistant` other than `off` wins over all of them.

The assistant drops out of the cutout as a circle holding the core while it listens, shrinks to a small circle while it thinks, and stretches into a card with your `children` when it answers. The core is the free voice orb; pass `core` to use any orb that takes the effect orb props.

`platform="dot"` is for phones without the pill: a dot after the clock pulses while the agent works, grows into a chip with the title when it needs you (press it for the same card, under the status bar), and flashes a check when it is done.

## Examples

### Every status and form

Example: Phone island states. Each status in each form, the assistant listening, thinking and answering, the dot platform and landscape. Preview: https://chatcn.dev/preview/phone-island-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `status` | `"idle" | "working" | "needs-input" | "done" | "error"` | Default `idle` |
| `step` | `string` | Compact trailing text while working, for example "3 of 8" |
| `title`, `subtitle` | `string` | The card's two lines. The title is announced |
| `icon` | `ReactNode` | The card's 36 px tile. Default the spinner |
| `progress` | `number` | 0 to 1. A bar in the card while working |
| `actions` | `{ label, onPress, primary? }[]` | Up to two buttons for needs-input, a retry for error |
| `form` | `"auto" | "rest" | "compact" | "expanded" | "assistant"` | Default `auto`. Force one for a still |
| `assistant` | `"off" | "listening" | "thinking" | "answering"` | Default `off` |
| `core` | `(props) => ReactNode` | The orb in the assistant |
| `children` | `ReactNode` | The assistant's answer |
| `onExpandedChange` | `(expanded: boolean) => void` | When the card opens or closes |
| `platform` | `"pill" | "dot"` | Default `pill` |
| `reducedMotion` | `boolean` | Defaults to the user's setting |

## Accessibility

- A polite status region named "Agent" announces the title when the status changes and a new step at most once every 3 s, not on every tick.
- The actions are real buttons with a 44 px tall hit area, and so is the dot platform's chip. A working island is a button that opens and closes the card, with `aria-expanded`; its focus ring is the island's own edge.
- When a status change takes away the control that had focus, focus moves to the new card's first action, or to the island, which then shows the same ring.
- Escape closes an open card that has no pending action.
- Reduced motion: the shape changes at once and the content crossfades in 120 ms, without blur or travel.
- The island is hardware: black in light and dark. Under `forced-colors` it keeps a 2 px system edge that follows its shape, and the actions and the progress bar keep system colors.

Source: https://chatcn.dev/docs/components/phone-island