@@ -12,7 +12,7 @@ import {
1212 useRouter ,
1313} from "@tanstack/react-router" ;
1414import { Check , Copy } from "lucide" ;
15- import { useEffect , useEffectEvent , useMemo , useRef , useState } from "react" ;
15+ import { useEffect , useEffectEvent , useRef , useState } from "react" ;
1616
1717import { APP_BASE_NAME , APP_DISPLAY_NAME , APP_STAGE_LABEL , APP_VERSION } from "../branding" ;
1818import { resolveServerBackedAppDisplayName } from "../branding.logic" ;
@@ -152,19 +152,11 @@ function RootRouteView() {
152152 authGateState . status === "hosted-static" ,
153153 ) ;
154154
155- useEffect ( ( ) => {
156- const frame = window . requestAnimationFrame ( ( ) => {
157- syncBrowserChromeTheme ( ) ;
158- } ) ;
159- return ( ) => {
160- window . cancelAnimationFrame ( frame ) ;
161- } ;
162- } , [ pathname ] ) ;
163-
164155 if ( pathname === "/pair" || pathname === "/connect" || pathname === "/connect-agent" ) {
165156 return (
166157 < >
167158 < DocumentTitleSync />
159+ < BrowserChromeThemeSync key = { pathname } />
168160 < Outlet />
169161 </ >
170162 ) ;
@@ -176,6 +168,7 @@ function RootRouteView() {
176168 return (
177169 < >
178170 < DocumentTitleSync />
171+ < BrowserChromeThemeSync key = { pathname } />
179172 { hostedPromptLinkLanding }
180173 </ >
181174 ) ;
@@ -186,6 +179,7 @@ function RootRouteView() {
186179 < ToastProvider >
187180 < AnchoredToastProvider >
188181 < DocumentTitleSync />
182+ < BrowserChromeThemeSync key = { pathname } />
189183 < ContrastAppearanceSync />
190184 < EnvironmentThemeSync />
191185 < GlassAppearanceSync />
@@ -206,6 +200,7 @@ function RootRouteView() {
206200 return (
207201 < >
208202 < DocumentTitleSync />
203+ < BrowserChromeThemeSync key = { pathname } />
209204 < Outlet />
210205 </ >
211206 ) ;
@@ -223,6 +218,7 @@ function RootRouteView() {
223218 < ToastProvider >
224219 < AnchoredToastProvider >
225220 < DocumentTitleSync />
221+ < BrowserChromeThemeSync key = { pathname } />
226222 < ContrastAppearanceSync />
227223 < EnvironmentThemeSync />
228224 < GlassAppearanceSync />
@@ -342,6 +338,19 @@ function FontAppearanceSync() {
342338 return null ;
343339}
344340
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+
345354function DocumentTitleSync ( ) {
346355 const primaryServerVersion =
347356 useAtomValue ( primaryServerConfigAtom ) ?. environment . serverVersion ?? null ;
@@ -392,7 +401,7 @@ function RootRouteErrorView({ error }: ErrorComponentProps) {
392401 const message = errorMessage ( error ) ;
393402 // Router pathname rather than window.location: desktop uses hash history, where the window path is always "/".
394403 const pathname = useLocation ( { select : ( location ) => location . pathname } ) ;
395- const report = useMemo ( ( ) => errorReport ( error , pathname ) , [ error , pathname ] ) ;
404+ const report = errorReport ( error , pathname ) ;
396405
397406 return (
398407 < StandalonePage tone = "error" >
0 commit comments