The best way to control Claude Code, Codex and more from any computer or phone
perf(web): the root route compiles with the React Compiler (#20585)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 22:04 UTC
20851e304eb543acf9cbcd5db5d2161a60212fbf
1 file changed
+20
-11
apps/web/src/routes/__root.tsx
+20
-11
@@ -12,7 +12,7 @@ import {
12
useRouter,
13
} from "@tanstack/react-router";
14
import { Check, Copy } from "lucide";
15
-import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
15
+import { useEffect, useEffectEvent, useRef, useState } from "react";
16
17
import { APP_BASE_NAME, APP_DISPLAY_NAME, APP_STAGE_LABEL, APP_VERSION } from "../branding";
18
import { resolveServerBackedAppDisplayName } from "../branding.logic";
@@ -152,19 +152,11 @@ function RootRouteView() {
152
authGateState.status === "hosted-static",
153
);
154
155
- useEffect(() => {
156
- const frame = window.requestAnimationFrame(() => {
157
- syncBrowserChromeTheme();
158
- });
159
- return () => {
160
- window.cancelAnimationFrame(frame);
161
- };
162
- }, [pathname]);
163
-
155
if (pathname === "/pair" || pathname === "/connect" || pathname === "/connect-agent") {
156
return (
157
<>
158
<DocumentTitleSync />
159
+ <BrowserChromeThemeSync key={pathname} />
160
<Outlet />
161
</>
162
);
@@ -176,6 +168,7 @@ function RootRouteView() {
168
return (
169
<>
170
<DocumentTitleSync />
171
+ <BrowserChromeThemeSync key={pathname} />
172
{hostedPromptLinkLanding}
173
</>
174
);
@@ -186,6 +179,7 @@ function RootRouteView() {
179
<ToastProvider>
180
<AnchoredToastProvider>
181
<DocumentTitleSync />
182
+ <BrowserChromeThemeSync key={pathname} />
183
<ContrastAppearanceSync />
184
<EnvironmentThemeSync />
185
<GlassAppearanceSync />
@@ -206,6 +200,7 @@ function RootRouteView() {
200
return (
201
<>
202
<DocumentTitleSync />
203
+ <BrowserChromeThemeSync key={pathname} />
204
<Outlet />
205
</>
206
);
@@ -223,6 +218,7 @@ function RootRouteView() {
218
<ToastProvider>
219
<AnchoredToastProvider>
220
<DocumentTitleSync />
221
+ <BrowserChromeThemeSync key={pathname} />
222
<ContrastAppearanceSync />
223
<EnvironmentThemeSync />
224
<GlassAppearanceSync />
@@ -342,6 +338,19 @@ function FontAppearanceSync() {
338
return null;
339
}
340
341
+/** Keyed by pathname: each route paints its own surface, which the browser chrome samples. */
342
+function BrowserChromeThemeSync() {
343
+ useEffect(() => {
344
+ const frame = window.requestAnimationFrame(() => {
345
+ syncBrowserChromeTheme();
346
+ });
347
+ return () => {
348
+ window.cancelAnimationFrame(frame);
349
+ };
350
+ }, []);
351
+ return null;
352
+}
353
+
354
function DocumentTitleSync() {
355
const primaryServerVersion =
356
useAtomValue(primaryServerConfigAtom)?.environment.serverVersion ?? null;
@@ -392,7 +401,7 @@ function RootRouteErrorView({ error }: ErrorComponentProps) {
401
const message = errorMessage(error);
402
// Router pathname rather than window.location: desktop uses hash history, where the window path is always "/".
403
const pathname = useLocation({ select: (location) => location.pathname });
395
- const report = useMemo(() => errorReport(error, pathname), [error, pathname]);
404
+ const report = errorReport(error, pathname);
405
406
return (
407
<StandalonePage tone="error">