import { redirect } from "next/navigation"; import { requireUser } from "@/lib/auth"; import { settingsView } from "@/lib/settings"; import { getSettings } from "@/lib/db"; import { saveSettingsAction } from "@/lib/actions"; import { SettingsForm } from "@/components/settings-form"; const TITLES = { 1: "Paste a plan. Get a ranked fix.", 2: "Say which models to ask.", 3: "Ready." } as const; export default async function Setup({ searchParams }: { searchParams: Promise<{ step?: string }> }) { const u = await requireUser(); const step = (await searchParams).step ?? ""; const n = (["1", "2", "3"].includes(step) ? step : "1") as "1" | "2" | "3"; const view = settingsView(u.id); // Step 3 stays reachable after onboarding: it is the "are both models actually ready?" screen. if (n !== "3" && getSettings(u.id)?.onboarded === 1 && view.has_analyst && view.has_jev) redirect("/app"); return

Step {n} of 3

{TITLES[n]}

{n === "1" &&

qAI reads a SQL Server ShowPlan XML, works out the bottleneck in code, asks your model for several ways to fix it, then has Jev score each one. You configure nothing on this screen.

} {n === "2" && } {n === "3" && <>

One run = one digest, a few model calls, four Jev questions per option. If the analyst or Jev is unreachable, the report says so instead of inventing a verdict.

Analyst {view.has_analyst ? "ready" : "missing"} · Jev {view.has_jev ? "ready" : "missing"}

Go }

Keys stay in this container, encrypted with APP_SECRET · settings

{n !== "3" && Next}
; }