Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Match the Prompt Research layout and AI visibility page spacing to the other pages (EVE-399) (#883)
Carter Smithb9bce3d2492e
diff --git a/src/client/features/ai-visibility/PromptHistoryPage.tsx b/src/client/features/ai-visibility/PromptHistoryPage.tsxindex 45879f09..39879b2a 100644--- a/src/client/features/ai-visibility/PromptHistoryPage.tsx+++ b/src/client/features/ai-visibility/PromptHistoryPage.tsx@@ -46,11 +46,13 @@ export function PromptHistoryPage({prefetchRunNowCost(queryClient, projectId, tracker, [promptId]);}, [queryClient, projectId, promptId, tracker]);return (- <div className="space-y-5 pt-1">- <BackLink to="/p/$projectId/ai-visibility" params={{ projectId }}>- All tracked prompts- </BackLink>+ <div className="space-y-4"><PageHeader+ backLink={+ <BackLink to="/p/$projectId/ai-visibility" params={{ projectId }}>+ All tracked prompts+ </BackLink>+ }title={<span className="whitespace-pre-wrap" data-ph-mask>{prompt?.text ?? retainedPrompt ?? "Prompt analysis"}diff --git a/src/client/features/ai-visibility/PromptResearchKeyword.tsx b/src/client/features/ai-visibility/PromptResearchKeyword.tsxindex 421314d5..660b4304 100644--- a/src/client/features/ai-visibility/PromptResearchKeyword.tsx+++ b/src/client/features/ai-visibility/PromptResearchKeyword.tsx@@ -1,7 +1,5 @@import { useState } from "react";import { useQuery, useQueryClient } from "@tanstack/react-query";-import { Link } from "@tanstack/react-router";-import { ArrowLeft } from "lucide-react";import { SkeletonTableRows } from "@/client/components/SkeletonPresets";import { Button } from "@/client/components/ui/button";import { researchAiVisibilityPrompts } from "@/serverFunctions/ai-visibility";@@ -54,26 +52,10 @@ export function PromptResearchKeyword({});};return (- <div className="space-y-5 pt-1">- <div>- <Button- variant="ghost"- size="sm"- nativeButton={false}- render={- <Link- to="/p/$projectId/ai-visibility/research"- params={{ projectId }}- />- }- >- <ArrowLeft /> Back- </Button>- </div>- <h1 className="text-2xl font-semibold tracking-tight">{keyword}</h1>+ <><div className="overflow-hidden rounded-lg border bg-card border-border"><div className="flex flex-wrap items-center justify-between gap-3 border-b px-4 py-3 border-border">- <h2 className="font-medium">Prompts</h2>+ <h2 className="font-medium">Prompts about “{keyword}”</h2><Button size="sm" disabled={!selected.size} onClick={track}>Track selected{selected.size ? ` (${selected.size})` : ""}</Button>@@ -120,6 +102,6 @@ export function PromptResearchKeyword({}}/>)}- </div>+ </>);}diff --git a/src/client/features/ai-visibility/PromptResearchPage.tsx b/src/client/features/ai-visibility/PromptResearchPage.tsxindex adb05d0d..b7474e9a 100644--- a/src/client/features/ai-visibility/PromptResearchPage.tsx+++ b/src/client/features/ai-visibility/PromptResearchPage.tsx@@ -1,15 +1,15 @@import { useState } from "react";import { useQuery } from "@tanstack/react-query";import { Link, useNavigate } from "@tanstack/react-router";-import { ChevronRight, Search, Telescope } from "lucide-react";+import { ChevronRight, Telescope } from "lucide-react";import { EmptyState } from "@/client/components/EmptyState";-import { PageHeader } from "@/client/components/PageHeader";+import { BackLink, PageHeader } from "@/client/components/PageHeader";+import { SearchCard, SearchInput } from "@/client/components/SearchCard";import {SkeletonPageContent,SkeletonTableRows,} from "@/client/components/SkeletonPresets";import { Button } from "@/client/components/ui/button";-import { Input } from "@/client/components/ui/input";import {Table,TableBody,@@ -45,10 +45,23 @@ export function PromptResearchPage({}}/>);- if (!state?.configured)- return (- <div className="space-y-5 pt-1">- <PageHeader title="Prompt Research" />+ return (+ <div className="space-y-4">+ <PageHeader+ title="Prompt Research"+ description="Find the questions people ask AI about your market, and the sites the answers cite."+ backLink={+ keyword && state?.configured ? (+ <BackLink+ to="/p/$projectId/ai-visibility/research"+ params={{ projectId }}+ >+ Relevant keywords+ </BackLink>+ ) : undefined+ }+ />+ {!state?.configured ? (<EmptyStateicon={Telescope}title="Prompt research starts with a tracker"@@ -65,17 +78,28 @@ export function PromptResearchPage({</Button>}/>- </div>- );- return keyword ? (- <PromptResearchKeyword- key={keyword}- projectId={projectId}- state={state}- keyword={keyword}- />- ) : (- <KeywordList projectId={projectId} />+ ) : (+ <>+ {/* A new keyword resets the draft. The prefix keeps this key apart+ from its keyword-view sibling's. */}+ <KeywordSearch+ key={`search:${keyword ?? ""}`}+ projectId={projectId}+ keyword={keyword}+ />+ {keyword ? (+ <PromptResearchKeyword+ key={keyword}+ projectId={projectId}+ state={state}+ keyword={keyword}+ />+ ) : (+ <KeywordList projectId={projectId} />+ )}+ </>+ )}+ </div>);}@@ -86,117 +110,125 @@ function KeywordList({ projectId }: { projectId: string }) {queryFn: () => listAiResearchKeywords({ data: { projectId } }),});return (- <div className="space-y-5 pt-1">- <div className="flex flex-col items-center gap-4 rounded-lg border bg-card px-4 py-10 text-center border-border">- <h1 className="text-2xl font-semibold tracking-tight">- Explore questions about your market- </h1>- <KeywordSearch projectId={projectId} />+ <div className="overflow-hidden rounded-lg border bg-card border-border">+ <div className="border-b p-4 border-border">+ <h2 className="font-medium">Relevant keywords</h2>+ <p className="text-sm text-muted-foreground">+ Select a keyword to see the prompts people ask AI about it.+ </p></div>- <div className="overflow-hidden rounded-lg border bg-card border-border">- <div className="border-b p-4 border-border">- <h2 className="font-medium">Relevant keywords</h2>- <p className="text-sm text-muted-foreground">- Select a keyword to see the prompts people ask AI about it.- </p>- </div>- {query.isPending ? (- <SkeletonTableRows rows={5} columns={1} className="p-4" />- ) : query.isError ? (- <AiQueryError- error={query.error}- retry={() => {- void query.refetch();- }}- />- ) : !query.data.keywords.length ? (- <p className="p-10 text-center text-sm text-muted-foreground">- Add topics to your tracker, or search a keyword above.- </p>- ) : (- <Table>- <TableHeader>- <TableRow>- <TableHead>Keyword</TableHead>- <TableHead className="w-10">- <span className="sr-only">Open</span>- </TableHead>+ {query.isPending ? (+ <SkeletonTableRows rows={5} columns={1} className="p-4" />+ ) : query.isError ? (+ <AiQueryError+ error={query.error}+ retry={() => {+ void query.refetch();+ }}+ />+ ) : !query.data.keywords.length ? (+ <p className="p-10 text-center text-sm text-muted-foreground">+ Add topics to your tracker, or search a keyword above.+ </p>+ ) : (+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>Keyword</TableHead>+ <TableHead className="w-10">+ <span className="sr-only">Open</span>+ </TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {query.data.keywords.map((keyword) => (+ // Any cell opens the keyword; the link keeps it keyboard reachable.+ <TableRow+ key={keyword}+ className="cursor-pointer"+ onClick={() =>+ void navigate({+ to: "/p/$projectId/ai-visibility/research",+ params: { projectId },+ search: { q: keyword },+ })+ }+ >+ <TableCell>+ <Link+ to="/p/$projectId/ai-visibility/research"+ params={{ projectId }}+ search={{ q: keyword }}+ className="font-medium hover:underline"+ // The row navigates too; this keeps new-tab clicks to one tab.+ onClick={(event) => event.stopPropagation()}+ >+ {keyword}+ </Link>+ </TableCell>+ <TableCell>+ <ChevronRight className="size-4 text-muted-foreground" />+ </TableCell></TableRow>- </TableHeader>- <TableBody>- {query.data.keywords.map((keyword) => (- // Any cell opens the keyword; the link keeps it keyboard reachable.- <TableRow- key={keyword}- className="cursor-pointer"- onClick={() =>- void navigate({- to: "/p/$projectId/ai-visibility/research",- params: { projectId },- search: { q: keyword },- })- }- >- <TableCell>- <Link- to="/p/$projectId/ai-visibility/research"- params={{ projectId }}- search={{ q: keyword }}- className="font-medium hover:underline"- // The row navigates too; this keeps new-tab clicks to one tab.- onClick={(event) => event.stopPropagation()}- >- {keyword}- </Link>- </TableCell>- <TableCell>- <ChevronRight className="size-4 text-muted-foreground" />- </TableCell>- </TableRow>- ))}- </TableBody>- </Table>- )}- </div>+ ))}+ </TableBody>+ </Table>+ )}</div>);}-function KeywordSearch({ projectId }: { projectId: string }) {+function KeywordSearch({+ projectId,+ keyword,+}: {+ projectId: string;+ keyword: string | undefined;+}) {const navigate = useNavigate();- const [draft, setDraft] = useState("");+ const [draft, setDraft] = useState(keyword ?? "");+ const [error, setError] = useState<string | null>(null);return (- <form- className="w-full max-w-xl text-left"+ <SearchCardonSubmit={(event) => {event.preventDefault();- if (!draft.trim()) return;+ if (!draft.trim()) {+ setError("Enter a keyword.");+ return;+ }void navigate({to: "/p/$projectId/ai-visibility/research",params: { projectId },search: { q: draft.trim() },});}}+ error={error}+ errorId="ai-keyword-research-error"+ secondRow={+ <p+ id="ai-keyword-research-cost"+ className="text-xs text-muted-foreground"+ >+ About $0.25 in credits per keyword.+ </p>+ }>- <div className="flex gap-2">- <Input- value={draft}- onChange={(event) => setDraft(event.target.value)}- placeholder="Enter a keyword"- aria-label="Keyword"- aria-describedby="ai-keyword-research-cost"- maxLength={100}- />- <Button type="submit" disabled={!draft.trim()}>- <Search /> Analyze- </Button>- </div>- <p- id="ai-keyword-research-cost"- className="mt-2 text-xs text-muted-foreground"- >- About $0.25 in credits per keyword.- </p>- </form>+ <SearchInput+ value={draft}+ onChange={(event) => {+ setDraft(event.target.value);+ setError(null);+ }}+ placeholder="Enter a keyword"+ aria-label="Keyword"+ aria-invalid={error ? true : undefined}+ aria-describedby={+ error+ ? "ai-keyword-research-error ai-keyword-research-cost"+ : "ai-keyword-research-cost"+ }+ maxLength={100}+ />+ </SearchCard>);}diff --git a/src/client/features/ai-visibility/PromptTrackingPage.tsx b/src/client/features/ai-visibility/PromptTrackingPage.tsxindex 7af0b9cf..0f2389a8 100644--- a/src/client/features/ai-visibility/PromptTrackingPage.tsx+++ b/src/client/features/ai-visibility/PromptTrackingPage.tsx@@ -170,7 +170,7 @@ function PromptTrackingContent({);return (- <div className="space-y-5 pt-1">+ <div className="space-y-4"><PageHeadertitle="Prompt Tracking"description="Track the prompts your customers use with AI. Inspect where your business is mentioned or cited."