Back to Snippets

AI Agent Task Timeline JS

A progress view for an AI agent working through a task. Each step shows its title, the tool it calls and what came back, with a spinner while it runs, a check when it finishes and its own time. The progress bar and the total timer sit at the top. The third step fails on its first try to show the error state, and Retry step carries on from there. Stop halts the current step, and Run again starts over.

The steps come from a plain array of objects, so the list and the progress count build themselves from your data. Replace runStep with a real tool call that resolves to true or false, and pass its AbortSignal to fetch so Stop can cancel the call. A rejected call shows as a failed step with its error message. The step icons are drawn in CSS from a data-state attribute (pending, running, done, failed or stopped), and the line between two steps turns green once the first one is done.

The running step gets aria-current set to step, and every step carries hidden state text, so screen readers hear Done or Failed before the title. The bar has the progressbar role with aria-valuenow and a readable aria-valuetext. A hidden status region announces each step as it starts, and the card follows a dark color scheme when the system uses one.

0
#javascript
#css
#ai
#agent
#timeline
#steps
#progress bar
#status