shadcn.io is an independent project built on shadcn/ui
On this page11 sections
Queue shows the to-do list an agent keeps while it works, in two sections: To do, with what's left, and Completed. Each section is a line with its count that opens onto its items, and an item moves from one section to the other when the agent marks it done.
Use Plan when the agent settles every step before it starts and you want a count of how far it has got. For the steps of one piece of work as the agent takes them, use Task.
Installation
Queue is a pattern. The command adds the part it's built from, Trace, and the code to copy is the demo's.
Anatomy

Usage
<script lang="ts">
import {
CircleCheckIcon, CircleIcon, ListChecksIcon, ListTodoIcon,
} from "lucide-svelte";
import {
Trace, TraceCollapsible, TraceCollapsibleContent,
TraceCollapsibleTrigger, TraceIcon, TraceLine, TraceTitle,
} from "@/components/ui/trace";
</script>
<Trace>
<TraceCollapsible>
<TraceCollapsibleTrigger>
<TraceLine>
<TraceIcon>
<ListTodoIcon aria-hidden="true" />
</TraceIcon>
<TraceTitle>2 to do</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<Trace>
<TraceLine>
<TraceIcon>
<CircleIcon aria-hidden="true" />
</TraceIcon>
<TraceTitle>Update the registry snapshots</TraceTitle>
</TraceLine>
<TraceLine>
<TraceIcon>
<CircleIcon aria-hidden="true" />
</TraceIcon>
<TraceTitle>Add tests for the combobox</TraceTitle>
</TraceLine>
</Trace>
</TraceCollapsibleContent>
</TraceCollapsible>
<TraceCollapsible>
<TraceCollapsibleTrigger>
<TraceLine>
<TraceIcon>
<ListChecksIcon aria-hidden="true" />
</TraceIcon>
<TraceTitle>1 completed</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<Trace>
<TraceLine>
<TraceIcon>
<CircleCheckIcon aria-hidden="true" />
</TraceIcon>
<TraceTitle>Add a changeset</TraceTitle>
</TraceLine>
</Trace>
</TraceCollapsibleContent>
</TraceCollapsible>
</Trace>
Each section is a TraceCollapsible whose content holds a second Trace, one line per item.
Add defaultOpen to the To do section's TraceCollapsible to show what's left from the start, as both demos do.
Accessibility
Each section line is a button with aria-expanded, so a screen reader hears its count, such as 2 to do, and whether its items are showing, and Enter or Space opens or closes it. An item with a description is a button too, while a plain item is text and takes no focus. The section an item sits in tells people whether it's done, but the item in progress differs only by its hidden icon and its shimmer. The demo at the top of the page starts that item's title with In progress in an sr-only span, so a screen reader says it.
- Tab
- Moves focus to the next section line, or to an item with a description inside an open section. Plain items are skipped.
- Shift+Tab
- Moves focus to the previous section line or item.
- Enter
- When focus is on a section or an item, opens or closes it.
- Space
- When focus is on a section or an item, opens or closes it.
Demos
Descriptions
Five to-dos, three of them with a description. An item with one is a TraceCollapsible that opens onto a line of context, and an item without one stays a plain TraceLine. To do starts open and Completed closed, so what's left comes first. Keep the task itself in the title, and save the description for what the title can't say, such as why the focus ring is clipped.
AI SDK
With the AI SDK, give the agent a tool that writes its whole to-do list, writeTodos here, and pass it to streamText so each call reaches the client as a tool-writeTodos part.
const writeTodos = tool({
description: "Write the whole todo list again whenever a todo changes.",
inputSchema: z.object({
todos: z.array(
z.object({
content: z.string(),
status: z.enum(["pending", "in_progress", "completed"]),
})
),
}),
execute: async () => "Saved.",
});Every call carries the whole list, so render the last one. Skip a call whose input is still streaming, since it holds only part of the list.
import { Chat } from "@ai-sdk/svelte";
const chat = new Chat({});
const todos = $derived(
(chat.messages.at(-1)?.parts ?? [])
.filter((part) => part.type === "tool-writeTodos")
.filter((part) => part.state !== "input-streaming")
.at(-1)?.input?.todos
);Map each item's status to a section, an icon and a TraceLine status. Give the item in progress the running status only while the chat streams, so its title stops shimmering when the agent stops.
| Item status | Section | Icon | TraceLine status |
|---|---|---|---|
pending | To do | CircleIcon | none |
in_progress | To do | CircleDotIcon | "running" while the chat streams |
completed | Completed | CircleCheckIcon | none |
Migrating from AI SDK Elements
AI SDK Elements is for React. In Svelte, start from the demo above: its two sections are all there is to Queue.
FAQ
When should I use Queue instead of Plan?
Use Queue for a to-do list the agent keeps and rewrites as it works, where what matters is what's left. Items can be added, reordered or dropped between updates, and the two sections only say which are done.
Use Plan for steps the agent settles before it starts, shown in order under one line with a count such as 2 of 4 done. A plan reads as a route through the job, a queue as a list of open work.
Why does Queue split To do and Completed into two sections?
So people see what's left without reading past what's done. Each section's title carries its count, so a closed section still says how much it holds, and Completed can stay folded once the list grows, as in the Descriptions demo.
Hide a section while it's empty, as the demo at the top of the page does. An empty Completed line would be a button that opens onto nothing, and 0 completed reads as noise at the start of the work.
How do I show which Queue item is in progress?
Give it a dot icon instead of an empty circle, and the running status on its TraceLine, which makes its title shimmer. Set the status only while the chat streams, so an item doesn't look busy after the agent stops.
The item stays in To do while it's in progress, and moves to Completed with a check once the agent marks it done. The icon and the shimmer aren't announced, so the demo at the top of the page also starts that item's title with In progress in an sr-only span.
How do I add a description to a Queue item?
Make that item a TraceCollapsible, with its line in the trigger and the description in TraceCollapsibleContent, as the Descriptions demo does. The item gets a chevron and becomes a button that opens onto the sentence.
Leave an item with nothing more to say as a plain TraceLine, so it isn't a tab stop that opens onto nothing. Keep the task in the title and use the description for the why or the how.
How do I stop a long Queue from taking over the chat?
Start Completed closed, so the finished items fold behind one line with their count, as the Descriptions demo does. For a To do section that still runs long, give its inner Trace a maximum height and overflow-y-auto, such as max-h-48 overflow-y-auto, so the list scrolls inside the message.
Don't cut items from the list to save room. People open the queue to see everything the agent still means to do.
How do I show the latest Queue when the agent wrote it in an earlier message?
Search back through the messages instead of reading only the last one. Each writeTodos call carries the whole list, so the newest complete call anywhere in the conversation is the current queue, and earlier calls can be ignored.
Start from the end of the messages, take the first one that has a tool-writeTodos part whose input has finished streaming, and render that call's list. A new turn that doesn't touch the list then still shows it.
Is this the same as the AI SDK Elements Queue?
It does the same job without a wrapper of its own. Each section is a TraceCollapsible, each item a TraceLine, and the scroll area around the list is gone, so the list grows with the message unless you give it a height.
AI SDK Elements is for React, so in Svelte start from the demo at the top of the page, which holds the whole pattern.
API Reference
Queue has no props of its own. Each section and each item is a Trace line: TraceCollapsible holds a section's open state, and TraceLine takes an item's status.












