"use client"; import { isChunkLoadError, recoverByReload } from "@/app/chunk-recovery"; // Root error boundary for the whole app. Two jobs: // // 1. Self-heal stale-chunk failures. After a redeploy, an already-open tab // still references the previous build's chunk hashes; those 404 against the // new build and throw a ChunkLoadError when a route's code is loaded // (e.g. navigating to /agent/sessions). Without a boundary, Next.js shows a // dead "Application error" page. recoverByReload() reloads once (guarded) to // fetch the current build. // // 2. Give every other render error a friendly retry instead of a blank screen. // // NOTE: there is intentionally no useEffect — React effect hooks are banned // project-wide. The one-shot recovery runs from a ref callback (commit time), // which is idempotent thanks to the sessionStorage guard in recoverByReload(). export default function AppError({ error, reset, }: { error: Error & { digest?: string }; reset: () => void; }) { const chunkError = isChunkLoadError(error); return (
void recoverByReload() : undefined} style={{ minHeight: "60vh", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: "14px", padding: "48px 24px", textAlign: "center", color: "var(--fg, #e6e6e6)", background: "var(--bg, #0a0a0a)", fontFamily: "ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif", }} > {chunkError ? (

Updating to the latest version…

) : ( <>

Something went wrong.

This view hit an unexpected error. You can retry it, or reload the app.

)}
); }