The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(message-queue): render queue items through assistant-ui primitives
Steven Enamakel1b6da2dc4d4d
diff --git a/app/src/components/assistant-ui/elements/message-queue.tsx b/app/src/components/assistant-ui/elements/message-queue.tsxindex 635118ee1f..62d04b9a46 100644--- a/app/src/components/assistant-ui/elements/message-queue.tsx+++ b/app/src/components/assistant-ui/elements/message-queue.tsx@@ -14,7 +14,7 @@*/import { cn } from '@/components/assistant-ui/lib/utils';import { ArrowUpIcon, XIcon } from 'lucide-react';-import type { ComponentProps } from 'react';+import type { ComponentProps, ReactNode } from 'react';import { field, ghostButton, mono, paper } from './surfaces';@@ -25,7 +25,9 @@ export interface QueuedMessage {export function MessageQueue({running,- queued,+ queued = [],+ queuedCount = queued.length,+ children,onCancel,runningLabel = 'running',queuedLabel = (count: number) => `${count} queued`,@@ -35,7 +37,10 @@ export function MessageQueue({...props}: Omit<ComponentProps<'div'>, 'children' | 'running' | 'queued' | 'onCancel'> & {running: string;- queued: readonly QueuedMessage[];+ queued?: readonly QueuedMessage[];+ queuedCount?: number;+ /** Native runtime queue rows; omitted by standalone previews. */+ children?: ReactNode;onCancel?: (id: string) => void;runningLabel?: string;queuedLabel?: (count: number) => string;@@ -56,40 +61,39 @@ export function MessageQueue({<span className={cn(mono, 'text-foreground/35 shrink-0')}>{runningLabel}</span></div>- {queued.length > 0 && (+ {queuedCount > 0 && (<div className="flex items-baseline justify-between px-1">- <span className={cn(mono, 'text-foreground/35')}>{queuedLabel(queued.length)}</span>+ <span className={cn(mono, 'text-foreground/35')}>{queuedLabel(queuedCount)}</span><span className={cn(mono, 'text-foreground/35')}>{pendingHint}</span></div>)}<ul className="flex flex-col gap-1.5">- {queued.map((message, index) => (- <li+ {children ?? queued.map((message, index) => (+ <MessageQueueItemkey={message.id}- className={cn(- field,- 'fade-in slide-in-from-bottom-1 animate-in fill-mode-both flex items-center gap-2.5 rounded-2xl py-2 pr-2 pl-3 duration-300'- )}>- <span className={cn(mono, 'text-foreground/30 w-3 shrink-0 tabular-nums')}>- {index + 1}- </span>- <span className="text-foreground/60 min-w-0 flex-1 truncate text-[13.5px]">- {message.text}- </span>- <ArrowUpIcon className="text-foreground/25 size-3 shrink-0" />- {onCancel && (- <button- type="button"- aria-label={removeLabel(message.text)}- onClick={() => onCancel(message.id)}- className={cn(ghostButton, 'size-6 shrink-0')}>+ position={index + 1}+ text={message.text}+ action={onCancel ? (+ <button type="button" aria-label={removeLabel(message.text)} onClick={() => onCancel(message.id)} className={cn(ghostButton, 'size-6 shrink-0')}><XIcon className="size-3.5" /></button>- )}- </li>+ ) : null}+ />))}</ul></div>);}++/** Shared registry row; runtime text and actions are supplied by queue primitives. */+export function MessageQueueItem({ position, text, action }: { position: number; text: ReactNode; action?: ReactNode }) {+ return (+ <li className={cn(field, 'fade-in slide-in-from-bottom-1 animate-in fill-mode-both flex items-center gap-2.5 rounded-2xl py-2 pr-2 pl-3 duration-300')}>+ <span className={cn(mono, 'text-foreground/30 w-3 shrink-0 tabular-nums')}>{position}</span>+ <span className="text-foreground/60 min-w-0 flex-1 truncate text-[13.5px]">{text}</span>+ <ArrowUpIcon aria-hidden className="text-foreground/25 size-3 shrink-0" />+ {action}+ </li>+ );+}diff --git a/app/src/features/conversations/aui/ComposerMessageQueue.tsx b/app/src/features/conversations/aui/ComposerMessageQueue.tsxindex 3c6159c89a..fc8d2c9b51 100644--- a/app/src/features/conversations/aui/ComposerMessageQueue.tsx+++ b/app/src/features/conversations/aui/ComposerMessageQueue.tsx@@ -2,16 +2,15 @@* The composer's message queue: the running prompt and the messages queued* behind it, rendered with assistant-ui's `message-queue` element.*- * Reads `s.composer.queue`, the same list `ComposerPrimitive.Queue` iterates,- * which the runtime fills from the external store's `queue` adapter- * (`queueAdapter.ts`, over the core's run queue). The element owns the whole- * list, so it takes the array rather than rendering one primitive per item.- * Removal goes back through the runtime (`composer.queueItem().remove()`), so- * it lands on the adapter and from there on the core.+ * `ComposerPrimitive.Queue` supplies each item's scope; `QueueItemPrimitive`+ * renders its text and removes it through the core-backed queue adapter.*/-import { useAui, useAuiState } from '@assistant-ui/react';+import { ComposerPrimitive, QueueItemPrimitive, useAuiState } from '@assistant-ui/react';+import { XIcon } from 'lucide-react';-import { MessageQueue } from '../../../components/assistant-ui/elements/message-queue';+import { Button } from '../../../components/assistant-ui/ui/button';++import { MessageQueue, MessageQueueItem } from '../../../components/assistant-ui/elements/message-queue';import { useT } from '../../../lib/i18n/I18nContext';type ThreadMessages = ReadonlyArray<{@@ -34,7 +33,6 @@ function runningPrompt(messages: ThreadMessages): string {export function ComposerMessageQueue() {const { t } = useT();- const aui = useAui();const queue = useAuiState(s => s.composer.queue);const running = useAuiState(s => runningPrompt(s.thread.messages as ThreadMessages));@@ -45,15 +43,32 @@ export function ComposerMessageQueue() {data-testid="queued-followups"className="mb-2 max-w-none"running={running}- queued={queue.map(item => ({- id: item.id,- text: item.parts.map(part => (part.type === 'text' ? part.text : '')).join(''),- }))}- onCancel={id => aui.composer.queueItem({ id }).remove()}+ queuedCount={queue.length}runningLabel={t('chat.messageQueue.running')}queuedLabel={count => t('chat.messageQueue.queuedCount').replace('{count}', String(count))}pendingHint={t('chat.messageQueue.pendingHint')}- removeLabel={text => t('chat.messageQueue.remove').replace('{text}', text)}+ >+ <ComposerPrimitive.Queue>{() => <RuntimeQueueItem />}</ComposerPrimitive.Queue>+ </MessageQueue>+ );+}++/** Queue item identity, text, and removal stay inside assistant-ui's item scope. */+function RuntimeQueueItem() {+ const { t } = useT();+ const text = useAuiState(s => s.queueItem.parts.filter(part => part.type === 'text').map(part => part.text).join('\n\n'));+ const position = useAuiState(s => s.composer.queue.findIndex(item => item.id === s.queueItem.id) + 1);+ return (+ <MessageQueueItem+ position={position}+ text={<QueueItemPrimitive.Text />}+ action={+ <QueueItemPrimitive.Remove asChild>+ <Button variant="ghost" size="icon-xs" aria-label={t('chat.messageQueue.remove').replace('{text}', text)} className="rounded-full">+ <XIcon aria-hidden className="size-3.5" />+ </Button>+ </QueueItemPrimitive.Remove>+ }/>);}