From cc4839bedb625be44465972655e973e031835db3 Mon Sep 17 00:00:00 2001 From: Ubbe Date: Fri, 30 Jan 2026 20:40:46 +0700 Subject: [PATCH] hotfix(frontend): fix home redirect (3) (#11904) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Changes 🏗️ Further improvements to LaunchDarkly initialisation and homepage redirect... ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Run the app locally with the flag disabled/enabled, and the redirects work --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Ubbe <0ubbe@users.noreply.github.com> --- autogpt_platform/frontend/src/app/page.tsx | 20 +++++++++++-------- .../feature-flags/feature-flag-provider.tsx | 9 ++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) 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 (