import { AlertTriangle, X } from "lucide-react"; import type { TFunction } from "i18next"; import { useTranslation } from "react-i18next"; import { Button } from "@/components/ui/button"; import { resolveModelRequestFailureCopy } from "@/lib/model-request-failure"; import { cn } from "@/lib/utils"; import type { StreamError } from "@/lib/nanobot-client"; interface StreamErrorNoticeProps { error: StreamError; onDismiss: () => void; onOpenSettings?: () => void; } /** * Fallback banner for transport-level faults that cannot be attached to a * visible failed message. ``role="alert"`` + ``aria-live="assertive"`` * ensures screen readers announce the failure. */ export function StreamErrorNotice({ error, onDismiss, onOpenSettings }: StreamErrorNoticeProps) { const { t } = useTranslation(); const { title, body } = resolveCopy(error, t); return (
{title}
{body}
{error.kind === "model_request_failed" && onOpenSettings ? ( ) : null}