Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Clear auth and onboarding dead ends before the ShadCN port (EVE-286) (#714)
Ben Senescu257f79d98be7
diff --git a/.agents/PAPERCUTS.md b/.agents/PAPERCUTS.mdindex a1d94faa..88dae931 100644--- a/.agents/PAPERCUTS.md+++ b/.agents/PAPERCUTS.md@@ -19,6 +19,7 @@ data, or sensitive paths.- [ ] `2026-09-11T00:13:05Z` — `codex` — The web-content review skill points to the removed `src/server/features/onboarding/openseo-fact-sheet.md`; the reference now lives at `src/server/features/sam/openseo-fact-sheet.md`. Update the skill's pointer so content reviews reach the current fact sheet.- `2026-09-05T23:52:53Z` — `codex` — After `pnpm build` ran alongside an active Vite dev server, browser navigation failed and server functions returned undefined. The server logged `Cannot read properties of undefined (reading 'map')` in `runInRunnerObject` / `loadEntries`. Restarting Vite restored the same dashboard without code changes. Stop and restart the dev server around production builds before browser QA; consider documenting or isolating the shared build/runtime state.+- [ ] `2026-09-27T22:06:28Z` — `claude` — Hosted auth mode can't run behind `pnpm dev:agents`: `hostedBaseUrlSchema` in `src/lib/auth.ts` accepts only https or the exact host `localhost`, so a portless `*.localhost` `BETTER_AUTH_URL` returns 500, and setting `TURNSTILE_SITE_KEY` without `TURNSTILE_SECRET_KEY` turns every `/api/auth` call into a bare "Missing Better Auth hosted configuration" 500. Workaround: run `vite dev --port <n> --strictPort` with `BETTER_AUTH_URL=http://localhost:<n>`; fix: accept `*.localhost` over http and name the missing variable in the error.## Deferreddiff --git a/src/client/features/ai-mcp/AgentSetup.tsx b/src/client/features/ai-mcp/AgentSetup.tsxindex cae99e30..487dc93d 100644--- a/src/client/features/ai-mcp/AgentSetup.tsx+++ b/src/client/features/ai-mcp/AgentSetup.tsx@@ -43,7 +43,7 @@ export function AgentSetup({className="btn btn-ghost btn-sm gap-2"onClick={onComplete}>- Skip for now <ArrowRight className="size-4" />+ Finish <ArrowRight className="size-4" /></button></div></fieldset>diff --git a/src/client/features/audit/AuditDetail.tsx b/src/client/features/audit/AuditDetail.tsxindex c6639e36..cd47916c 100644--- a/src/client/features/audit/AuditDetail.tsx+++ b/src/client/features/audit/AuditDetail.tsx@@ -81,10 +81,12 @@ export function AuditDetail({: 0;const failedWithResults = isFailed && partialPageCount > 0;// Wait for the results fetch before choosing between the "partial results"- // banner and the zero-page support CTA, so the CTA doesn't flash first.- const showSupportCta =- (isFailed && resultsQuery.isSuccess && !failedWithResults) ||- (isComplete && status.pagesCrawled <= 1);+ // banner and the zero-page banner, so the zero-page banner doesn't flash.+ const failedWithoutResults =+ isFailed && resultsQuery.isSuccess && !failedWithResults;+ // A completed crawl that reached one page or none was blocked by the site.+ // A failed audit stopped on our side, so it gets the error code instead.+ const showBlockedCta = isComplete && status.pagesCrawled <= 1;return (<div className="px-4 py-4 md:px-6 md:py-6 pb-24 md:pb-8 overflow-auto">@@ -112,10 +114,34 @@ export function AuditDetail({/>)}- {showSupportCta && (- <div- className={isFailed ? "alert alert-error" : "alert alert-warning"}- >+ {failedWithoutResults && (+ <div className="alert alert-error">+ <AlertCircle className="size-5" />+ <div className="space-y-1">+ <p className="font-medium">+ This audit stopped before it crawled any pages.+ </p>+ <p>+ Run a new audit to try again, or email{" "}+ <a+ className="link link-primary"+ href={`mailto:${SUPPORT_EMAIL}`}+ >+ {SUPPORT_EMAIL}+ </a>{" "}+ if this keeps happening.+ </p>+ {status.errorCode ? (+ <p className="font-mono text-xs opacity-70">+ Code: {status.errorCode}+ </p>+ ) : null}+ </div>+ </div>+ )}++ {showBlockedCta && (+ <div className="alert alert-warning"><AlertCircle className="size-5" /><div className="space-y-1"><p className="font-medium">diff --git a/src/client/features/auth/TurnstileWidget.tsx b/src/client/features/auth/TurnstileWidget.tsxindex fd3ca3b1..54b5554c 100644--- a/src/client/features/auth/TurnstileWidget.tsx+++ b/src/client/features/auth/TurnstileWidget.tsx@@ -68,6 +68,9 @@ export function TurnstileWidget({// effect (a fresh onToken each render must not tear down and re-render it).const onTokenRef = useRef(onToken);onTokenRef.current = onToken;+ // Set when the script can't load (ad blocker, network filter), so the form+ // explains why it can't submit instead of sitting on a disabled button.+ const [scriptFailed, setScriptFailed] = useState(false);useEffect(() => {if (!TURNSTILE_SITE_KEY) return;@@ -98,6 +101,11 @@ export function TurnstileWidget({);const script = existing ?? document.createElement("script");script.addEventListener("load", renderWidget);+ script.addEventListener("error", () => {+ // Drop the failed tag so the next mount requests the script again.+ script.remove();+ if (!cancelled) setScriptFailed(true);+ });if (!existing) {script.src = TURNSTILE_SCRIPT_SRC;script.async = true;@@ -123,5 +131,13 @@ export function TurnstileWidget({}, [resetNonce]);if (!TURNSTILE_SITE_KEY) return null;+ if (scriptFailed) {+ return (+ <p className="text-sm text-error">+ The security check couldn’t load. Allow challenges.cloudflare.com+ in your browser or ad blocker, then reload the page.+ </p>+ );+ }return <div ref={containerRef} className="flex justify-center" />;}diff --git a/src/client/features/billing/route-state.test.ts b/src/client/features/billing/route-state.test.tsindex 675821b5..eec47f8f 100644--- a/src/client/features/billing/route-state.test.ts+++ b/src/client/features/billing/route-state.test.ts@@ -39,6 +39,16 @@ describe("getSubscribeRouteState", () => {);});+ it("keeps finalizing after a failed poll", () => {+ expect(+ getSubscribeRouteState({+ ...base,+ checkoutCompleted: true,+ isCustomerError: true,+ }),+ ).toBe("finalizing");+ });+it("lets the user through once the finalizing window runs out", () => {expect(getSubscribeRouteState({diff --git a/src/client/features/billing/route-state.ts b/src/client/features/billing/route-state.tsindex 84295a32..f2de6407 100644--- a/src/client/features/billing/route-state.ts+++ b/src/client/features/billing/route-state.ts@@ -39,7 +39,9 @@ export function getSubscribeRouteState(args: {return "redirectToApp" as const;}- if (args.isCustomerError) {+ // A failed poll while finalizing keeps polling: the error screen would stop+ // the poll and park a just-paid user on "Billing unavailable".+ if (args.isCustomerError && !args.checkoutCompleted) {return "error" as const;}diff --git a/src/routes/_authenticated.oauth-consent.tsx b/src/routes/_authenticated.oauth-consent.tsxindex 7946ccd9..44af336b 100644--- a/src/routes/_authenticated.oauth-consent.tsx+++ b/src/routes/_authenticated.oauth-consent.tsx@@ -23,7 +23,9 @@ const SCOPES = [function OAuthConsentPage() {const { data: session } = useSession();- const [isSubmitting, setIsSubmitting] = useState(false);+ const [pendingAction, setPendingAction] = useState<+ "authorize" | "cancel" | null+ >(null);const [error, setError] = useState<string | null>(null);useEffect(() => {@@ -32,39 +34,39 @@ function OAuthConsentPage() {async function respond(accept: boolean) {setError(null);- setIsSubmitting(true);+ setPendingAction(accept ? "authorize" : "cancel");if (!accept) {captureClientEvent("mcp:consent_denied");}- const response = await fetch("/api/oauth/consent", {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({- accept,- query: window.location.search,- }),- });- const data: {- redirectTo?: string;- error?: string;- } = await response.json();+ try {+ const response = await fetch("/api/oauth/consent", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ accept,+ query: window.location.search,+ }),+ });+ const data: {+ redirectTo?: string;+ error?: string;+ } = await response.json();- if (!response.ok) {- setError(data.error ?? "Unable to complete authorization.");- setIsSubmitting(false);- return;+ if (!response.ok) {+ setError(data.error ?? "Unable to complete authorization.");+ } else if (data.redirectTo) {+ window.location.assign(data.redirectTo);+ return;+ } else {+ setError("Authorization response did not include a redirect URL.");+ }+ } catch {+ setError("We couldn't reach OpenSEO. Please try again.");}-- if (data.redirectTo) {- window.location.assign(data.redirectTo);- return;- }-- setError("Authorization response did not include a redirect URL.");- setIsSubmitting(false);+ setPendingAction(null);}return (@@ -121,18 +123,18 @@ function OAuthConsentPage() {<buttontype="button"className="btn btn-ghost flex-1"- disabled={isSubmitting}+ disabled={pendingAction !== null}onClick={() => void respond(false)}>- Cancel+ {pendingAction === "cancel" ? "Canceling..." : "Cancel"}</button><buttontype="button"className="btn btn-primary flex-1"- disabled={isSubmitting}+ disabled={pendingAction !== null}onClick={() => void respond(true)}>- {isSubmitting ? "Authorizing..." : "Authorize"}+ {pendingAction === "authorize" ? "Authorizing..." : "Authorize"}</button></div>diff --git a/src/routes/_authenticated.onboarding.index.tsx b/src/routes/_authenticated.onboarding.index.tsxindex b7510b81..6552dc77 100644--- a/src/routes/_authenticated.onboarding.index.tsx+++ b/src/routes/_authenticated.onboarding.index.tsx@@ -76,19 +76,29 @@ function OnboardingFlow({const goToStep = (next: number) =>void navigate({ to: "/onboarding", search: { step: clampStep(next) } });- const handleNext = () => {+ // Wait for the save before moving on, so a failure toast shows on the step+ // the user can retry instead of on the next one.+ const handleNext = async () => {+ try {+ await saveMutation.mutateAsync({});+ } catch {+ return;+ }if (step === 0) {captureClientEvent("onboarding:interests_selected", {interests: answers.selectedInterests,interest_other: answers.interestOther.trim() || undefined,});}- saveMutation.mutate({});goToStep(step + 1);};- const handleSkip = () => {- saveMutation.mutate({});+ const handleSkip = async () => {+ try {+ await saveMutation.mutateAsync({});+ } catch {+ return;+ }captureClientEvent("onboarding:step_skipped", { step });goToStep(step + 1);};diff --git a/src/routes/_authenticated.subscribe.tsx b/src/routes/_authenticated.subscribe.tsxindex 6f594f60..24bef8c4 100644--- a/src/routes/_authenticated.subscribe.tsx+++ b/src/routes/_authenticated.subscribe.tsx@@ -98,8 +98,8 @@ function SubscribePage() {}, [refetchCustomer, isFinalizing]);// Armed once on landing with checkout=success (not on the finalizing state,- // which a transient poll error can leave and re-enter) so the deadline is a- // hard bound from arrival.+ // which a refetch with no cached data can leave for "loading" and re-enter)+ // so the deadline is a hard bound from arrival.useEffect(() => {if (!checkoutCompleted || finalizingTimedOut) return;const timeout = setTimeout(diff --git a/src/routes/accept-invitation.$id.tsx b/src/routes/accept-invitation.$id.tsxindex 7e982487..454a35cd 100644--- a/src/routes/accept-invitation.$id.tsx+++ b/src/routes/accept-invitation.$id.tsx@@ -72,7 +72,9 @@ function InvitationCard({invitationId: string;userEmail: string;}) {- const [isSubmitting, setIsSubmitting] = useState(false);+ const [pendingAction, setPendingAction] = useState<+ "accept" | "decline" | null+ >(null);const [actionError, setActionError] = useState<string | null>(null);const [declined, setDeclined] = useState(false);@@ -92,7 +94,7 @@ function InvitationCard({async function handleAccept() {setActionError(null);- setIsSubmitting(true);+ setPendingAction("accept");try {const accepted = await authClient.organization.acceptInvitation({invitationId,@@ -101,7 +103,7 @@ function InvitationCard({setActionError(accepted.error.message || "We couldn't accept the invitation.",);- setIsSubmitting(false);+ setPendingAction(null);return;}@@ -117,13 +119,13 @@ function InvitationCard({window.location.assign("/");} catch {setActionError("We couldn't accept the invitation. Please try again.");- setIsSubmitting(false);+ setPendingAction(null);}}async function handleDecline() {setActionError(null);- setIsSubmitting(true);+ setPendingAction("decline");try {const result = await authClient.organization.rejectInvitation({invitationId,@@ -132,14 +134,14 @@ function InvitationCard({setActionError(result.error.message || "We couldn't decline the invitation.",);- setIsSubmitting(false);+ setPendingAction(null);return;}captureClientEvent("team:invitation_decline");setDeclined(true);} catch {setActionError("We couldn't decline the invitation. Please try again.");- setIsSubmitting(false);+ setPendingAction(null);}}@@ -222,18 +224,18 @@ function InvitationCard({<buttontype="button"className="btn btn-soft w-full"- disabled={isSubmitting}+ disabled={pendingAction !== null}onClick={() => void handleAccept()}>- {isSubmitting ? "Joining..." : "Accept invitation"}+ {pendingAction === "accept" ? "Joining..." : "Accept invitation"}</button><buttontype="button"className="btn btn-ghost w-full"- disabled={isSubmitting}+ disabled={pendingAction !== null}onClick={() => void handleDecline()}>- Decline+ {pendingAction === "decline" ? "Declining..." : "Decline"}</button></div></AuthPageCard>diff --git a/src/routes/auth-error.tsx b/src/routes/auth-error.tsxindex 53481114..37cddb77 100644--- a/src/routes/auth-error.tsx+++ b/src/routes/auth-error.tsx@@ -5,7 +5,6 @@ import { googleAuthErrorCopy } from "@/client/features/integrations/googleAuthErconst authErrorSearchSchema = z.object({error: z.string().optional(),- error_description: z.string().optional(),});export const Route = createFileRoute("/auth-error")({diff --git a/src/routes/reset-password.tsx b/src/routes/reset-password.tsxindex 3d244fcb..2432ad47 100644--- a/src/routes/reset-password.tsx+++ b/src/routes/reset-password.tsx@@ -123,7 +123,10 @@ function ResetPasswordPage() {if (result.error) {formApi.setErrorMap({onSubmit: {- form: "This reset link is no longer valid. Request a new one and try again.",+ form:+ result.error.code === "INVALID_TOKEN" || !result.error.message+ ? "This reset link is no longer valid. Request a new one and try again."+ : result.error.message,fields: {},},});