Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend): launch darkly initialisation (#10408)

Ubbee9b682cc7ab3
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 0119f3f8bb..10677f9b6c 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
@@ -3,32 +3,16 @@ import { ReactNode } from "react";
import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
import { BehaveAs, getBehaveAs } from "@/lib/utils";
-export function LaunchDarklyProvider({ children }: { children: ReactNode }) {
- const clientId = process.env.NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID;
+const clientId = process.env.NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID;
+const envEnabled = process.env.NEXT_PUBLIC_LAUNCHDARKLY_ENABLED === "true";
+export function LaunchDarklyProvider({ children }: { children: ReactNode }) {
+ const { user } = useSupabase();
const isCloud = getBehaveAs() === BehaveAs.CLOUD;
-
- const enabled =
- isCloud && process.env.NEXT_PUBLIC_LAUNCHDARKLY_ENABLED === "true";
-
- const { user, isUserLoading } = useSupabase();
+ const enabled = isCloud && envEnabled && clientId && user;
if (!enabled) return <>{children}</>;
- if (!clientId) {
- throw new Error("NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID is not defined");
- }
-
- // Show loading state while user is being determined
- if (isUserLoading) {
- return (
- <div className="flex min-h-screen items-center justify-center">
- <div className="h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" />
- </div>
- );
- }
-
- // Create user context for LaunchDarkly
const userContext = user
? {
kind: "user",