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
This commit is contained in:
Julius Marminge authored and Julius Marminge committed 2026-02-26 21:05:53 -08:00
1 parent 5fd632c357
commit 69a2eac2ff
1 file changed
+4 -2
+4 -2
View File
@@ -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<string | null>(null);
const handledBootstrapThreadIdRef = useRef<string | null>(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;
}