import React, { Component, type ReactNode } from 'react'; import { RotateCcw, X, AlertTriangle } from 'lucide-react'; interface WindowErrorBoundaryProps { windowId: string; windowTitle?: string; onClose?: () => void; children: ReactNode; } interface WindowErrorBoundaryState { hasError: boolean; error: Error | null; } export default class WindowErrorBoundary extends Component< WindowErrorBoundaryProps, WindowErrorBoundaryState > { constructor(props: WindowErrorBoundaryProps) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): WindowErrorBoundaryState { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error( `[WindowErrorBoundary] Error caught in window "${this.props.windowId}":`, error, errorInfo ); } handleReset = () => { this.setState({ hasError: false, error: null }); }; render() { if (this.state.hasError) { return (
{/* Header */}
SYSTEM INTERRUPT: {this.props.windowTitle || this.props.windowId}
{/* Error Message */}
{this.state.error?.message || 'An unexpected runtime error occurred.'}

The window process encountered a recoverable fault. You can restart this window module without losing your desktop session.

{/* Action Buttons */}
{this.props.onClose && ( )}
); } return this.props.children; } }