"use client"; import { Primitive } from "../../utils/Primitive"; import { type ComponentRef, forwardRef, type ComponentPropsWithoutRef, } from "react"; import { useMessageError } from "@assistant-ui/core/react"; export namespace ErrorPrimitiveMessage { export type Element = ComponentRef; export type Props = ComponentPropsWithoutRef; } export const ErrorPrimitiveMessage = forwardRef< ErrorPrimitiveMessage.Element, ErrorPrimitiveMessage.Props >(({ children, ...props }, forwardRef) => { const error = useMessageError(); if (error === undefined) return null; return ( {children ?? String(error)} ); }); ErrorPrimitiveMessage.displayName = "ErrorPrimitive.Message";