From 69a2eac2ff1ba0af1afd0334514789340051cab2 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 26 Feb 2026 18:58:59 -0800 Subject: [PATCH] Use pathname ref in EventRouter bootstrap navigation - Track latest `pathname` in a ref for bootstrap event handling - Prevent effect resubscriptions by removing `pathname` from deps - Keep auto-navigation gated to root route using current path --- apps/web/src/routes/__root.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx index b21389e3d4dcdac828b4b68b3e7f1c69cf922a26..a7fbeb3395bedfac5ae1060cb03780e47c5c55d8 100644 --- a/apps/web/src/routes/__root.tsx +++ b/apps/web/src/routes/__root.tsx @@ -127,8 +127,10 @@ function EventRouter() { const queryClient = useQueryClient(); const navigate = useNavigate(); const pathname = useRouterState({ select: (state) => state.location.pathname }); + const pathnameRef = useRef(pathname); const lastConfigIssuesSignatureRef = useRef(null); const handledBootstrapThreadIdRef = useRef(null); + pathnameRef.current = pathname; useEffect(() => { const api = readNativeApi(); @@ -201,7 +203,7 @@ function EventRouter() { projectId: payload.bootstrapProjectId, expanded: true, }); - if (pathname !== "/") { + if (pathnameRef.current !== "/") { return; } if (handledBootstrapThreadIdRef.current === payload.bootstrapThreadId) { @@ -264,7 +266,7 @@ function EventRouter() { unsubWelcome(); unsubServerConfigUpdated(); }; - }, [dispatch, navigate, pathname, queryClient]); + }, [dispatch, navigate, queryClient]); return null; } -- 2.54.0