# Task log

> What the agent did, task by task, as it does it: steps arrive on a hairline trail, files sit in chips, titles turn past tense.

An agent that edits code should show its work without dumping a terminal on people. The task log groups what it did under plain titles: while a task runs its title carries a sweep of light and its steps arrive one at a time on a hairline trail, each opening to its height and rising out of a light blur, the newest shimmering. Files it read or changed sit in small chips, and outcomes like "52 files" or "0 errors" trail after in a quieter grey. When a task finishes its title morphs into the past tense, "Finding project files" becoming "Found project files", and its steps can fold away. Once everything has settled, "Run again" folds in underneath.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/task-log.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: `lucide-react`
- Hairline UI components it needs (the CLI installs them too): `text-morph`
- Docs and live preview: https://hairlineui.com/ui/task-log
- Registry item (source): https://hairlineui.com/r/task-log.json

## Usage

```tsx
import { TaskLog } from "@/components/task-log";

<TaskLog
  tasks={[
    { id: "find", title: "Finding project files", doneTitle: "Found project files", status: "done",
      steps: [{ id: "1", text: "Read", file: "page.tsx" }, { id: "2", text: "Scanning", detail: "52 files" }] },
  ]}
  onRerun={rerun}
/>
```

## With the AI SDK

```tsx
"use client";
import { useChat } from "@ai-sdk/react";
import { TaskLog, type TaskLogTask } from "@/components/task-log";

// Each data-task part streams { id, title, doneTitle, status, steps } as the agent works.
export function AgentWork() {
  const { messages, regenerate } = useChat();
  const last = messages.at(-1);
  const tasks = (last?.parts ?? []).flatMap((p) => (p.type === "data-task" ? [p.data as TaskLogTask] : []));
  return <TaskLog tasks={tasks} onRerun={() => regenerate()} />;
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `tasks` | `TaskLogTask[]` | – | { id, title, doneTitle?, icon?, status, steps } in order; status is "running", "done" or "error". |
| `steps` | `TaskLogStep[]` | – | On each task: { id, text, file?, detail? }. A file shows as a chip, detail trails after in grey. |
| `onRerun` | `() => void` | – | Shows "Run again" once no task is running. |
| `rerunLabel` | `string` | `"Run again"` | The button’s words. |

## States

- **running**: A 1.4s sweep of light crosses the task title and the newest step. Each step opens to its height (380ms) and rises 4px out of a 4px blur; tasks arrive the same way.
- **done**: The title morphs from title to doneTitle, keeping the letters they share, and the sweep stops. The title is a disclosure: the chevron turns and the steps fold away (380ms).
- **error**: The title turns red behind an alert icon, keeping the steps that ran.
- **rerun**: With onRerun, "Run again" folds open under the log once no task is running.

## What it handles

An agent that edits code should show its work without dumping a terminal on people. This groups what the agent did under plain titles, and lets people open the detail when they want it.

- **Steps arrive as it works**: Each step opens to its height and rises out of a light blur on a hairline trail. The newest one shimmers.
- **Files in chips**: Files it read or changed sit in small chips, and outcomes like “52 files” or “0 errors” trail after in grey.
- **Titles turn past tense**: “Finding project files” becomes “Found project files” when the task finishes.
- **Tasks fold away**: Each title is a disclosure, so finished steps can be tucked away.
- **Errors stay readable**: A failed task turns its title red behind an alert icon and keeps the steps that ran.
- **Run again, quietly announced**: “Run again” folds in once nothing is running. A polite status names the running task, and never re-reads the whole log.

## Replaces

a step list, file chips, a task disclosure, past-tense title logic, a Run again button

## Where it fits

- **Coding agents**: Show which files the agent read and changed, task by task.
- **Automation and workflow runs**: Group what a run did under plain titles.
- **Deploy and migration logs**: A short summary for each task, with the details a click away.
- **Research agents**: The queries run and the sources read while an answer is prepared.

## Notes

- Each task title is a button with aria-expanded controlling its steps, which are inert while folded.
- A polite status region names the running task and its newest step, then "All tasks finished"; it never re-reads the whole log.
- The sweep of light is a moving mask, so it reaches letters that are mid-morph; with reduced motion there is no sweep and steps simply appear.
- Steps and tasks present on the first render don’t animate, so a finished log renders still.
- Installs Text morph.

License: MIT (https://hairlineui.com/license#components)
