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
fix(assistant-ui): handle missing assistant message in chat component
Steven Enamakel06beb7b7834d
diff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsxnew file mode 100644index 0000000000..8c399f2233--- /dev/null+++ b/app/src/features/conversations/components/AssistantUiChat.tsx@@ -0,0 +1,81 @@+import {+ AssistantRuntimeProvider,+ AttachmentPrimitive,+ AuiIf,+ type ChatModelAdapter,+ ComposerPrimitive,+ CompositeAttachmentAdapter,+ MessagePrimitive,+ SimpleImageAttachmentAdapter,+ SimpleTextAttachmentAdapter,+ ThreadPrimitive,+ useLocalRuntime,+} from '@assistant-ui/react';++/**+ * A local-only runtime so the assistant-ui primitives can be exercised without+ * an OpenHuman connector, stored conversation, or real model request.+ */+const localChatModel: ChatModelAdapter = {+ run: async () => ({+ content: [+ {+ type: 'text',+ text: 'This is a local placeholder response. OpenHuman connectors are not wired in yet.',+ },+ ],+ }),+};++const localAttachmentAdapter = new CompositeAttachmentAdapter([+ new SimpleImageAttachmentAdapter(),+ new SimpleTextAttachmentAdapter(),+]);++/** A raw assistant-ui surface with no application styling or connector code. */+export function AssistantUiChat() {+ const runtime = useLocalRuntime(localChatModel, {+ adapters: { attachments: localAttachmentAdapter },+ });++ return (+ <AssistantRuntimeProvider runtime={runtime}>+ <ThreadPrimitive.Root data-testid="assistant-ui-chat">+ <ThreadPrimitive.Viewport turnAnchor="top">+ <ThreadPrimitive.Empty>How can I help you today?</ThreadPrimitive.Empty>+ <ThreadPrimitive.Messages>+ {() => (+ <MessagePrimitive.Root>+ <MessagePrimitive.Parts />+ </MessagePrimitive.Root>+ )}+ </ThreadPrimitive.Messages>+ <ThreadPrimitive.ViewportFooter>+ <ComposerPrimitive.Root>+ <ComposerPrimitive.AttachmentDropzone>+ <ComposerPrimitive.Attachments>+ {() => (+ <AttachmentPrimitive.Root>+ <AttachmentPrimitive.Name />+ <AttachmentPrimitive.Remove>Remove</AttachmentPrimitive.Remove>+ </AttachmentPrimitive.Root>+ )}+ </ComposerPrimitive.Attachments>+ <ComposerPrimitive.Input placeholder="Send a message..." />+ <ComposerPrimitive.AddAttachment>Add attachment</ComposerPrimitive.AddAttachment>+ <AuiIf condition={state => !state.thread.isRunning}>+ <ComposerPrimitive.Send>Send</ComposerPrimitive.Send>+ </AuiIf>+ <AuiIf condition={state => state.thread.isRunning}>+ <ComposerPrimitive.Cancel>Cancel</ComposerPrimitive.Cancel>+ </AuiIf>+ </ComposerPrimitive.AttachmentDropzone>+ </ComposerPrimitive.Root>+ </ThreadPrimitive.ViewportFooter>+ </ThreadPrimitive.Viewport>+ </ThreadPrimitive.Root>+ </AssistantRuntimeProvider>+ );+}++export default AssistantUiChat;