fix(web):refresh dashboard session queries

This commit is contained in:
Anish Sarkar 2026-06-23 13:01:41 +05:30
parent be95f65c6b
commit b37114f193
5 changed files with 25 additions and 20 deletions

View file

@ -13,13 +13,15 @@ import { Logo } from "@/components/Logo";
import { ModelProviderConnectionsPanel } from "@/components/settings/model-connections/model-provider-connections-panel";
import { Button } from "@/components/ui/button";
import { useGlobalLoadingEffect } from "@/hooks/use-global-loading";
import { getBearerToken, redirectToLogin } from "@/lib/auth-utils";
import { useSession } from "@/hooks/use-session";
import { redirectToLogin } from "@/lib/auth-utils";
import { hasEnabledChatModel, isLlmOnboardingComplete } from "@/lib/onboarding";
export default function OnboardPage() {
const router = useRouter();
const params = useParams();
const searchSpaceId = Number(params.search_space_id);
const session = useSession();
const { data: globalConnections = [], isLoading: globalLoading } = useAtomValue(
globalModelConnectionsAtom
);
@ -29,8 +31,8 @@ export default function OnboardPage() {
useAtomValue(globalLlmConfigStatusAtom);
useEffect(() => {
if (!getBearerToken()) redirectToLogin();
}, []);
if (session.status === "unauthenticated") redirectToLogin();
}, [session.status]);
const hasUsableChatModel = useMemo(
() => hasEnabledChatModel([...globalConnections, ...connections]),
@ -43,7 +45,8 @@ export default function OnboardPage() {
connections
);
const isLoading = globalLoading || rolesLoading || globalConfigStatusLoading;
const isLoading =
session.status === "loading" || globalLoading || rolesLoading || globalConfigStatusLoading;
// Onboarding only applies when no global_llm_config.yaml exists. If a global
// config is present (or onboarding is already complete), leave this page.

View file

@ -3,31 +3,32 @@
import { useEffect, useState } from "react";
import { USER_QUERY_KEY } from "@/atoms/user/user-query.atoms";
import { useGlobalLoadingEffect } from "@/hooks/use-global-loading";
import { ensureTokensFromElectron, getBearerToken, redirectToLogin } from "@/lib/auth-utils";
import { useSession } from "@/hooks/use-session";
import { ensureTokensFromElectron, redirectToLogin } from "@/lib/auth-utils";
import { queryClient } from "@/lib/query-client/client";
export function DashboardShell({ children }: { children: React.ReactNode }) {
const [isCheckingAuth, setIsCheckingAuth] = useState(true);
const session = useSession();
// Use the global loading screen - spinner animation won't reset
useGlobalLoadingEffect(isCheckingAuth);
useEffect(() => {
async function checkAuth() {
let token = getBearerToken();
if (!token) {
const synced = await ensureTokensFromElectron();
if (synced) token = getBearerToken();
if (typeof window !== "undefined" && window.electronAPI) {
await ensureTokensFromElectron();
}
if (!token) {
if (session.status === "loading") return;
if (session.status === "unauthenticated") {
redirectToLogin();
return;
}
queryClient.invalidateQueries({ queryKey: [...USER_QUERY_KEY] });
setIsCheckingAuth(false);
}
checkAuth();
}, []);
void checkAuth();
}, [session.status]);
// Return null while loading - the global provider handles the loading UI
if (isCheckingAuth) {