# Hold to run

Approval you have to mean: hold the agent's command and ink fills the row through the text itself, inverting every letter it passes.

Also called: hold to confirm, press and hold.

> 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: Hold to run. Press and hold the command: ink fills the row through the text. Let go early and it drains back. The production deploy needs a longer hold and fills red. Preview: https://chatcn.dev/preview/hold-to-run-demo

A tap is too easy for a migration or a production deploy. Here the command is the button: press and hold and ink fills the row from the start, running through the command so each letter it passes turns to paper. Let go early and the fill drains back on a spring that keeps its speed, so a hesitant press reads as hesitation. Hold to the end and it runs; the row stays inked with a run check while it works, then clears.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/hold-to-run
```

## Usage

```tsx
import { HoldToRun } from "@/components/ui/chatcn/pro/hold-to-run"

<HoldToRun
  command="pnpm db:migrate --env production"
  tone="danger"
  holdMs={1800}
  status={status}
  onConfirm={run}
/>
```

## Examples

### States and tones

Example: Every state, both tones. Idle, running, done and failed, for a staging command and for a production one in the danger tone. Preview: https://chatcn.dev/preview/hold-to-run-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `command` | `string` | Shown in mono; the row is the button |
| `onConfirm` | `() => void` | Runs once the hold completes |
| `status` | `"idle" | "running" | "done" | "error"` | Drive it after confirm. Back to idle drains the ink |
| `holdMs` | `number` | Default 1100. Longer for anything destructive |
| `tone` | `"default" | "danger"` | Danger fills red |
| `icon` | `ReactNode` | Replaces the terminal glyph |
| `labels` | `Partial<Record<status | "holding", string>>` | Right side text per state |

## Keyboard

- Hold `Space` or `Enter` for the same time. Releasing early cancels.

## Accessibility

- A button named with its action and command. The inked copy of the row is `aria-hidden`.
- The right side label edits in place (Hold to run, Keep holding, Running) so the state is readable, not only visible.
- A context menu on long press is suppressed so a touch hold is not interrupted.

## Motion

- Filling is a steady ramp you control, eased so the first frames already show ink; draining is a spring that starts from the ink on screen, with its speed.
- The fill is a `clip-path` inset on an inverted copy of the row: one property, compositor friendly.
- The row presses to 0.985 while held. Reduced motion keeps the fill (it is the progress) and drops the ease.

Source: https://chatcn.dev/docs/components/hold-to-run