"use client"; import { Component, type ReactNode } from "react"; import { Button } from "@/components/shadcn/button/button"; interface SidePanelErrorBoundaryProps { children: ReactNode; onRetry: () => void; } interface SidePanelErrorBoundaryState { hasError: boolean; } // GlobalSidePanel mounts at the app-layout level, above every segment // error.tsx, so an uncaught render/chunk-load error in a lazy tab would // bubble to global-error and replace the whole app. Class component because // React has no hook equivalent for error boundaries. export class SidePanelErrorBoundary extends Component< SidePanelErrorBoundaryProps, SidePanelErrorBoundaryState > { state: SidePanelErrorBoundaryState = { hasError: false }; static getDerivedStateFromError(): SidePanelErrorBoundaryState { return { hasError: true }; } private handleRetry = () => { this.props.onRetry(); this.setState({ hasError: false }); }; render() { if (this.state.hasError) { return (

This panel failed to load.

); } return this.props.children; } }