{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-assistant-04",
  "description": "A failed assistant reply kept in the conversation with a button to try again.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/ai-assistant.json",
    "https://www.dashboardblocks.com/r/radix/ai-chat.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/ai-assistant/ai-assistant-04.tsx",
      "content": "'use client'\n\nimport {\n  ChatComposer,\n  ChatConversation,\n  ChatMessages,\n  ChatWelcome,\n} from '@/registry/components/dashboardblocks/ai-assistant'\nimport type { AIChat } from '@/registry/components/dashboardblocks/ai-message'\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { useRef } from 'react'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface AiAssistant4Props extends BlockStateProps {\n  /**\n   * The chat it runs: `useChat()` from `@ai-sdk/react`, or `useChatStream` for any other stream.\n   * The AI SDK sends \"An error occurred.\" for any error on the server unless the route's `onError` returns a message to show.\n   */\n  chat: AIChat\n  description: string\n  title: string\n}\n\nconst exampleProps: Omit<AiAssistant4Props, 'chat'> = {\n  description: 'Answers from incidents, deploys and runbooks.',\n  title: 'Ops assistant',\n}\n\nconst AiAssistant4 = (props: AiAssistant4Props) => {\n  const { description, errorMessage, status: blockStatus, title } = props\n  const { chat } = props\n  const { messages, status } = chat\n  const state = getBlockState(blockStatus, messages)\n  const composerRef = useRef<HTMLTextAreaElement>(null)\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider errorMessage={errorMessage} state={state}>\n          <section className='@container flex h-[44rem] flex-col gap-3'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <p className='text-muted-foreground text-sm'>{description}</p>\n            </header>\n            <ChatMessages\n              status={status}\n              latest={messages.at(-1)}\n              className='min-h-0 border-t'\n              contentClassName='ps-0 pe-4'\n            >\n              {state === 'empty' ? (\n                <ChatWelcome\n                  className='my-auto py-8'\n                  title='Ask about your systems'\n                  description='Answers from incidents, deploys and runbooks. Attach a log or a screenshot to ask about it.'\n                />\n              ) : (\n                state && <BlockStateRows rows={3} />\n              )}\n              {!state && <ChatConversation chat={chat} composerRef={composerRef} />}\n            </ChatMessages>\n            <ChatComposer\n              accept='image/*,.log,.txt,.pdf'\n              disabled={blockStatus !== undefined}\n              status={status}\n              textareaRef={composerRef}\n              onSubmit={chat.sendMessage}\n              onStop={chat.stop}\n              placeholder='Ask about incidents or deploys'\n            />\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { AiAssistant4, exampleProps as aiAssistant4ExampleProps, type AiAssistant4Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/ai-assistant/ai-assistant-04.tsx"
    }
  ],
  "meta": {
    "shows": "A failed assistant reply kept in the conversation with a button to try again.",
    "size": "half",
    "usedWith": [
      "ai-assistant-02",
      "states-01"
    ],
    "component": "AiAssistant4",
    "props": "{ chat: { addToolApprovalResponse?: (response: { approved: boolean; id: string; reason?: string }) => unknown; error?: Error; messages: { id: string; metadata?: unknown; parts: ({ citations?: { endIndex?: number; source: { id: string; sourceType: \"url\"; title?: string; url: string } | { id: string; sourceType: \"document\"; title: string } }[]; state?: \"done\" | \"streaming\"; text: string; type: \"text\" } | { state?: \"done\" | \"streaming\"; text: string; type: \"reasoning\" } | { type: `tool-${string}`; approval?: { approved?: boolean; id: string; isAutomatic?: boolean; reason?: string; requestReason?: string }; errorText?: string; input?: unknown; output?: unknown; preliminary?: boolean; state: \"input-streaming\" | \"input-available\" | \"approval-requested\" | \"approval-responded\" | \"output-available\" | \"output-error\" | \"output-denied\"; title?: string; toolCallId: string } | { toolName: string; type: \"dynamic-tool\"; approval?: { approved?: boolean; id: string; isAutomatic?: boolean; reason?: string; requestReason?: string }; errorText?: string; input?: unknown; output?: unknown; preliminary?: boolean; state: \"input-streaming\" | \"input-available\" | \"approval-requested\" | \"approval-responded\" | \"output-available\" | \"output-error\" | \"output-denied\"; title?: string; toolCallId: string } | { sourceId: string; title?: string; type: \"source-url\"; url: string } | { filename?: string; mediaType: string; sourceId: string; title: string; type: \"source-document\" } | { filename?: string; mediaType: string; type: \"file\"; url: string } | { data: unknown; id?: string; type: `data-${string}` } | { type: \"step-start\" | \"custom\" | \"reasoning-file\" | \"steering-message\" })[]; role: \"system\" | \"user\" | \"assistant\" }[]; regenerate: (options: { messageId?: string }) => unknown; selectVersion?: (messageId: string, index: number) => unknown; sendMessage: (message: { files?: { filename?: string; mediaType: string; type: \"file\"; url: string }[]; messageId?: string; metadata?: unknown; text: string }) => unknown; setMessages?: (messages: []) => void; status: \"error\" | \"streaming\" | \"ready\" | \"submitted\"; stop: () => unknown; versions?: {  } }; description: string; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
