From 29504c884bd623d2bf06ddb23643c0688295e450 Mon Sep 17 00:00:00 2001 From: 96528025 Date: Wed, 18 Mar 2026 14:38:34 -0700 Subject: [PATCH 1/2] fix: add error handling to async clipboard handler in header.tsx Wrap the async onClick handler for copying the SVG logo in a try-catch block to handle potential failures from fetch(), res.text(), and navigator.clipboard.writeText(). Show a success toast on copy and an error toast if any step fails. Fixes #722 Co-Authored-By: Claude Sonnet 4.6 --- apps/web/src/components/header.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx index e24486b44..7eb3c9cd9 100644 --- a/apps/web/src/components/header.tsx +++ b/apps/web/src/components/header.tsx @@ -23,6 +23,7 @@ import { ContextMenuItem, ContextMenuTrigger, } from "./ui/context-menu"; +import { toast } from "sonner"; export function Header() { const [isMenuOpen, setIsMenuOpen] = useState(false); @@ -66,9 +67,14 @@ export function Header() { { - const res = await fetch(DEFAULT_LOGO_URL); - const svg = await res.text(); - await navigator.clipboard.writeText(svg); + try { + const res = await fetch(DEFAULT_LOGO_URL); + const svg = await res.text(); + await navigator.clipboard.writeText(svg); + toast.success("SVG copied to clipboard"); + } catch { + toast.error("Failed to copy SVG to clipboard"); + } }} > From c1613d8a21c18ce218fbe31c4ff0f187e1220827 Mon Sep 17 00:00:00 2001 From: 96528025 Date: Wed, 18 Mar 2026 14:45:08 -0700 Subject: [PATCH 2/2] fix: guard HTTP failure responses and rename res to response - Rename `res` to `response` to follow no-abbreviation naming guideline - Add `response.ok` check to throw on non-2xx status codes, preventing error page content from being silently copied to the clipboard Co-Authored-By: Claude Sonnet 4.6 --- apps/web/src/components/header.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx index 7eb3c9cd9..64d424717 100644 --- a/apps/web/src/components/header.tsx +++ b/apps/web/src/components/header.tsx @@ -68,8 +68,11 @@ export function Header() { { try { - const res = await fetch(DEFAULT_LOGO_URL); - const svg = await res.text(); + const response = await fetch(DEFAULT_LOGO_URL); + if (!response.ok) { + throw new Error(`Failed to fetch SVG: ${response.status}`); + } + const svg = await response.text(); await navigator.clipboard.writeText(svg); toast.success("SVG copied to clipboard"); } catch {