# Auto run timer

An action that runs by itself unless stopped, with the time left draining round the Cancel button.

Also called: auto run countdown, countdown button.

> 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: Runs unless you stop it. The next command runs in 5 s: the time left drains round Cancel, holds while you point at it, and gives way to a run check at zero. Preview: https://chatcn.dev/preview/auto-run-timer-demo

Agents that run steps on their own still need a moment to be stopped. The time left is drawn round the Cancel button, its outline draining as the seconds roll down. Point at the row and the clock holds while it waits for you; move away and it carries on. Cancel snaps the outline back and offers Run now. At zero the button gives way to a run check.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/auto-run-timer
```

## Usage

```tsx
import { AutoRunTimer } from "@/components/ui/chatcn/pro/auto-run-timer"

<AutoRunTimer
  action="pnpm biome check lib/session.ts"
  status={status}
  seconds={5}
  onRun={run}
  onCancel={cancel}
  onRunNow={run}
/>
```

## Examples

### States

Example: Counting, running, done, cancelled. The same command in each state of the timer. Preview: https://chatcn.dev/preview/auto-run-timer-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `action` | `string` | What will run |
| `status` | `"counting" | "running" | "done" | "cancelled"` |  |
| `seconds` | `number` | Default 5 |
| `onRun` | `() => void` | At zero |
| `onCancel` / `onRunNow` | `() => void` |  |
| `icon` | `ReactNode` | Replaces the terminal glyph |

## Accessibility

- Focus inside the row holds the clock too, so keyboard users get the same time to decide.
- The time left is a polite live region that changes once a second.

## Motion

- One frame clock that only advances while not held; the outline is `stroke-dasharray` on a `pathLength` 100 rect.
- The number re-renders once per second, not per frame.

Source: https://chatcn.dev/docs/components/auto-run-timer