Skip to documentation content

Queue

Hold the messages a person sends while the agent is busy, and let them reorder, edit, remove, or send one now.

queue-demo

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

Queue
  • 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.

KeyAction
TabMove across the header and the actions
Enter or SpaceOpen or close the queue, or press the focused action
EscapeCancel an edit

Installation

npx honestui@latest add queue

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.

queue-prompt-bar

API reference

Queue

Accepts native section props beyond those listed.

PropTypeDefaultDescription
itemsQueueItem[]RequiredWhat waits, first to last.
onSendNow(id: string) => voidNonePassing it shows Send now on the first item.
onRemove(id: string) => voidNonePassing it shows Remove.
onEdit(id: string, text: string) => voidNonePassing it shows Edit.
onMove(id: string, toIndex: number) => voidNonePassing it shows Move up and Move down.
defaultOpenbooleantrueWhether the list starts open.
openbooleanNoneControls whether the list is open.
onOpenChange(open: boolean) => voidNoneCalled when the header is pressed.
labelsPartial<QueueLabels>EnglishThe header, action names, and edit field name.

Types

ExportShape
QueueItemid, text, and an optional meta