import { useCallback, useState, type ErrorInfo, type ReactNode } from 'react'; import { ErrorBoundary as ReactErrorBoundary, type FallbackProps, } from 'react-error-boundary'; type ErrorFallbackProps = FallbackProps & { showDetails: boolean; componentStack: string | null; }; type ErrorBoundaryProps = { children: ReactNode; showDetails?: boolean; onRetry?: () => void; resetKeys?: unknown[]; }; function formatError(error: unknown): string { if (error instanceof Error) { return `${error.name}: ${error.message}`; } return String(error); } function ErrorFallback({ error, resetErrorBoundary, showDetails, componentStack, }: ErrorFallbackProps) { return (
An error occurred while loading the chat interface.
{showDetails && (
{formatError(error)}
{componentStack}