# Control glow

The edge a browser draws around a page while an agent drives it, with a badge and a Stop button. It holds still while the agent waits for you and drains away when you take over.

Example: Agent in control of a checkout. The agent fills the delivery details with the edge on, stops before paying and waits, then the person takes over and the edge drains away. Loops; use Stop or Resume to take over. Preview: https://chatcn.dev/preview/control-glow-demo

## Installation

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

## Usage

```tsx
import { ControlGlow } from "@/components/ui/chatcn/control-glow"

<ControlGlow
  state={driver}
  name="Agent"
  onStop={() => setDriver("user")}
  onResume={() => setDriver("agent")}
>
  <Page />
</ControlGlow>
```

Wrap whatever the agent is using. The edge is a 3 px line in `--chatcn-primary` (or `tone`) with a soft inner falloff, drawn on an overlay that ignores the pointer, so the page keeps working under it. It follows the corners of the box it wraps (`border-radius: inherit`); where the wrapper sits inside a parent without a radius, pass `radius` to match the screen, as on a phone screen with `radius={48}`.

- `agent`: the edge breathes slowly (55% to 100% over 2.4 s) and the badge shows the kit spinner, "Agent is in control" and Stop.
- `paused`: the edge eases to 60% and holds. The badge says "Waiting for you" with Resume.
- `user`: the edge drains from the top down in 300 ms and the badge says "You have control" for `noticeDuration`, then leaves.
- `off`: no edge and no badge.

The badge is one pill that reshapes to each message with `clip-path`, so nothing around it moves, and it sits below `--chatcn-safe-top` on a phone screen. It is a polite status region and its buttons are real buttons with 32 px hit areas (44 px on touch). A breath that resumes picks up from the opacity the edge already has, and the breath sleeps off screen. Under reduced motion the edge does not breathe and every change is a cut. In forced colors the edge becomes a 3 px `Highlight` outline.

## Examples

### States

Off, the agent in control, waiting for you and taken over, on a browser and on a phone screen.

Example: Control glow states. Off, the agent in control, waiting for you and taken over, on a browser and on a phone screen. Preview: https://chatcn.dev/preview/control-glow-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `state` | `off | agent | paused | user` | Who drives |
| `name` | `string` | Default "Agent": "Agent is in control" |
| `tone` | `string` | Edge and badge colour. Default `var(--chatcn-primary)` |
| `radius` | `number | string` | Default `inherit` |
| `badge` | `boolean` | Default true |
| `noticeDuration` | `number` | ms the takeover notice stays. Default 1600 |
| `onStop`, `onResume` | `() => void` | The badge buttons show when given |

Source: https://chatcn.dev/docs/components/control-glow