import { Component, type ReactNode } from 'react'; interface Props { children: ReactNode; } interface State { hasError: boolean; error: Error | null; } export default class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, info: React.ErrorInfo) { console.error('ErrorBoundary caught:', error, info.componentStack); try { window.electronAPI?.logError?.(error.message, error.stack || '', info.componentStack || ''); } catch {} } handleReload = () => { window.location.reload(); }; handleReset = () => { try { localStorage.clear(); sessionStorage.clear(); } catch {} window.location.reload(); }; render() { if (this.state.hasError) { return (

Something went wrong

An unexpected error occurred. Your work may still be recoverable.

{this.state.error && (
Error details
                {this.state.error.message}
                {'\n'}
                {this.state.error.stack}
              
)}
); } return this.props.children; } }