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.

feat(frontend): capture marketing-site triggerprompt into sessionStorage (#13248)

Ubbe04c089966b5d
diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/login/useLoginPage.ts b/autogpt_platform/frontend/src/app/(no-navbar)/login/useLoginPage.ts
index db44dcb34c..059b6830d7 100644
--- a/autogpt_platform/frontend/src/app/(no-navbar)/login/useLoginPage.ts
+++ b/autogpt_platform/frontend/src/app/(no-navbar)/login/useLoginPage.ts
@@ -1,4 +1,5 @@
import { useToast } from "@/components/molecules/Toast/use-toast";
+import { useCaptureMarketingPrompt } from "@/hooks/useCaptureMarketingPrompt";
import { sanitizeAuthNext } from "@/lib/auth-redirect";
import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
import { environment } from "@/services/environment";
@@ -11,6 +12,8 @@ import z from "zod";
import { login as loginAction } from "./actions";
export function useLoginPage() {
+ useCaptureMarketingPrompt();
+
const { supabase, user, isUserLoading, isLoggedIn } = useSupabase();
const [feedback, setFeedback] = useState<string | null>(null);
const router = useRouter();
diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/signup/useSignupPage.ts b/autogpt_platform/frontend/src/app/(no-navbar)/signup/useSignupPage.ts
index 3676ce5698..57dd0126ba 100644
--- a/autogpt_platform/frontend/src/app/(no-navbar)/signup/useSignupPage.ts
+++ b/autogpt_platform/frontend/src/app/(no-navbar)/signup/useSignupPage.ts
@@ -1,4 +1,5 @@
import { useToast } from "@/components/molecules/Toast/use-toast";
+import { useCaptureMarketingPrompt } from "@/hooks/useCaptureMarketingPrompt";
import { sanitizeAuthNext } from "@/lib/auth-redirect";
import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
import { environment } from "@/services/environment";
@@ -11,6 +12,8 @@ import z from "zod";
import { signup as signupAction } from "./actions";
export function useSignupPage() {
+ useCaptureMarketingPrompt();
+
const { supabase, user, isUserLoading, isLoggedIn } = useSupabase();
const [feedback, setFeedback] = useState<string | null>(null);
const { toast } = useToast();
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/useWorkflowImportAutoSubmit.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/useWorkflowImportAutoSubmit.ts
index 2779790a27..30582984e5 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/useWorkflowImportAutoSubmit.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/useWorkflowImportAutoSubmit.ts
@@ -16,13 +16,21 @@ function extractPromptFromUrl(): {
if (typeof window === "undefined") return null;
const searchParams = new URLSearchParams(window.location.search);
- const autosubmit = searchParams.get("autosubmit") === "true";
+ const autosubmitFromUrl = searchParams.get("autosubmit") === "true";
- // Check sessionStorage first (used by workflow import for large prompts)
+ // Check sessionStorage first (used by workflow import for large prompts
+ // and by the marketing-site CTA handoff via useCaptureMarketingPrompt).
const storedPrompt = sessionStorage.getItem("importWorkflowPrompt");
if (storedPrompt) {
sessionStorage.removeItem("importWorkflowPrompt");
+ // Onboarding wipes URL params before we reach /copilot, so the
+ // marketing handoff stashes its autosubmit intent alongside the prompt.
+ const autosubmitFromStorage =
+ sessionStorage.getItem("importWorkflowAutosubmit") === "true";
+ sessionStorage.removeItem("importWorkflowAutosubmit");
+ const autosubmit = autosubmitFromUrl || autosubmitFromStorage;
+
// Check for a pre-uploaded workflow file attached to this import
let filePart: FileUIPart | undefined;
const storedFile = sessionStorage.getItem("importWorkflowFile");
@@ -77,7 +85,7 @@ function extractPromptFromUrl(): {
`${cleanURL.pathname}${cleanURL.search}`,
);
- return { prompt: prompt.trim(), autosubmit };
+ return { prompt: prompt.trim(), autosubmit: autosubmitFromUrl };
}
/**
diff --git a/autogpt_platform/frontend/src/hooks/useCaptureMarketingPrompt.ts b/autogpt_platform/frontend/src/hooks/useCaptureMarketingPrompt.ts
new file mode 100644
index 0000000000..4e45ea4ac4
--- /dev/null
+++ b/autogpt_platform/frontend/src/hooks/useCaptureMarketingPrompt.ts
@@ -0,0 +1,31 @@
+import { useMountEffect } from "./useMountEffect";
+
+const PROMPT_KEY = "importWorkflowPrompt";
+const AUTOSUBMIT_KEY = "importWorkflowAutosubmit";
+const PARAM = "triggerprompt";
+
+/**
+ * Capture a `?triggerprompt=` value handed off from the marketing site and
+ * stash it into sessionStorage so it survives the signup → onboarding →
+ * /copilot redirect chain (which would otherwise strip the URL). The /copilot
+ * page picks it up via `useWorkflowImportAutoSubmit` and auto-submits.
+ */
+export function useCaptureMarketingPrompt() {
+ useMountEffect(() => {
+ if (typeof window === "undefined") return;
+
+ const url = new URL(window.location.href);
+ const prompt = url.searchParams.get(PARAM);
+ if (!prompt || !prompt.trim()) return;
+
+ sessionStorage.setItem(PROMPT_KEY, prompt.trim());
+ sessionStorage.setItem(AUTOSUBMIT_KEY, "true");
+
+ url.searchParams.delete(PARAM);
+ window.history.replaceState(
+ null,
+ "",
+ `${url.pathname}${url.search}${url.hash}`,
+ );
+ });
+}