# React Native AI Agent Activity, step log (Pro)

> A React Native AI agent activity view for iOS, Android and the web: each step an agent takes (thinking, searching, tools, code, files) with spinners, durations, inputs, outputs and sources, nested steps, approvals, Stop and Try again, and a one-line summary.

# Agent activity Pro

What an AI agent is doing, step by step, as Claude, Cursor and Copilot show their agents' work: thinking, planning, searching, running tools and code, reading and editing files. Each step has a spinner and a soft shimmer while it runs, its time, and what it was given and returned folded under it. Steps can nest; a step that needs permission shows Approve and Deny; the run shows its state and time ("Working… 42s · 8 steps"), with Stop and Try again, and folds to that one line.

```tsx
import { AgentActivity } from '@patine-ui/pro';
```

```tsx live full
import { AgentActivity } from '@patine-ui/pro';

const script = [
  { id: 's1', kind: 'plan', title: 'Planned the fix', detail: 'Reproduce, find the cause, patch, run the tests.', durationMs: 2100 },
  { id: 's2', kind: 'search', title: 'Searched the codebase', input: 'toISOString date tests', sources: [{ title: 'date.utils.ts' }, { title: 'calendar.utils.test.ts' }], durationMs: 3400 },
  { id: 's3', kind: 'code', title: 'Ran the failing test', input: 'pnpm test calendar.utils', output: 'Expected 2026-03-10, received 2026-03-09', durationMs: 8200 },
  { id: 's4', kind: 'file', title: 'Edited calendar.utils.ts', detail: 'Use toDateKey instead of toISOString', durationMs: 1200 },
  { id: 's5', kind: 'code', title: 'Ran the full suite', output: '1,284 passed', durationMs: 26000 },
];

export default function Example() {
  const [shown, setShown] = React.useState(1);
  React.useEffect(() => {
    if (shown > script.length) return;
    const id = setTimeout(() => setShown((n) => n + 1), 1400);
    return () => clearTimeout(id);
  }, [shown]);
  const steps = script.slice(0, shown).map((s, i) => (i === shown - 1 && shown <= script.length ? { ...s, status: 'running', durationMs: undefined, startedAt: new Date() } : { ...s, status: 'done' }));
  return <AgentActivity steps={steps} task="Fix the flaky date test" onStop={() => setShown(script.length + 1)} onRetry={() => setShown(1)} style={{ width: 460 }} />;
}
```

## Example: an agent that asks first

A support agent working a refund: it reads the order and the policy on its own, then stops at the step that moves money and waits for a person. Approve finishes the run; Deny ends it with a note.

```tsx live full
import { useState } from 'react';
import { View } from 'react-native';
import { AgentActivity } from '@patine-ui/pro';

const BEFORE = [
  { id: 'a', kind: 'search', title: 'Looked up order #20417', status: 'done', durationMs: 900, sources: [{ title: 'Order #20417' }] },
  { id: 'b', kind: 'browse', title: 'Read the refund policy', status: 'done', durationMs: 2100, sources: [{ title: 'Returns and refunds' }] },
  { id: 'c', kind: 'thinking', title: 'Eligible: delivered 6 days ago, unworn', status: 'done', durationMs: 1200 },
];

export default function Example() {
  const [answer, setAnswer] = useState<'waiting' | 'approved' | 'denied'>('waiting');
  const steps = [
    ...BEFORE,
    {
      id: 'd',
      kind: 'tool',
      title: 'Refund €107.00 to Visa •••• 4242',
      detail: 'payments.refund({ order: 20417, amount: 10700 })',
      status: answer === 'waiting' ? 'waiting' : answer === 'approved' ? 'done' : 'error',
      durationMs: answer === 'approved' ? 1400 : undefined,
    },
    ...(answer === 'approved' ? [{ id: 'e', kind: 'message', title: 'Emailed Lena: refund on its way, 3–5 days', status: 'done', durationMs: 800 }] : []),
  ];
  return (
    <View style={{ width: '100%', maxWidth: 480 }}>
      <AgentActivity
        steps={steps}
        task="Lena Novak wants a refund for order #20417"
        status={answer === 'waiting' ? 'running' : answer === 'approved' ? 'done' : 'error'}
        onApprove={() => setAnswer('approved')}
        onDeny={() => setAnswer('denied')}
        onRetry={() => setAnswer('waiting')}
      />
    </View>
  );
}
```

## Steps

A step is `{ id, kind?, title, detail?, status, startedAt?, endedAt?, durationMs?, input?, output?, sources?, children? }`. `kind` picks the icon: `'thinking'`, `'plan'`, `'search'`, `'browse'`, `'tool'`, `'code'`, `'file'` or `'message'`. `status` is `'pending'`, `'running'`, `'waiting'` (for approval), `'done'`, `'error'` or `'skipped'`. Times come from `startedAt` and `endedAt` (a running step counts up each second) or `durationMs`. Steps with `input`, `output` or `sources` open to show them; `expanded`, `defaultExpanded` and `onExpandedChange` control which are open.

## The run

`status` is the run's state, worked out from the steps unless you pass it: running, waiting, done, failed, stopped or idle. `onStop` shows Stop while it runs, `onRetry` shows Try again after a failure or a stop. The header folds the steps away into its summary: `collapsed`, `defaultCollapsed` and `onCollapsedChange` control it.

## Approvals and nesting

A step `'waiting'` for permission shows Approve and Deny when `onApprove` and `onDeny` are set; the card's border turns amber while it waits. `children` nest sub-steps under a step, as a sub-agent's work.

```tsx live full
import { AgentActivity } from '@patine-ui/pro';

const steps = [
  { id: 'a', kind: 'thinking', title: 'Thought about the request', status: 'done', durationMs: 1800 },
  {
    id: 'b',
    kind: 'tool',
    title: 'Research agent',
    status: 'done',
    durationMs: 14200,
    children: [
      { id: 'b1', kind: 'browse', title: 'Read the Stripe docs', status: 'done', durationMs: 5100, sources: [{ title: 'Payment Intents', url: 'https://docs.stripe.com/payments/payment-intents' }] },
      { id: 'b2', kind: 'search', title: 'Searched past tickets', status: 'done', durationMs: 2300 },
    ],
  },
  { id: 'c', kind: 'code', title: 'Run database migration', detail: 'ALTER TABLE invoices ADD COLUMN currency', status: 'waiting' },
];

export default function Example() {
  const [log, setLog] = React.useState('');
  return (
    <View style={{ gap: 8, width: 460 }}>
      <AgentActivity steps={steps} title="Billing agent" onApprove={(s) => setLog(`Approved: ${s.title}`)} onDeny={(s) => setLog(`Denied: ${s.title}`)} />
      <Text>{log}</Text>
    </View>
  );
}
```

## Variants

`variant` is `'card'` (the default), `'timeline'` (no card) or `'compact'` (tight rows with small markers, for a chat bubble).

```tsx live full
import { AgentActivity } from '@patine-ui/pro';

const steps = [
  { id: '1', kind: 'search', title: 'Searched the web', status: 'done', durationMs: 2400 },
  { id: '2', kind: 'browse', title: 'Read 4 pages', status: 'done', durationMs: 6100 },
  { id: '3', kind: 'message', title: 'Wrote the answer', status: 'error', durationMs: 900, detail: 'The model timed out.' },
];

export default function Example() {
  return <AgentActivity steps={steps} variant="compact" onRetry={() => {}} style={{ width: 380 }} />;
}
```

## Accessibility

Each step is read with its status and time ("Searched the codebase, Done, 3.4s"), says whether it opens, and the run's summary is a polite live region, so screen readers hear progress without being interrupted. Spinners and the shimmer stop when the OS asks to reduce motion.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `steps` | `AgentStep[]` | — | See [Steps](#steps). |
| `status` | `'running'` \| `'waiting'` \| `'done'` \| `'error'` \| `'stopped'` \| `'idle'` | from the steps | |
| `title` / `task` | `string` | `'Agent'` | |
| `variant` | `'card'` \| `'timeline'` \| `'compact'` | `'card'` | |
| `expanded` / `defaultExpanded` / `onExpandedChange` | `string[]` | `[]` | Open steps. |
| `collapsed` / `defaultCollapsed` / `onCollapsedChange` | `boolean` | `false` | |
| `onStop` / `onRetry` | `() => void` | — | |
| `onApprove` / `onDeny` | `(step) => void` | — | |
| `onSourcePress` | `(source) => void` | opens its URL | |
| `showDurations` | `boolean` | `true` | |
| `now` | `Date` | a ticking clock | |
| `renderDetail` | `(info) => ReactNode` | — | A step's open details. |
| `density` / `animate` / `labels` / `design` / `theme` / `style` | | | |
