Skip to content

Open source alternative to Semrush and Ahrefs

Simplify onboarding navigation and agent setup (#639)

Ben Senescuaca747ffc7dc
diff --git a/src/client/features/ai-mcp/AgentList.tsx b/src/client/features/ai-mcp/AgentList.tsx
new file mode 100644
index 00000000..d0f856fb
--- /dev/null
+++ b/src/client/features/ai-mcp/AgentList.tsx
@@ -0,0 +1,32 @@
+import {
+ ClaudeIcon,
+ GrokIcon,
+ HermesIcon,
+ OpenAIIcon,
+ OpenClawIcon,
+} from "./AgentIcons";
+
+const AGENTS = [
+ { name: "Claude Code", Icon: ClaudeIcon },
+ { name: "ChatGPT", Icon: OpenAIIcon },
+ { name: "Grok Bot", Icon: GrokIcon },
+ { name: "Hermes", Icon: HermesIcon },
+ { name: "OpenClaw", Icon: OpenClawIcon },
+];
+
+export function AgentList() {
+ return (
+ <ul className="mt-4 flex flex-wrap items-center gap-x-4 gap-y-2">
+ {AGENTS.map(({ name, Icon }) => (
+ <li
+ key={name}
+ className="flex items-center gap-1.5 text-xs text-base-content/60"
+ >
+ <Icon className="size-4" />
+ {name}
+ </li>
+ ))}
+ <li className="text-xs text-base-content/45">or any MCP client</li>
+ </ul>
+ );
+}
diff --git a/src/client/features/ai-mcp/AgentSetup.tsx b/src/client/features/ai-mcp/AgentSetup.tsx
index 3552e53e..a7c97bbc 100644
--- a/src/client/features/ai-mcp/AgentSetup.tsx
+++ b/src/client/features/ai-mcp/AgentSetup.tsx
@@ -1,111 +1,55 @@
-import { useState } from "react";
import { ArrowLeft, ArrowRight } from "lucide-react";
+import { AgentList } from "./AgentList";
import { AgentSetupPanel, AGENT_SETUP_DESCRIPTION } from "./AgentSetupPanel";
import { getAgentSetupPrompt } from "./agentSetupPrompt";
import { captureClientEvent } from "@/client/lib/posthog";
export function AgentSetup({
- onIntentChange,
- initialIntent,
onComplete,
onBack,
disabled = false,
}: {
- onIntentChange?: (intent: "yes" | "no") => void;
- initialIntent?: "yes" | "no" | "";
- onComplete?: (intent: "yes" | "no") => void;
- onBack?: () => void;
+ onComplete: () => void;
+ onBack: () => void;
disabled?: boolean;
}) {
- const [intent, setIntent] = useState(initialIntent ?? "");
const prompt = getAgentSetupPrompt(
typeof window === "undefined"
? "https://app.openseo.so"
: window.location.origin,
);
- const Heading = onComplete ? "h1" : "h2";
- const chooseIntent = (answer: "yes" | "no") => {
- if (answer === "yes" || !onComplete) setIntent(answer);
- onIntentChange?.(answer);
- captureClientEvent("onboarding:agent_intent", { answer });
- if (answer === "no") onComplete?.("no");
- };
return (
<fieldset disabled={disabled}>
<div className="mb-8">
- <Heading className="text-2xl font-semibold tracking-tight">
- {intent === "yes" ? "Set up your agent" : "Already use an AI agent?"}
- </Heading>
+ <h1 className="text-2xl font-semibold tracking-tight">
+ Set up your agent
+ </h1>
<p className="mt-3 text-pretty text-sm leading-relaxed text-base-content/60">
- {intent === "yes"
- ? AGENT_SETUP_DESCRIPTION
- : "Like Claude, ChatGPT Desktop, or Grok Bot."}
+ {AGENT_SETUP_DESCRIPTION}
</p>
+ <AgentList />
+ </div>
+ <AgentSetupPanel
+ prompt={prompt}
+ onCopy={() => captureClientEvent("onboarding:setup_prompt_copy")}
+ />
+ <div className="mt-7 flex items-center justify-between gap-3 border-t border-base-300 pt-5">
+ <button
+ type="button"
+ className="flex min-h-10 items-center gap-1.5 text-xs text-base-content/60 hover:text-base-content"
+ onClick={onBack}
+ >
+ <ArrowLeft className="size-3.5" /> Back
+ </button>
+ <button
+ type="button"
+ className="btn btn-ghost btn-sm gap-2"
+ onClick={() => onComplete()}
+ >
+ Skip for now <ArrowRight className="size-4" />
+ </button>
</div>
- {intent === "yes" ? (
- <>
- <AgentSetupPanel
- prompt={prompt}
- onCopy={() => captureClientEvent("onboarding:setup_prompt_copy")}
- />
- <div className="mt-7 flex items-center justify-between gap-3 border-t border-base-300 pt-5">
- <button
- type="button"
- className="flex min-h-10 items-center gap-1.5 text-xs text-base-content/60 hover:text-base-content"
- onClick={() => setIntent("")}
- >
- <ArrowLeft className="size-3.5" /> Back
- </button>
- {onComplete && (
- <button
- type="button"
- className="btn btn-ghost btn-sm gap-2"
- onClick={() => onComplete("yes")}
- >
- Go to dashboard <ArrowRight className="size-4" />
- </button>
- )}
- </div>
- </>
- ) : (
- <>
- <div className="flex items-center justify-between gap-3">
- {onBack && (
- <button
- type="button"
- className="flex min-h-10 items-center gap-1.5 text-xs text-base-content/60 hover:text-base-content"
- onClick={onBack}
- >
- <ArrowLeft className="size-3.5" /> Back
- </button>
- )}
- <div className="ml-auto flex gap-3">
- <button
- type="button"
- className="btn btn-outline min-w-16"
- aria-pressed={onComplete ? undefined : intent === "no"}
- onClick={() => chooseIntent("no")}
- >
- No
- </button>
- <button
- type="button"
- className="btn btn-primary min-w-24"
- onClick={() => chooseIntent("yes")}
- >
- Yes <ArrowRight className="size-4" />
- </button>
- </div>
- </div>
- {intent === "no" && (
- <p className="mt-4 text-sm text-base-content/60">
- You can use the dashboard on its own and connect an agent anytime
- from Agent setup.
- </p>
- )}
- </>
- )}
</fieldset>
);
}
diff --git a/src/client/features/gsc/SitePicker.tsx b/src/client/features/gsc/SitePicker.tsx
index 234272d1..59a200ef 100644
--- a/src/client/features/gsc/SitePicker.tsx
+++ b/src/client/features/gsc/SitePicker.tsx
@@ -1,3 +1,4 @@
+import type { ReactNode } from "react";
import { GooglePropertyPicker } from "@/client/features/integrations/GooglePropertyPicker";
type SiteOption = {
siteUrl: string;
@@ -29,6 +30,8 @@ export function SitePicker(props: {
onSelect: (selection: GscSiteSelection | null) => void;
onSave: () => void;
saving: boolean;
+ saveLabel?: string;
+ renderActions?: (saveButton: ReactNode) => ReactNode;
onRetry: () => void;
onReconnect: () => void;
secondaryAction?: { label: string; onClick: () => void; disabled?: boolean };
diff --git a/src/client/features/integrations/GooglePropertyPicker.tsx b/src/client/features/integrations/GooglePropertyPicker.tsx
index d65c4a58..a75ba729 100644
--- a/src/client/features/integrations/GooglePropertyPicker.tsx
+++ b/src/client/features/integrations/GooglePropertyPicker.tsx
@@ -1,5 +1,11 @@
import { GoogleAccountRemovalDialog } from "@/client/features/integrations/GoogleAccountRemovalDialog";
-import { useId, useRef, useState, type KeyboardEvent } from "react";
+import {
+ useId,
+ useRef,
+ useState,
+ type KeyboardEvent,
+ type ReactNode,
+} from "react";
import { Check, ChevronDown, Plus, Search } from "lucide-react";
type Selection = { accountId: string; propertyId: string };
@@ -37,9 +43,11 @@ export function GooglePropertyPicker({
onSelect,
onSave,
saving,
+ saveLabel = "Save property",
onRetry,
onReconnect,
secondaryAction,
+ renderActions,
}: {
provider: "gsc" | "ga4";
readOnly?: boolean;
@@ -51,9 +59,11 @@ export function GooglePropertyPicker({
onSelect: (selection: Selection | null) => void;
onSave: () => void;
saving: boolean;
+ saveLabel?: string;
onRetry: () => void;
onReconnect: () => void;
secondaryAction?: SecondaryAction;
+ renderActions?: (saveButton: ReactNode) => ReactNode;
}) {
const [open, setOpen] = useState(false);
const [removing, setRemoving] = useState<Account | null>(null);
@@ -93,6 +103,17 @@ export function GooglePropertyPicker({
setSearch("");
trigger.current?.focus();
};
+ const saveButton = (
+ <button
+ hidden={readOnly}
+ type="button"
+ className="btn btn-primary btn-sm"
+ onClick={onSave}
+ disabled={!canSave || saving}
+ >
+ {saving ? "Saving…" : saveLabel}
+ </button>
+ );
return (
<div className="space-y-4">
{removing ? (
@@ -307,27 +328,23 @@ export function GooglePropertyPicker({
</div>
) : null}
</div>
- <div className="flex flex-wrap items-center gap-1">
- <button
- hidden={readOnly}
- type="button"
- className="btn btn-primary btn-sm"
- onClick={onSave}
- disabled={!canSave || saving}
- >
- {saving ? "Saving…" : "Save property"}
- </button>
- {secondaryAction ? (
- <button
- type="button"
- className="btn btn-ghost btn-sm"
- disabled={saving || secondaryAction.disabled}
- onClick={secondaryAction.onClick}
- >
- {secondaryAction.label}
- </button>
- ) : null}
- </div>
+ {renderActions ? (
+ renderActions(saveButton)
+ ) : (
+ <div className="flex flex-wrap items-center gap-1">
+ {saveButton}
+ {secondaryAction ? (
+ <button
+ type="button"
+ className="btn btn-ghost btn-sm"
+ disabled={saving || secondaryAction.disabled}
+ onClick={secondaryAction.onClick}
+ >
+ {secondaryAction.label}
+ </button>
+ ) : null}
+ </div>
+ )}
</div>
);
}
diff --git a/src/client/features/integrations/googleLinkError.test.ts b/src/client/features/integrations/googleLinkError.test.ts
new file mode 100644
index 00000000..c43448b5
--- /dev/null
+++ b/src/client/features/integrations/googleLinkError.test.ts
@@ -0,0 +1,101 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { googleAuthErrorCopy } from "./googleAuthErrorCopy";
+
+const captureClientEvent = vi.hoisted(() => vi.fn());
+vi.mock("@/client/lib/posthog", () => ({ captureClientEvent }));
+
+beforeEach(() => vi.resetModules());
+afterEach(() => vi.unstubAllGlobals());
+
+async function openCallback(path: string) {
+ const location = new URL(path, "https://app.example.com");
+ const state = { key: "preserved-router-state" };
+ const replaceState = vi.fn((_state, _title, url: URL) => {
+ location.href = url.href;
+ });
+ vi.stubGlobal("window", {
+ location,
+ history: { state, replaceState },
+ });
+ const errors = await import("./googleLinkError");
+ errors.captureGoogleLinkError();
+ return { errors, location, state, replaceState };
+}
+
+describe("Google link callback errors", () => {
+ it("recovers an account conflict appended after the dashboard anchor", async () => {
+ const { errors, location, state, replaceState } = await openCallback(
+ "/p/project-a?google_link_error=gsc#connect-gsc&error=account_already_linked_to_different_user&error_description=Already%20linked",
+ );
+
+ const error = errors.getGoogleLinkError("gsc");
+ expect(error).toEqual({ code: "account_already_linked_to_different_user" });
+ const copy = googleAuthErrorCopy(error!.code, "Search Console");
+ expect(copy.title).toBe("Google account already connected");
+ expect(copy.description).toContain(
+ "Sign in to the OpenSEO user that linked it",
+ );
+ expect(location.href).toBe(
+ "https://app.example.com/p/project-a#connect-gsc",
+ );
+ expect(replaceState).toHaveBeenCalledWith(state, "", expect.any(URL));
+
+ errors.reportGoogleLinkErrorOnce();
+ errors.reportGoogleLinkErrorOnce();
+ expect(captureClientEvent).toHaveBeenCalledExactlyOnceWith(
+ "gsc:connect_error",
+ { error_code: "account_already_linked_to_different_user" },
+ );
+ expect(errors.getGoogleLinkError("ga4")).toBeNull();
+ errors.clearGoogleLinkError();
+ expect(errors.getGoogleLinkError("gsc")).toBeNull();
+ });
+
+ it("keeps ordinary query errors and onboarding step parameters", async () => {
+ const { errors, location } = await openCallback(
+ "/onboarding?step=3&google_link_error=gsc&error=access_denied&error_description=Denied",
+ );
+ expect(errors.getGoogleLinkError("gsc")).toEqual({ code: "access_denied" });
+ expect(location.href).toBe("https://app.example.com/onboarding?step=3");
+ });
+
+ it("preserves unrelated query and fragment parameters and supports GA4", async () => {
+ const { errors, location } = await openCallback(
+ "/p/project-a?range=28d&google_link_error=ga4#connect-ga4&tab=overview&error=state_mismatch",
+ );
+ expect(errors.getGoogleLinkError("ga4")).toEqual({
+ code: "state_mismatch",
+ });
+ expect(location.href).toBe(
+ "https://app.example.com/p/project-a?range=28d#connect-ga4&tab=overview",
+ );
+ errors.reportGoogleLinkErrorOnce();
+ expect(captureClientEvent).toHaveBeenCalledWith("ga4:connect_error", {
+ error_code: "state_mismatch",
+ });
+ });
+
+ it("prefers a query error when both locations contain one", async () => {
+ const { errors, location } = await openCallback(
+ "/p/project-a?google_link_error=gsc&error=access_denied#connect-gsc&error=state_mismatch",
+ );
+ expect(errors.getGoogleLinkError("gsc")).toEqual({ code: "access_denied" });
+ expect(location.hash).toBe("#connect-gsc");
+ });
+
+ it("does not consume errors from unrelated redirects", async () => {
+ const path =
+ "/p/project-a?error=access_denied#connect-gsc&error=state_mismatch";
+ const { errors, location, replaceState } = await openCallback(path);
+ expect(errors.getGoogleLinkError("gsc")).toBeNull();
+ expect(replaceState).not.toHaveBeenCalled();
+ expect(location.href).toBe("https://app.example.com" + path);
+ errors.reportGoogleLinkErrorOnce();
+ expect(captureClientEvent).not.toHaveBeenCalled();
+ });
+
+ it("reports unknown when a marked callback has no error code", async () => {
+ const { errors } = await openCallback("/p/project-a?google_link_error=gsc");
+ expect(errors.getGoogleLinkError("gsc")).toEqual({ code: "unknown" });
+ });
+});
diff --git a/src/client/features/integrations/googleLinkError.ts b/src/client/features/integrations/googleLinkError.ts
index ce67807f..9aa4b866 100644
--- a/src/client/features/integrations/googleLinkError.ts
+++ b/src/client/features/integrations/googleLinkError.ts
@@ -28,7 +28,18 @@ function captureLinkErrorFromLocation(): CapturedLinkError | null {
const url = new URL(window.location.href);
const provider = url.searchParams.get(GOOGLE_LINK_ERROR_PARAM);
if (provider !== "gsc" && provider !== "ga4") return null;
- const code = url.searchParams.get("error") ?? "unknown";
+ // OAuth can append &error= after an existing #connect-gsc anchor.
+ // Retain the anchor so the dashboard can reopen the connection step.
+ const [anchor, ...fragmentParts] = url.hash.slice(1).split("&");
+ const fragmentParams = new URLSearchParams(fragmentParts.join("&"));
+ const code =
+ url.searchParams.get("error") ?? fragmentParams.get("error") ?? "unknown";
+ if (fragmentParams.has("error") || fragmentParams.has("error_description")) {
+ fragmentParams.delete("error");
+ fragmentParams.delete("error_description");
+ const remaining = fragmentParams.toString();
+ url.hash = `${anchor}${remaining ? `&${remaining}` : ""}`;
+ }
url.searchParams.delete(GOOGLE_LINK_ERROR_PARAM);
url.searchParams.delete("error");
url.searchParams.delete("error_description");
diff --git a/src/client/features/integrations/googleSetupState.test.ts b/src/client/features/integrations/googleSetupState.test.ts
index 46812e4c..a2fceb3f 100644
--- a/src/client/features/integrations/googleSetupState.test.ts
+++ b/src/client/features/integrations/googleSetupState.test.ts
@@ -40,9 +40,10 @@ function renderSetup(
hasGrant: boolean,
connected = false,
canManage = true,
+ connectionError?: "initial" | "refetch",
) {
const client = new QueryClient({
- defaultOptions: { queries: { retry: false } },
+ defaultOptions: { queries: { retry: false, retryOnMount: false } },
});
client.setQueryData(["projects"], [{ id: "project-a" }]);
const provider = surface === "ga4" ? "ga4" : "gsc";
@@ -55,9 +56,25 @@ function renderSetup(
propertyId: "properties/123",
propertyDisplayName: "Example",
});
+ if (connectionError) {
+ client
+ .getQueryCache()
+ .find({
+ queryKey: [`${provider}Connection`, "project-a"],
+ })
+ ?.setState({
+ status: "error",
+ error: new Error("Connection check failed"),
+ ...(connectionError === "initial" ? { data: undefined } : {}),
+ });
+ }
const component =
surface === "onboarding"
- ? createElement(SearchConsoleOnboardingStep)
+ ? createElement(SearchConsoleOnboardingStep, {
+ onNext: vi.fn(),
+ onBack: vi.fn(),
+ onSkip: vi.fn(),
+ })
: createElement(
surface === "gsc"
? SearchConsoleConnectionCard
@@ -105,3 +122,52 @@ it.each(["gsc", "ga4"] as const)(
expect(html).toContain("Manage Google accounts");
},
);
+
+describe("onboarding connection actions", () => {
+ it("keeps cached property setup and a single footer after a failed refetch", () => {
+ const html = renderSetup("onboarding", true, false, true, "refetch");
+ expect(html).toContain("Choose property");
+ expect(html).not.toContain("check your Google connection.");
+ expect(html.match(/Save and continue/g)).toHaveLength(1);
+ expect(html.match(/Skip for now/g)).toHaveLength(1);
+ expect(html.match(/ Back<\/button>/g)).toHaveLength(1);
+ });
+
+ it("keeps a saved connection usable after a failed refetch", () => {
+ const html = renderSetup("onboarding", true, true, true, "refetch");
+ expect(html).toContain("https://example.com/");
+ expect(html).toMatch(/>Continue[ <]/);
+ expect(html).not.toContain("Save and continue");
+ });
+
+ it("offers retry and disables saving when the initial connection check fails", () => {
+ const html = renderSetup("onboarding", false, false, true, "initial");
+ expect(html).toContain("Couldn&#x27;t check your Google connection.");
+ expect(html).toContain("Try again");
+ expect(html).not.toContain("Choose property");
+ expect(html).toMatch(/disabled="">Save and continue<\/button>/);
+ });
+
+ it("requires saving a property or explicitly skipping before advancing", () => {
+ const html = renderSetup("onboarding", true);
+ expect(html).toContain("Save and continue");
+ expect(html).toContain("Skip for now");
+ expect(html).not.toMatch(/>Continue[ <]/);
+ expect(html).not.toContain("Save property");
+ });
+
+ it("offers an explicit skip before Google authorization", () => {
+ const html = renderSetup("onboarding", false);
+ expect(html).toContain("Skip for now");
+ expect(html).not.toMatch(/>Continue[ <]/);
+ expect(html).toContain("Save and continue");
+ expect(html).toMatch(/disabled="">Save and continue<\/button>/);
+ });
+
+ it("allows continuing without another save for an existing connection", () => {
+ const html = renderSetup("onboarding", true, true);
+ expect(html).toMatch(/>Continue[ <]/);
+ expect(html).not.toContain("Save and continue");
+ expect(html).not.toContain("Skip for now");
+ });
+});
diff --git a/src/client/features/onboarding/PostSignupOnboarding.tsx b/src/client/features/onboarding/PostSignupOnboarding.tsx
index 23fa861a..d6cb78c5 100644
--- a/src/client/features/onboarding/PostSignupOnboarding.tsx
+++ b/src/client/features/onboarding/PostSignupOnboarding.tsx
@@ -102,20 +102,20 @@ export function PostSignupOnboarding({
onOtherChange={(sourceOther) => updateAnswers({ sourceOther })}
/>
) : step === 3 ? (
- <SearchConsoleOnboardingStep />
+ <SearchConsoleOnboardingStep
+ onNext={onNext}
+ onBack={onBack}
+ onSkip={onSkip}
+ />
) : (
<AgentSetup
- initialIntent={answers.mcpSetupIntent}
onComplete={onFinish}
onBack={onBack}
disabled={isSaving}
- onIntentChange={(mcpSetupIntent) =>
- updateAnswers({ mcpSetupIntent })
- }
/>
)}
- {step < ONBOARDING_LAST_STEP && (
+ {step < 3 && (
<div className="mt-8 flex items-center justify-between gap-3">
{step > 0 ? (
<button
diff --git a/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx b/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx
index a7f77901..f3e0ee02 100644
--- a/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx
+++ b/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx
@@ -1,6 +1,6 @@
import * as React from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
-import { Check } from "lucide-react";
+import { ArrowLeft, ArrowRight, Check } from "lucide-react";
import { toast } from "sonner";
import { GoogleGlyph } from "@/client/features/gsc/GoogleGlyph";
import { GoogleLinkErrorAlert } from "@/client/features/integrations/GoogleLinkErrorAlert";
@@ -30,7 +30,13 @@ const GRANT_STATUS_KEY = ["gscGrantStatus"];
* same binding the project's Integrations page does. The step lives before the
* agent-setup screen because most users leave onboarding from that screen.
*/
-export function SearchConsoleOnboardingStep() {
+type NavigationProps = {
+ onNext: () => void;
+ onBack: () => void;
+ onSkip: () => void;
+};
+
+export function SearchConsoleOnboardingStep(props: NavigationProps) {
const projectsQuery = useQuery({
queryKey: ["projects"],
queryFn: () => getProjects(),
@@ -49,13 +55,25 @@ export function SearchConsoleOnboardingStep() {
</p>
</div>
- {project ? <GscConnect projectId={project.id} /> : <Checking />}
+ {project ? (
+ <GscConnect key={project.id} projectId={project.id} {...props} />
+ ) : (
+ <>
+ <Checking />
+ <StepNavigation {...props} />
+ </>
+ )}
</div>
);
}
/** Connect + pick-a-property flow, scoped to a known project. */
-function GscConnect({ projectId }: { projectId: string }) {
+function GscConnect({
+ projectId,
+ onNext,
+ onBack,
+ onSkip,
+}: { projectId: string } & NavigationProps) {
const queryClient = useQueryClient();
const linking = useGoogleLinkPending();
const [selection, setSelection] = React.useState<GscSiteSelection | null>(
@@ -70,8 +88,7 @@ function GscConnect({ projectId }: { projectId: string }) {
const connection = connectionQuery.data;
const connected = Boolean(connection?.connected);
const hasGrant = Boolean(connection?.currentUserHasGrant);
- const needsSetup =
- connectionQuery.isSuccess && !connection?.googleOAuthConfigured;
+ const needsSetup = Boolean(connection && !connection.googleOAuthConfigured);
const sitesQuery = useQuery({
queryKey: ["gscSites", projectId],
@@ -103,6 +120,7 @@ function GscConnect({ projectId }: { projectId: string }) {
void queryClient.invalidateQueries({ queryKey: connectionKey });
// The dashboard checklist reads the same connection state.
void queryClient.invalidateQueries({ queryKey: ["projects"] });
+ onNext();
},
onError: (error) => toast.error(getStandardErrorMessage(error)),
});
@@ -114,64 +132,130 @@ function GscConnect({ projectId }: { projectId: string }) {
void startGoogleLink("gsc", window.location.href);
};
- if (connectionQuery.isLoading) return <Checking />;
-
- if (needsSetup) {
- return <SelfHostedSetupWarning />;
- }
-
- if (connected) {
- return (
- <div className="flex items-center gap-3 rounded-lg border border-success/30 bg-success/10 p-3.5 text-sm">
- <span className="flex size-6 shrink-0 items-center justify-center rounded-full bg-success/20 text-success">
- <Check className="size-3.5" />
- </span>
- <span className="text-base-content/80">
- Connected to <span className="font-mono">{connection?.siteUrl}</span>.
- </span>
- </div>
- );
- }
-
- if (hasGrant) {
- return (
- <div className="space-y-4">
- <GoogleLinkErrorAlert provider="gsc" />
- <fieldset disabled={linking}>
- <SitePicker
- linking={linking}
- loading={sitesQuery.isLoading}
- error={sitesQuery.isError}
- accounts={accounts}
- selection={selection}
- onSelect={setSelection}
- onSave={() => selection && setSiteMutation.mutate(selection)}
- saving={setSiteMutation.isPending}
- onRetry={() => void sitesQuery.refetch()}
- onReconnect={handleConnect}
- />
- </fieldset>
- </div>
- );
- }
+ const busy = linking || setSiteMutation.isPending;
+ const showPicker = hasGrant && !connected && !needsSetup;
return (
- <div className="space-y-4">
- <GoogleLinkErrorAlert provider="gsc" />
+ <fieldset disabled={busy}>
+ {connectionQuery.isLoading ? (
+ <Checking />
+ ) : connectionQuery.isError && !connection ? (
+ <div role="alert" className="text-sm">
+ <p>Couldn't check your Google connection.</p>
+ <button
+ type="button"
+ className="btn btn-ghost btn-sm"
+ onClick={() => void connectionQuery.refetch()}
+ >
+ Try again
+ </button>
+ </div>
+ ) : needsSetup ? (
+ <SelfHostedSetupWarning />
+ ) : connected ? (
+ <div className="flex items-center gap-3 rounded-lg border border-success/30 bg-success/10 p-3.5 text-sm">
+ <span className="flex size-6 shrink-0 items-center justify-center rounded-full bg-success/20 text-success">
+ <Check className="size-3.5" />
+ </span>
+ <span className="text-base-content/80">
+ Connected to{" "}
+ <span className="font-mono">{connection?.siteUrl}</span>.
+ </span>
+ </div>
+ ) : (
+ <div className="space-y-4">
+ <GoogleLinkErrorAlert provider="gsc" />
+ {hasGrant ? (
+ <SitePicker
+ linking={linking}
+ loading={sitesQuery.isLoading}
+ error={sitesQuery.isError}
+ accounts={accounts}
+ selection={selection}
+ onSelect={setSelection}
+ onSave={() =>
+ selection && !busy && setSiteMutation.mutate(selection)
+ }
+ saveLabel="Save and continue"
+ renderActions={(saveButton) => (
+ <StepNavigation
+ onNext={onNext}
+ onBack={onBack}
+ onSkip={onSkip}
+ saveAction={saveButton}
+ />
+ )}
+ saving={setSiteMutation.isPending}
+ onRetry={() => void sitesQuery.refetch()}
+ onReconnect={handleConnect}
+ />
+ ) : (
+ <button
+ type="button"
+ onClick={handleConnect}
+ disabled={linking}
+ aria-busy={linking}
+ className="inline-flex items-center gap-2.5 rounded-lg border border-base-300 bg-base-100 px-4 py-2.5 text-sm font-semibold text-base-content shadow-sm transition hover:bg-base-200 hover:shadow focus-visible:outline-2 focus-visible:outline-primary"
+ >
+ {linking ? (
+ <span className="loading loading-spinner loading-xs" />
+ ) : (
+ <GoogleGlyph className="size-[18px]" />
+ )}
+ {linking ? "Opening Google…" : "Connect with Google"}
+ </button>
+ )}
+ </div>
+ )}
+ {!showPicker && (
+ <StepNavigation
+ connected={connected}
+ onNext={onNext}
+ onBack={onBack}
+ onSkip={onSkip}
+ />
+ )}
+ </fieldset>
+ );
+}
+
+function StepNavigation({
+ connected = false,
+ onNext,
+ onBack,
+ onSkip,
+ saveAction,
+}: NavigationProps & { connected?: boolean; saveAction?: React.ReactNode }) {
+ return (
+ <div className="mt-8 flex items-center justify-between gap-3">
<button
type="button"
- onClick={handleConnect}
- disabled={linking}
- aria-busy={linking}
- className="inline-flex items-center gap-2.5 rounded-lg border border-base-300 bg-base-100 px-4 py-2.5 text-sm font-semibold text-base-content shadow-sm transition hover:bg-base-200 hover:shadow focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
+ className="flex min-h-10 items-center gap-1.5 text-xs text-base-content/60 hover:text-base-content"
+ onClick={onBack}
>
- {linking ? (
- <span className="loading loading-spinner loading-xs" />
+ <ArrowLeft className="size-3.5" /> Back
+ </button>
+ <div className="flex items-center gap-2">
+ {connected ? (
+ <button type="button" className="btn btn-primary" onClick={onNext}>
+ Continue <ArrowRight className="size-4" />
+ </button>
) : (
- <GoogleGlyph className="size-[18px]" />
+ <button
+ type="button"
+ className="btn btn-ghost btn-sm text-base-content/55"
+ onClick={onSkip}
+ >
+ Skip for now
+ </button>
)}
- {linking ? "Opening Google…" : "Connect with Google"}
- </button>
+ {!connected &&
+ (saveAction ?? (
+ <button type="button" className="btn btn-primary btn-sm" disabled>
+ Save and continue
+ </button>
+ ))}
+ </div>
</div>
);
}
diff --git a/src/routes/_app/ai.tsx b/src/routes/_app/ai.tsx
index ad45e910..3e4738fe 100644
--- a/src/routes/_app/ai.tsx
+++ b/src/routes/_app/ai.tsx
@@ -8,13 +8,7 @@ import {
getAgentSetupPrompt,
} from "@/client/features/ai-mcp/agentSetupPrompt";
import { CopyButton } from "@/client/features/ai-mcp/SetupControls";
-import {
- ClaudeIcon,
- GrokIcon,
- HermesIcon,
- OpenAIIcon,
- OpenClawIcon,
-} from "@/client/features/ai-mcp/AgentIcons";
+import { AgentList } from "@/client/features/ai-mcp/AgentList";
const DOCS_URL = "https://openseo.so/docs/agent-setup";
const COACH_DOCS_URL = "https://openseo.so/docs/skills/seo-coach";
@@ -39,13 +33,6 @@ const SKILLS = [
["local-seo", "Audits a Google Business Profile and Maps visibility."],
["seo-report", "Saves any of the above as a report on your Reports page."],
];
-const AGENTS = [
- { name: "Claude Code", Icon: ClaudeIcon },
- { name: "ChatGPT", Icon: OpenAIIcon },
- { name: "Grok Bot", Icon: GrokIcon },
- { name: "Hermes", Icon: HermesIcon },
- { name: "OpenClaw", Icon: OpenClawIcon },
-];
export const Route = createFileRoute("/_app/ai")({
component: AiPage,
@@ -99,20 +86,7 @@ function AiPage() {
install its SEO skills. It will guide you through any manual
steps.
</p>
- <ul className="mt-4 flex flex-wrap items-center gap-x-4 gap-y-2">
- {AGENTS.map(({ name, Icon }) => (
- <li
- key={name}
- className="flex items-center gap-1.5 text-xs text-base-content/60"
- >
- <Icon className="size-4" />
- {name}
- </li>
- ))}
- <li className="text-xs text-base-content/45">
- or any MCP client
- </li>
- </ul>
+ <AgentList />
<div className="mt-5 flex flex-wrap items-center gap-x-5 gap-y-3 [&>button]:h-11 [&>button]:gap-2 [&>button]:text-sm">
<CopyButton
primary