diff --git a/autogpt_platform/frontend/src/app/page.tsx b/autogpt_platform/frontend/src/app/page.tsx index 88e4e21644..ce67760eda 100644 --- a/autogpt_platform/frontend/src/app/page.tsx +++ b/autogpt_platform/frontend/src/app/page.tsx @@ -1,11 +1,15 @@ -import { redirect } from "next/navigation"; +"use client"; + +import { LoadingSpinner } from "@/components/atoms/LoadingSpinner/LoadingSpinner"; +import { useRouter } from "next/navigation"; +import { useEffect } from "react"; -/** - * Root page always redirects to /copilot. - * The /copilot page handles the feature flag check and redirects to /library if needed. - * This single-check approach avoids race conditions with LaunchDarkly initialization. - * See: SECRT-1845 - */ export default function Page() { - redirect("/copilot"); + const router = useRouter(); + + useEffect(() => { + router.replace("/copilot"); + }, [router]); + + return ; } diff --git a/autogpt_platform/frontend/src/services/feature-flags/feature-flag-provider.tsx b/autogpt_platform/frontend/src/services/feature-flags/feature-flag-provider.tsx index 9e1c812e85..da073816ac 100644 --- a/autogpt_platform/frontend/src/services/feature-flags/feature-flag-provider.tsx +++ b/autogpt_platform/frontend/src/services/feature-flags/feature-flag-provider.tsx @@ -1,5 +1,6 @@ "use client"; +import { LoadingSpinner } from "@/components/atoms/LoadingSpinner/LoadingSpinner"; import { useSupabase } from "@/lib/supabase/hooks/useSupabase"; import * as Sentry from "@sentry/nextjs"; import { LDProvider } from "launchdarkly-react-client-sdk"; @@ -15,7 +16,9 @@ export function LaunchDarklyProvider({ children }: { children: ReactNode }) { const clientId = environment.getLaunchDarklyClientId(); const context = useMemo(() => { - if (isUserLoading || !user) { + if (isUserLoading) return; + + if (!user) { return { kind: "user" as const, key: "anonymous", @@ -38,6 +41,10 @@ export function LaunchDarklyProvider({ children }: { children: ReactNode }) { return <>{children}; } + if (isUserLoading) { + return ; + } + return (