Skip to content

Open source alternative to Semrush and Ahrefs

Add Add to ChatGPT and Add to Claude buttons and move on once the agent connects (EVE-444) (#996)

Carter Smith7919515ddcbb
diff --git a/src/client/features/ai-mcp/AgentSetup.tsx b/src/client/features/ai-mcp/AgentSetup.tsx
index 9b6120fa..cc2331ec 100644
--- a/src/client/features/ai-mcp/AgentSetup.tsx
+++ b/src/client/features/ai-mcp/AgentSetup.tsx
@@ -1,11 +1,29 @@
-import { useState } from "react";
-import { ArrowRight } from "lucide-react";
+import { useEffect, useEffectEvent, useState } from "react";
+import { useQuery } from "@tanstack/react-query";
+import { ArrowRight, Check } from "lucide-react";
import { AgentList } from "./AgentList";
+import { ClaudeIcon, OpenAIIcon } from "./AgentIcons";
import { AgentSetupPanel, AGENT_SETUP_DESCRIPTION } from "./AgentSetupPanel";
import { getAgentSetupPrompt } from "./agentSetupPrompt";
import { captureClientEvent } from "@/client/lib/posthog";
import { WizardFooter } from "@/client/features/onboarding/WizardFooter";
import { Button } from "@/client/components/ui/button";
+import { getMcpAuthorizedAt } from "@/serverFunctions/onboarding";
+
+const ONE_CLICK_INSTALLS = [
+ {
+ agent: "chatgpt",
+ name: "ChatGPT",
+ href: "https://chatgpt.com/plugins/plugin_asdk_app_6abddd2c7e4c819191f1398c4bd8e9b3",
+ Icon: OpenAIIcon,
+ },
+ {
+ agent: "claude",
+ name: "Claude",
+ href: "https://claude.com/marketplace/connectors/openseo",
+ Icon: ClaudeIcon,
+ },
+];
/** Last onboarding step. Onboarding finishes when the user clicks Go to
* dashboard, or when their agent connects over MCP (the server marks it). */
@@ -18,6 +36,25 @@ export function AgentSetup({
}) {
const prompt = getAgentSetupPrompt(window.location.origin);
const [copied, setCopied] = useState(false);
+ // Once the user copies the prompt or opens an agent listing, Go to dashboard
+ // becomes the main button.
+ const [startedSetup, setStartedSetup] = useState(false);
+ // Polls while the tab is visible, so the step moves on within a few seconds
+ // of the user returning from their agent.
+ const { data } = useQuery({
+ queryKey: ["mcpAuthorizedAt"],
+ queryFn: () => getMcpAuthorizedAt(),
+ refetchInterval: 3_000,
+ });
+ const connected = Boolean(data?.authorizedAt);
+
+ // Leave "Connected" on screen briefly before moving on.
+ const finish = useEffectEvent(onFinish);
+ useEffect(() => {
+ if (!connected) return;
+ const timer = setTimeout(finish, 1_500);
+ return () => clearTimeout(timer);
+ }, [connected]);
return (
<div>
@@ -32,13 +69,43 @@ export function AgentSetup({
</div>
<AgentSetupPanel
prompt={prompt}
- copyVariant={copied ? "outline" : "default"}
+ copyVariant={startedSetup ? "outline" : "default"}
onCopy={() => {
setCopied(true);
+ setStartedSetup(true);
captureClientEvent("onboarding:setup_prompt_copy");
}}
+ actions={ONE_CLICK_INSTALLS.map(({ agent, name, href, Icon }) => (
+ <Button
+ key={agent}
+ variant="outline"
+ size="lg"
+ className="w-full"
+ nativeButton={false}
+ render={<a href={href} target="_blank" rel="noreferrer" />}
+ onClick={() => {
+ setStartedSetup(true);
+ captureClientEvent("onboarding:add_to_agent_click", { agent });
+ }}
+ >
+ <Icon data-icon="inline-start" />
+ {/* "Add to" drops on narrow screens so both buttons fit one row. */}
+ <span>
+ <span className="max-sm:sr-only">Add to </span>
+ {name}
+ </span>
+ </Button>
+ ))}
>
- {copied ? (
+ {connected ? (
+ <p
+ role="status"
+ className="mt-3 flex items-center justify-center gap-1.5 text-sm font-medium text-success"
+ >
+ <Check className="size-4" aria-hidden />
+ Connected
+ </p>
+ ) : copied ? (
<p className="mt-3 text-center text-xs text-muted-foreground">
Paste it into your agent and approve the connection.
</p>
@@ -51,9 +118,9 @@ export function AgentSetup({
continueAction={
<Button
type="button"
- variant={copied ? "default" : "ghost"}
+ variant={startedSetup ? "default" : "ghost"}
className={
- copied
+ startedSetup
? "font-semibold"
: "h-8 gap-2 px-3 text-xs font-semibold"
}
diff --git a/src/client/features/ai-mcp/AgentSetupPanel.tsx b/src/client/features/ai-mcp/AgentSetupPanel.tsx
index b2da9e5a..e90c8061 100644
--- a/src/client/features/ai-mcp/AgentSetupPanel.tsx
+++ b/src/client/features/ai-mcp/AgentSetupPanel.tsx
@@ -9,11 +9,14 @@ export function AgentSetupPanel({
prompt,
onCopy,
copyVariant = "default",
+ actions,
children,
}: {
prompt: string;
onCopy?: () => void;
copyVariant?: ComponentProps<typeof CopyButton>["variant"];
+ /** Buttons shown side by side under the copy button, e.g. one-click installs. */
+ actions?: ReactNode;
/** Shown under the copy button, e.g. what to do after copying. */
children?: ReactNode;
}) {
@@ -31,15 +34,20 @@ export function AgentSetupPanel({
</p>
</div>
</div>
- <CopyButton
- variant={copyVariant}
- size="lg"
- className="w-full"
- value={prompt}
- label="Copy setup prompt"
- successMessage="Setup prompt copied"
- onCopy={onCopy}
- />
+ <div className="flex flex-col gap-2">
+ <CopyButton
+ variant={copyVariant}
+ size="lg"
+ className="w-full"
+ value={prompt}
+ label="Copy setup prompt"
+ successMessage="Setup prompt copied"
+ onCopy={onCopy}
+ />
+ {actions ? (
+ <div className="grid grid-cols-2 gap-2">{actions}</div>
+ ) : null}
+ </div>
{children}
</div>
<div className="mt-4 text-center">
diff --git a/src/routes/_authenticated.onboarding.index.tsx b/src/routes/_authenticated.onboarding.index.tsx
index 0e6be3d6..dd06231a 100644
--- a/src/routes/_authenticated.onboarding.index.tsx
+++ b/src/routes/_authenticated.onboarding.index.tsx
@@ -92,6 +92,9 @@ function OnboardingPage() {
};
const handleFinish = async () => {
+ // Agent setup also finishes on its own once the agent connects, so this
+ // can run again while a click's save is still pending.
+ if (saveMutation.isPending) return;
try {
await saveMutation.mutateAsync({ completed: true });
// The route guard fetched this query without a mounted observer. Refetch
diff --git a/src/serverFunctions/onboarding.ts b/src/serverFunctions/onboarding.ts
index c99b6866..75e96730 100644
--- a/src/serverFunctions/onboarding.ts
+++ b/src/serverFunctions/onboarding.ts
@@ -4,6 +4,7 @@ import { eq, sql } from "drizzle-orm";
import { z } from "zod";
import { user, userOnboardingAnswers } from "@/db/schema";
import { db } from "@/db";
+import { ActivationRepository } from "@/server/features/activation/repositories/ActivationRepository";
import { captureServerEvent } from "@/server/lib/posthog";
import { requireAuthenticatedContext } from "@/serverFunctions/middleware";
@@ -63,6 +64,16 @@ export const getOnboardingAnswers = createServerFn({ method: "GET" })
};
});
+// The onboarding Agent setup step polls this to see when an agent connects.
+export const getMcpAuthorizedAt = createServerFn({ method: "GET" })
+ .middleware(requireAuthenticatedContext)
+ .handler(async ({ context }) => {
+ const activation = await ActivationRepository.getOrganizationActivation(
+ context.organizationId,
+ );
+ return { authorizedAt: activation?.firstMcpAuthorizedAt ?? null };
+ });
+
export const saveOnboardingAnswers = createServerFn({ method: "POST" })
.middleware(requireAuthenticatedContext)
.validator(onboardingAnswersSchema)