From 6370ec1a0d20e591b483b1e7fa82bd10fdb23216 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 17 Jul 2026 20:12:23 +0000 Subject: [PATCH 1/2] fix: harden Therapy Compass recovery and error accessibility Co-authored-by: BigSimmo --- src/app/global-error.tsx | 32 ++++++++++--------- src/components/route-error-boundary.tsx | 8 +++-- src/components/therapy-compass/bindings.tsx | 5 ++- .../therapy-compass/data/use-therapy-data.ts | 15 ++++++--- .../therapy-compass/therapy-card.tsx | 6 ++-- .../therapy-compass/therapy-compass-page.tsx | 30 +++++++++++------ 6 files changed, 63 insertions(+), 33 deletions(-) diff --git a/src/app/global-error.tsx b/src/app/global-error.tsx index 0b9bd1dd4..7b4a1ed22 100644 --- a/src/app/global-error.tsx +++ b/src/app/global-error.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; /** * Last-resort boundary for the App Router. Unlike `app/error.tsx`, this replaces @@ -11,8 +11,10 @@ import { useEffect } from "react"; * still renders correctly when the styling/theming system is exactly what failed. */ export default function GlobalError({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) { + const headingRef = useRef(null); useEffect(() => { console.error("Fatal error captured by global-error boundary:", error); + headingRef.current?.focus(); }, [error]); return ( @@ -25,8 +27,8 @@ export default function GlobalError({ error, reset }: { error: Error & { digest? alignItems: "center", justifyContent: "center", padding: "1rem", - backgroundColor: "#f4f5f7", - color: "#1a1c1e", + backgroundColor: "Canvas", + color: "CanvasText", fontFamily: 'system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"', }} @@ -37,15 +39,15 @@ export default function GlobalError({ error, reset }: { error: Error & { digest? maxWidth: "28rem", boxSizing: "border-box", borderRadius: "1rem", - border: "1px solid #e2e4e8", - backgroundColor: "#ffffff", + border: "1px solid CanvasText", + backgroundColor: "Canvas", padding: "1.5rem", textAlign: "center", - boxShadow: "0 10px 30px rgba(15, 23, 42, 0.12)", + boxShadow: "0 10px 30px color-mix(in srgb, CanvasText 12%, transparent)", }} > -

Something went wrong

-

+

Something went wrong

+

The application failed to load. Please try again, or reload the page if the problem persists.

{error.digest && ( @@ -53,11 +55,11 @@ export default function GlobalError({ error, reset }: { error: Error & { digest? style={{ margin: "0 0 1.25rem", borderRadius: "0.5rem", - backgroundColor: "#f4f5f7", + backgroundColor: "Canvas", padding: "0.5rem", fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace", fontSize: "0.75rem", - color: "#5b6069", + color: "CanvasText", wordBreak: "break-all", }} > @@ -72,8 +74,8 @@ export default function GlobalError({ error, reset }: { error: Error & { digest? cursor: "pointer", borderRadius: "0.5rem", border: "none", - backgroundColor: "#1a1c1e", - color: "#ffffff", + backgroundColor: "ButtonFace", + color: "ButtonText", padding: "0.625rem 1rem", fontSize: "0.875rem", fontWeight: 600, @@ -87,9 +89,9 @@ export default function GlobalError({ error, reset }: { error: Error & { digest? style={{ cursor: "pointer", borderRadius: "0.5rem", - border: "1px solid #e2e4e8", - backgroundColor: "#ffffff", - color: "#1a1c1e", + border: "1px solid ButtonText", + backgroundColor: "ButtonFace", + color: "ButtonText", padding: "0.625rem 1rem", fontSize: "0.875rem", fontWeight: 600, diff --git a/src/components/route-error-boundary.tsx b/src/components/route-error-boundary.tsx index ae9957733..817302557 100644 --- a/src/components/route-error-boundary.tsx +++ b/src/components/route-error-boundary.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { TriangleAlert, RefreshCw } from "lucide-react"; import { cn, primaryControl } from "@/components/ui-primitives"; @@ -38,8 +38,10 @@ export function RouteErrorBoundary({ showReload = false, minHeightClass = "min-h-[50vh]", }: RouteErrorBoundaryProps) { + const headingRef = useRef(null); useEffect(() => { console.error(logLabel, error); + headingRef.current?.focus(); }, [error, logLabel]); return ( @@ -54,7 +56,9 @@ export function RouteErrorBoundary({