Queue
Hold the messages a person sends while the agent is busy, and let them reorder, edit, remove, or send one now.
Overview
Queue holds what a person sends while the agent is still working, in the order it will go. They can send the first item now, reorder the list, edit an item, or remove one.
It shows the items you pass and calls back on every change. Sending the next item when the agent is free is your application's work. It renders nothing when the queue is empty.
Anatomy
- HeaderThe count and the disclosure
- ItemIts position, text, and an optional note
- ActionsMove up, Move down, Edit, and Remove, when you handle them
- Send nowOn the first item, when you handle it
Installing queue brings Button, Collapsible, and Textarea along as registry dependencies.
Behavior
Actions
Each action appears only when you pass its handler. onMove receives the item's new index, onEdit the new text, and onRemove and onSendNow the item's id. Update items in response.
With a fine pointer the row actions stay quiet until the row is hovered or one of them has focus. On touch they are always shown.
Editing
Edit turns the item into a field. Enter or Save keeps the change, Shift+Enter adds a line, and Escape or Cancel leaves it as it was. Saving unchanged or empty text calls nothing.
Focus
Focus stays on Move up or Move down as the item moves, falling to the other one at either end. After Remove it moves to the next item's Remove, and after editing it returns to Edit.
Accessibility
The queue is a region named by its count, and the items are an ordered list. Every action is named with its item, such as "Remove: Skip anything under $50". Move up on the first item and Move down on the last are marked disabled but keep focus.
Installation
Usage
import { Queue } from "@/components/ai/queue"
<Queue
items={queue}
onSendNow={(id) => agent.interruptWith(take(id))}
onRemove={(id) => setQueue((items) => items.filter((item) => item.id !== id))}
onEdit={(id, text) => setQueue((items) => items.map((item) => (item.id === id ? { ...item, text } : item)))}
onMove={(id, toIndex) => setQueue((items) => move(items, id, toIndex))}
/>Examples
Above a Prompt Bar
What the person sends waits above the composer.
API reference
Queue
Accepts native section props beyond those listed.