Task
Show the steps an agent takes for one task, as it takes them.
Use a task to follow one piece of work an agent carries out, like a change across a few files. Its header shows how many steps are done, and it opens into the steps, each with its status and the files it touched.
- Read the request handlers
src/server.ts - Write the rate limit middleware
src/middleware/rate-limit.ts - Add tests for the limits
Installation
npx shadcn@latest add @kind-ui/taskComposition
Task
├── TaskTrigger
│ ├── TaskIcon
│ ├── TaskTitle
│ └── TaskMeta
└── TaskContent
└── TaskList
└── TaskItem
├── TaskItemIcon
├── TaskItemTitle
└── TaskItemFilesTask renders the trigger and content when you pass no children. Its trigger is a native button that shows or hides the list. TaskTitle shows the label, or "Task" without one, and TaskMeta how many steps are complete, like "1 of 3". TaskList renders an item for each of the items when you pass it no children, and each item shows its status mark, title and files unless you give it children. TaskItemFiles renders only while the item has files.
Usage
Items
Pass the steps as items, each with an id, a status of pending, running, complete or error, a title and optional files. Update an item's status as it runs, and keep its id: focus follows the id.
Without a status of its own, the task's status is what the items add up to: error once one fails, complete once all are complete, running once one runs or is complete, and pending before that. Pass status to set it yourself, like awaiting-input while the agent waits for an answer.
Opening and Closing
The task opens and closes like a Step: it opens while it runs or waits for input, closes when it completes, and stays open when it fails, until someone opens or closes it. Pass open with onOpenChange to control it, or autoOpen="never" to keep it closed until someone opens it.
Keyboard
The items are one Tab stop. The arrow keys move between them, and Home and End go to the first and last. When the focused item is removed, focus moves to its neighbor. Screen readers read each item's status, then its title, and the running one as the current step.
Streaming
A new item fades in once as it arrives, at the end of the list, so nothing above it moves. A status change morphs only the item's mark, so the rows never shift. A removed item leaves at once.
Screen readers hear an item's title and its outcome, like "Add tests for the limits complete", when it completes or fails, and nothing while it runs. Items that end in the same update, and the task itself, are read in one message.
Motion
Marks morph between statuses, and the list grows open and shut. Under prefers-reduced-motion, or with motion="reduced", they fade over 120 ms instead and nothing moves or spins, and with motion="none" they change at once.
API Reference
Prop
Type
Agent
An agent connected with createAgent finds the task by its title and reads its open and status. It can run these actions, and press the trigger like a person would.
Prop
Type
Runs in React and Web Components. On <kind-task>, items is a property only, other props are kebab-case attributes, so autoOpen is auto-open, and onOpenChange fires openchange. The element fills in its parts when it has no children, and keeps a <kind-task-item> in its list for each item.