diff --git a/src/main.tsx b/src/main.tsx index 114a209..80a79fb 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -40,6 +40,41 @@ export {}; const GA_ID = import.meta.env.VITE_GA_ID as string | undefined; +class RootErrorBoundary extends React.Component< + { children: React.ReactNode }, + { hasError: boolean; error?: unknown } +> { + state = { hasError: false as boolean, error: undefined as unknown }; + + static getDerivedStateFromError(error: unknown) { + return { hasError: true, error }; + } + + componentDidCatch(error: unknown) { + console.error("[HPL] Uncaught render error:", error); + } + + render() { + if (this.state.hasError) { + return ( +
+
+
+ HPL Recovery Mode +
+
Something crashed during render.
+
+ Check the console for details. If this is production, we can add a safer fallback path. +
+
+
+ ); + } + return this.props.children; + } +} + + function initGA(measurementId: string) { // 1) Create dataLayer + gtag stub immediately window.dataLayer = window.dataLayer ?? []; @@ -70,6 +105,8 @@ if (GA_ID) initGA(GA_ID); ReactDOM.createRoot(document.getElementById("root")!).render( - + + + ); \ No newline at end of file diff --git a/src/pages/admin/pages/AdminNotesPage.tsx b/src/pages/admin/pages/AdminNotesPage.tsx index 3972e57..b411e6e 100644 --- a/src/pages/admin/pages/AdminNotesPage.tsx +++ b/src/pages/admin/pages/AdminNotesPage.tsx @@ -152,6 +152,10 @@ export function AdminNotesPage() { await refreshNotes(); }; + const EXCERPT_SOFT_LIMIT = 280; + const excerptLength = form.excerpt.length; + const overLimit = excerptLength > EXCERPT_SOFT_LIMIT; + return (
{/* Header */} @@ -317,16 +321,39 @@ export function AdminNotesPage() {
-