The best way to control Claude Code, Codex and more from any computer or phone
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
Julius Marminge committed
Feb 26, 2026 at 18:58 UTC
69a2eac2ff1ba0af1afd0334514789340051cab2
1 file changed
+4
-2
apps/web/src/routes/__root.tsx
+4
-2
@@ -127,8 +127,10 @@ function EventRouter() {
127
const queryClient = useQueryClient();
128
const navigate = useNavigate();
129
const pathname = useRouterState({ select: (state) => state.location.pathname });
130
+ const pathnameRef = useRef(pathname);
131
const lastConfigIssuesSignatureRef = useRef<string | null>(null);
132
const handledBootstrapThreadIdRef = useRef<string | null>(null);
133
+ pathnameRef.current = pathname;
134
135
useEffect(() => {
136
const api = readNativeApi();
@@ -201,7 +203,7 @@ function EventRouter() {
203
projectId: payload.bootstrapProjectId,
204
expanded: true,
205
});
204
- if (pathname !== "/") {
206
+ if (pathnameRef.current !== "/") {
207
return;
208
}
209
if (handledBootstrapThreadIdRef.current === payload.bootstrapThreadId) {
@@ -264,7 +266,7 @@ function EventRouter() {
266
unsubWelcome();
267
unsubServerConfigUpdated();
268
};
267
- }, [dispatch, navigate, pathname, queryClient]);
269
+ }, [dispatch, navigate, queryClient]);
270
271
return null;
272
}