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
style(assistant-ui): reformat thread and queue components
Steven Enamakelfae21e008c38
diff --git a/app/src/components/assistant-ui/elements/message-queue.tsx b/app/src/components/assistant-ui/elements/message-queue.tsxindex 62d04b9a46..264fb204fa 100644--- a/app/src/components/assistant-ui/elements/message-queue.tsx+++ b/app/src/components/assistant-ui/elements/message-queue.tsx@@ -69,27 +69,46 @@ export function MessageQueue({)}<ul className="flex flex-col gap-1.5">- {children ?? queued.map((message, index) => (- <MessageQueueItem- key={message.id}- 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>- ) : null}- />- ))}+ {children ??+ queued.map((message, index) => (+ <MessageQueueItem+ key={message.id}+ 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>+ ) : 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 }) {+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')}>+ <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" />diff --git a/app/src/components/assistant-ui/elements/scroll-anchor.aui.tsx b/app/src/components/assistant-ui/elements/scroll-anchor.aui.tsxindex b7d37f3a15..78c7f51ce9 100644--- a/app/src/components/assistant-ui/elements/scroll-anchor.aui.tsx+++ b/app/src/components/assistant-ui/elements/scroll-anchor.aui.tsx@@ -10,13 +10,7 @@ import { ArrowDownIcon } from 'lucide-react';* library resumes following when the reader returns to the end.* Positioned above the composer so expanding its cards moves the pill with it.*/-export function ScrollAnchor({- label,- className,-}: {- label: string;- className?: string;-}) {+export function ScrollAnchor({ label, className }: { label: string; className?: string }) {return (<ThreadPrimitive.ScrollToBottom asChild behavior="instant"><Buttondiff --git a/app/src/components/assistant-ui/thread.editComposer.test.tsx b/app/src/components/assistant-ui/thread.editComposer.test.tsxindex e8ffa2a923..61d1b43654 100644--- a/app/src/components/assistant-ui/thread.editComposer.test.tsx+++ b/app/src/components/assistant-ui/thread.editComposer.test.tsx@@ -6,15 +6,17 @@ import { Thread } from './thread';function Harness({ onEdit = vi.fn() }: { onEdit?: ReturnType<typeof vi.fn> }) {const runtime = useExternalStoreRuntime({- messages: [- { id: 'user-1', role: 'user' as const, content: 'Original question' },- ],+ messages: [{ id: 'user-1', role: 'user' as const, content: 'Original question' }],convertMessage: message => message,isRunning: false,onNew: vi.fn(),onEdit,});- return <AssistantRuntimeProvider runtime={runtime}><Thread /></AssistantRuntimeProvider>;+ return (+ <AssistantRuntimeProvider runtime={runtime}>+ <Thread />+ </AssistantRuntimeProvider>+ );}describe('native message edit composer', () => {@@ -27,7 +29,9 @@ describe('native message edit composer', () => {fireEvent.change(input, { target: { value: '' } });expect(screen.getByRole('button', { name: 'Send' })).toBeDisabled();fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));- await waitFor(() => expect(screen.queryByRole('textbox', { name: 'Edit your message' })).toBeNull());+ await waitFor(() =>+ expect(screen.queryByRole('textbox', { name: 'Edit your message' })).toBeNull()+ );expect(screen.getByText('Original question')).toBeInTheDocument();expect(onEdit).not.toHaveBeenCalled();});@@ -36,10 +40,14 @@ describe('native message edit composer', () => {const onEdit = vi.fn();render(<Harness onEdit={onEdit} />);fireEvent.click(screen.getByRole('button', { name: 'Edit' }));- fireEvent.change(screen.getByRole('textbox', { name: 'Edit your message' }), { target: { value: 'Updated question' } });+ fireEvent.change(screen.getByRole('textbox', { name: 'Edit your message' }), {+ target: { value: 'Updated question' },+ });fireEvent.click(screen.getByRole('button', { name: 'Send' }));- await waitFor(() => expect(onEdit).toHaveBeenCalledWith(expect.objectContaining({- content: [{ type: 'text', text: 'Updated question' }],- })));+ await waitFor(() =>+ expect(onEdit).toHaveBeenCalledWith(+ expect.objectContaining({ content: [{ type: 'text', text: 'Updated question' }] })+ )+ );});});diff --git a/app/src/components/assistant-ui/thread.followBottom.test.tsx b/app/src/components/assistant-ui/thread.followBottom.test.tsxindex f86f42615b..68545dfda6 100644--- a/app/src/components/assistant-ui/thread.followBottom.test.tsx+++ b/app/src/components/assistant-ui/thread.followBottom.test.tsx@@ -210,10 +210,19 @@ describe('assistant-ui native scroll anchoring', () => {scrollToSpy.mockClear();const alignment = vi.spyOn(Element.prototype, 'scrollIntoView');setGeometry(viewport, 500, 1400);- act(() => store.dispatch({- type: loadThreadMessages.fulfilled.type,- payload: { threadId: 't1', messages: [msg('1', 'user', 'hi'), msg('2', 'agent', 'hello'), msg('3', 'user', 'follow-up')] },- }));+ act(() =>+ store.dispatch({+ type: loadThreadMessages.fulfilled.type,+ payload: {+ threadId: 't1',+ messages: [+ msg('1', 'user', 'hi'),+ msg('2', 'agent', 'hello'),+ msg('3', 'user', 'follow-up'),+ ],+ },+ })+ );growContent();expect(followedBottom(viewport)).toBe(true);expect(alignment).not.toHaveBeenCalled();diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex c0a9e8b88c..9e3143514d 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -470,15 +470,12 @@ const ThreadRoot: FC<{</>)}- <div- data-slot="aui_message-group"- className="mb-14 flex flex-col gap-y-6 empty:hidden">+ <div data-slot="aui_message-group" className="mb-14 flex flex-col gap-y-6 empty:hidden"><ThreadPrimitive.Messages>{() => <ThreadMessage />}</ThreadPrimitive.Messages><RunningStatusSlot /><TranscriptFooterSlot /></div>-<ThreadPrimitive.ViewportFooterclassName={cn('aui-thread-viewport-footer relative z-10 flex flex-col gap-4 overflow-visible bg-transparent pb-4 md:pb-6',@@ -1592,9 +1589,10 @@ const EditComposer: FC = () => {<div className="flex items-center gap-2 text-amber-700 dark:text-amber-400"><AlertTriangleIcon aria-hidden className="size-3.5 shrink-0" /><span className="font-mono text-[11px] tabular-nums">- {t(discardedReplies === 1- ? 'conversations.assistantUi.edit.discardedRepliesOne'- : 'conversations.assistantUi.edit.discardedRepliesOther'+ {t(+ discardedReplies === 1+ ? 'conversations.assistantUi.edit.discardedRepliesOne'+ : 'conversations.assistantUi.edit.discardedRepliesOther').replace('{count}', String(discardedReplies))}</span></div>diff --git a/app/src/features/conversations/aui/ComposerMessageQueue.tsx b/app/src/features/conversations/aui/ComposerMessageQueue.tsxindex fc8d2c9b51..d4c5e73a44 100644--- a/app/src/features/conversations/aui/ComposerMessageQueue.tsx+++ b/app/src/features/conversations/aui/ComposerMessageQueue.tsx@@ -8,9 +8,11 @@import { ComposerPrimitive, QueueItemPrimitive, useAuiState } from '@assistant-ui/react';import { XIcon } from 'lucide-react';+import {+ MessageQueue,+ MessageQueueItem,+} 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<{@@ -46,8 +48,7 @@ export function ComposerMessageQueue() {queuedCount={queue.length}runningLabel={t('chat.messageQueue.running')}queuedLabel={count => t('chat.messageQueue.queuedCount').replace('{count}', String(count))}- pendingHint={t('chat.messageQueue.pendingHint')}- >+ pendingHint={t('chat.messageQueue.pendingHint')}><ComposerPrimitive.Queue>{() => <RuntimeQueueItem />}</ComposerPrimitive.Queue></MessageQueue>);@@ -56,15 +57,26 @@ export function ComposerMessageQueue() {/** 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);+ 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 (<MessageQueueItemposition={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">+ <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>diff --git a/app/src/providers/__tests__/useOpenHumanExternalStore.identity.test.tsx b/app/src/providers/__tests__/useOpenHumanExternalStore.identity.test.tsxindex d66cfba1e7..3e719b67f2 100644--- a/app/src/providers/__tests__/useOpenHumanExternalStore.identity.test.tsx+++ b/app/src/providers/__tests__/useOpenHumanExternalStore.identity.test.tsx@@ -14,8 +14,12 @@ vi.mock('../../services/api/threadApi', () => ({describe('assistant-ui thread identity', () => {it('projects the real thread id so native thread switching can reset the viewport', () => {- const store = configureStore({ reducer: { thread: threadReducer, chatRuntime: chatRuntimeReducer } });- const wrapper = ({ children }: { children: ReactNode }) => <Provider store={store}>{children}</Provider>;+ const store = configureStore({+ reducer: { thread: threadReducer, chatRuntime: chatRuntimeReducer },+ });+ const wrapper = ({ children }: { children: ReactNode }) => (+ <Provider store={store}>{children}</Provider>+ );const { result, rerender } = renderHook(({ threadId }: { threadId: string | null }) => useOpenHumanExternalStore(threadId),{ wrapper, initialProps: { threadId: 'first' as string | null } }