From e10ff8d37fb5b94a1dd814d36b8789b574d12be9 Mon Sep 17 00:00:00 2001 From: Otto Date: Fri, 30 Jan 2026 08:32:50 +0000 Subject: [PATCH] fix(frontend): remove double flag check on homepage redirect (#11894) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Changes 🏗️ Fixes the hard refresh redirect bug (SECRT-1845) by removing the double feature flag check. ### Before (buggy) ``` / → checks flag → /copilot or /library /copilot (layout) → checks flag → /library if OFF ``` On hard refresh, two sequential LD checks created a race condition window. ### After (fixed) ``` / → always redirects to /copilot /copilot (layout) → single flag check via FeatureFlagPage ``` Single check point = no double-check race condition. ## Root Cause As identified by @0ubbe: the root page and copilot layout were both checking the feature flag. On hard refresh with network latency, the second check could fire before LaunchDarkly fully initialized, causing users to be bounced to `/library`. ## Test Plan - [ ] Hard refresh on `/` → should go to `/copilot` (flag ON) - [ ] Hard refresh on `/copilot` → should stay on `/copilot` (flag ON) - [ ] With flag OFF → should redirect to `/library` - [ ] Normal navigation still works Fixes: SECRT-1845 cc @0ubbe --- autogpt_platform/frontend/src/app/page.tsx | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/autogpt_platform/frontend/src/app/page.tsx b/autogpt_platform/frontend/src/app/page.tsx index 31d1e96e48..9a55e986bc 100644 --- a/autogpt_platform/frontend/src/app/page.tsx +++ b/autogpt_platform/frontend/src/app/page.tsx @@ -1,14 +1,20 @@ "use client"; -import { FeatureFlagRedirect } from "@/services/feature-flags/FeatureFlagRedirect"; -import { Flag } from "@/services/feature-flags/use-get-flag"; +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() { - return ( - - ); + const router = useRouter(); + + useEffect(() => { + router.replace("/copilot"); + }, [router]); + + return null; }