@devries-cameron20 / t3code-1 / commits / 133db22fae
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(web): copy the full error report from the error page (#9166)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>

Wout Stiens committed Sep 2, 2026 at 07:12 UTC 133db22fae34cfb2e62a806e99d22674b0376f35
1 file changed +48 -11
apps/web/src/routes/__root.tsx
+48 -11
@@ -8,9 +8,10 @@ import {
8 useLocation,
9 useNavigate,
10 } from "@tanstack/react-router";
11 -import { useEffect, useEffectEvent, useRef, useState } from "react";
11 +import { CheckIcon, CopyIcon } from "lucide-react";
12 +import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
13
13 -import { APP_BASE_NAME, APP_DISPLAY_NAME, APP_STAGE_LABEL } from "../branding";
14 +import { APP_BASE_NAME, APP_DISPLAY_NAME, APP_STAGE_LABEL, APP_VERSION } from "../branding";
15 import { resolveServerBackedAppDisplayName } from "../branding.logic";
16 import { AppSidebarLayout } from "../components/AppSidebarLayout";
17 import { CommandPalette } from "../components/CommandPalette";
@@ -22,6 +23,7 @@ import { DesktopAppActivationCoordinator } from "../components/desktop/DesktopAp
23 import { ProviderUpdateLaunchNotification } from "../components/ProviderUpdateLaunchNotification";
24 import { SlowRpcRequestToastCoordinator } from "../components/SlowRpcRequestToastCoordinator";
25 import { ThemeEditorHost } from "../components/settings/ThemeEditorHost";
26 +import { useCopyToClipboard } from "../hooks/useCopyToClipboard";
27 import { useDefaultThemeAdoption } from "../hooks/useDefaultTheme";
28 import { useEnvironmentThemeSync } from "../hooks/useEnvironmentTheme";
29 import { Button } from "../components/ui/button";
@@ -267,7 +269,9 @@ function HostedStaticEnvironmentBootstrap() {
269
270 function RootRouteErrorView({ error, reset }: ErrorComponentProps) {
271 const message = errorMessage(error);
270 - const details = errorDetails(error);
272 + // Router pathname rather than window.location: desktop uses hash history, where the window path is always "/".
273 + const pathname = useLocation({ select: (location) => location.pathname });
274 + const report = useMemo(() => errorReport(error, pathname), [error, pathname]);
275
276 return (
277 <div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-background px-4 py-10 text-foreground sm:px-6">
@@ -292,22 +296,32 @@ function RootRouteErrorView({ error, reset }: ErrorComponentProps) {
296 <Button size="sm" variant="outline" onClick={() => window.location.reload()}>
297 Reload app
298 </Button>
299 + <CopyErrorButton report={report} />
300 </div>
301
297 - <details className="group mt-5 overflow-hidden rounded-lg border border-border/70 bg-background/55">
298 - <summary className="cursor-pointer list-none px-3 py-2 text-xs font-medium text-muted-foreground">
299 - <span className="group-open:hidden">Show error details</span>
300 - <span className="hidden group-open:inline">Hide error details</span>
301 - </summary>
302 - <pre className="max-h-56 overflow-auto border-t border-border/70 bg-background/80 px-3 py-2 text-xs text-foreground/85">
303 - {details}
302 + <div className="mt-5 overflow-hidden rounded-lg border border-border/70 bg-background/55">
303 + <p className="px-3 py-1.5 text-xs font-medium text-muted-foreground">Error report</p>
304 + <pre className="max-h-64 overflow-auto border-t border-border/70 bg-background/80 px-3 py-2 text-xs whitespace-pre-wrap text-foreground/85">
305 + {report}
306 </pre>
305 - </details>
307 + </div>
308 </section>
309 </div>
310 );
311 }
312
313 +/** Copies the full error report and swaps to a check mark for a moment as confirmation. */
314 +function CopyErrorButton({ report }: { report: string }) {
315 + const { copyToClipboard, isCopied } = useCopyToClipboard({ target: "error-report" });
316 +
317 + return (
318 + <Button size="sm" variant="outline" onClick={() => copyToClipboard(report)}>
319 + {isCopied ? <CheckIcon className="text-success" /> : <CopyIcon />}
320 + {isCopied ? "Copied" : "Copy error"}
321 + </Button>
322 + );
323 +}
324 +
325 function errorMessage(error: unknown): string {
326 if (error instanceof Error && error.message.trim().length > 0) {
327 return error.message;
@@ -336,6 +350,29 @@ function errorDetails(error: unknown): string {
350 }
351 }
352
353 +const MAX_ERROR_CAUSE_DEPTH = 5;
354 +
355 +/**
356 + * Full error text for bug reports: app build, page path, time, then the stack
357 + * and any cause chain. Takes the pathname only so tokens in the query never
358 + * land on the clipboard.
359 + */
360 +function errorReport(error: unknown, pathname: string): string {
361 + const lines = [
362 + `${APP_DISPLAY_NAME} ${APP_VERSION}`,
363 + `Path: ${pathname}`,
364 + `Time: ${new Date().toISOString()}`,
365 + "",
366 + errorDetails(error),
367 + ];
368 + let cause = error instanceof Error ? error.cause : undefined;
369 + for (let depth = 0; cause !== undefined && depth < MAX_ERROR_CAUSE_DEPTH; depth += 1) {
370 + lines.push("", "Caused by:", errorDetails(cause));
371 + cause = cause instanceof Error ? cause.cause : undefined;
372 + }
373 + return lines.join("\n");
374 +}
375 +
376 function AuthenticatedTracingBootstrap() {
377 useEffect(() => {
378 void configureClientTracing();