Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Share one recent-searches list and show hover actions on focus and touch (EVE-283) (#710)
Carter Smith3c33015cf635
diff --git a/src/client/components/RecentSearches.tsx b/src/client/components/RecentSearches.tsxnew file mode 100644index 00000000..3216d50c--- /dev/null+++ b/src/client/components/RecentSearches.tsx@@ -0,0 +1,126 @@+import type { ComponentType, ReactNode } from "react";+import { ArrowLeft, Clock, History, X } from "lucide-react";++// Props for the caller's clickable element. Spread them onto a <Link> so+// cmd+click and "open in new tab" work, or onto a <button> for in-page state.+type ClickableProps = { className: string; children: ReactNode };++type Props<TItem extends { timestamp: number }> = {+ items: TItem[];+ loaded: boolean;+ onRemove: (timestamp: number) => void;+ renderLink: (item: TItem, props: ClickableProps) => ReactNode;+ getTitle: (item: TItem) => ReactNode;+ getSubtitle: (item: TItem) => ReactNode;+ emptyIcon: ComponentType<{ className?: string }>;+ emptyTitle: string;+ emptyDescription?: string;+};++export function RecentSearches<TItem extends { timestamp: number }>({+ items,+ loaded,+ onRemove,+ renderLink,+ getTitle,+ getSubtitle,+ emptyIcon: EmptyIcon,+ emptyTitle,+ emptyDescription,+}: Props<TItem>) {+ if (!loaded) {+ return null;+ }++ if (items.length === 0) {+ return (+ <section className="rounded-2xl border border-dashed border-base-300 bg-base-100/70 p-6 text-center text-base-content/55 space-y-2">+ <EmptyIcon className="size-9 mx-auto opacity-35" />+ <p className="text-base font-medium text-base-content/80">+ {emptyTitle}+ </p>+ {emptyDescription ? (+ <p className="text-sm max-w-md mx-auto">{emptyDescription}</p>+ ) : null}+ </section>+ );+ }++ return (+ <section className="rounded-2xl border border-base-300 bg-base-100 p-5 md:p-6">+ <div className="flex items-center gap-2 mb-4">+ <History className="size-4 text-base-content/45" />+ <span className="text-sm text-base-content/60">+ {items.length} recent search{items.length !== 1 ? "es" : ""}+ </span>+ </div>++ <div className="grid gap-2">+ {items.map((item) => (+ <div+ key={item.timestamp}+ className="group flex min-w-0 items-center gap-2 rounded-lg border border-base-300 bg-base-100 p-2"+ >+ {renderLink(item, {+ className:+ "flex min-w-0 flex-1 items-center gap-3 rounded-md px-1 py-1 text-left transition-colors hover:bg-base-200",+ children: (+ <>+ <Clock className="size-4 text-base-content/40 shrink-0" />+ <div className="min-w-0">+ <p className="font-medium text-base-content truncate">+ {getTitle(item)}+ </p>+ {getSubtitle(item) ? (+ <p className="text-sm text-base-content/60 truncate">+ {getSubtitle(item)}+ </p>+ ) : null}+ </div>+ </>+ ),+ })}+ <div className="flex items-center gap-2 shrink-0">+ <span className="text-xs text-base-content/40">+ {new Date(item.timestamp).toLocaleDateString(undefined, {+ month: "short",+ day: "numeric",+ })}+ </span>+ <button+ type="button"+ className="btn btn-ghost btn-xs p-1 reveal-on-hover"+ onClick={() => onRemove(item.timestamp)}+ aria-label="Remove from recent searches"+ >+ <X className="size-3" />+ </button>+ </div>+ </div>+ ))}+ </div>+ </section>+ );+}++// The "Recent searches" link that returns a research page to its list.+export function RecentSearchesBackLink({+ render,+}: {+ render: (props: ClickableProps) => ReactNode;+}) {+ return (+ <div>+ {render({+ className:+ "btn btn-ghost btn-sm gap-2 px-0 text-base-content/70 hover:bg-transparent",+ children: (+ <>+ <ArrowLeft className="size-4" />+ Recent searches+ </>+ ),+ })}+ </div>+ );+}diff --git a/src/client/components/chat/ChatMessage.tsx b/src/client/components/chat/ChatMessage.tsxindex 6407382f..1afd36fb 100644--- a/src/client/components/chat/ChatMessage.tsx+++ b/src/client/components/chat/ChatMessage.tsx@@ -92,7 +92,7 @@ function MessageActions({}) {return (<div- className={`flex gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 ${+ className={`flex gap-0.5 reveal-on-hover ${message.role === "user" ? "justify-end" : ""}`}>diff --git a/src/client/features/ai-search/BrandLookupPage.tsx b/src/client/features/ai-search/BrandLookupPage.tsxindex 3540dfe7..9e9e0b59 100644--- a/src/client/features/ai-search/BrandLookupPage.tsx+++ b/src/client/features/ai-search/BrandLookupPage.tsx@@ -3,9 +3,9 @@ import { useQuery } from "@tanstack/react-query";import { Link } from "@tanstack/react-router";import {AlertCircle,- ArrowLeft,BarChart3,Quote,+ Sparkles,TrendingUp,} from "lucide-react";import { lookupBrand } from "@/serverFunctions/ai-search";@@ -16,7 +16,10 @@ import {import { getStandardErrorMessage } from "@/client/lib/error-messages";import { BrandLookupResults } from "@/client/features/ai-search/components/BrandLookupResults";import { BrandLookupSearchCard } from "@/client/features/ai-search/components/BrandLookupSearchCard";-import { BrandLookupHistorySection } from "@/client/features/ai-search/components/BrandLookupHistorySection";+import {+ RecentSearches,+ RecentSearchesBackLink,+} from "@/client/components/RecentSearches";import { AiSearchLoadingState } from "@/client/features/ai-search/components/AiSearchLoadingState";import { AiSearchPaidPlanGate } from "@/client/features/ai-search/components/AiSearchPaidPlanGate";import { useBrandLookupSearchHistory } from "@/client/hooks/useBrandLookupSearchHistory";@@ -27,6 +30,7 @@ import {import { detectTarget } from "@/shared/targetDetection";import {parseResearchTarget,+ RESEARCH_SCOPE_LABELS,toScopeSearchParam,type ResearchScope,} from "@/shared/researchScope";@@ -307,27 +311,61 @@ function BrandLookupPageInner({<AiSearchLoadingState />) : resultData ? (<>- <div>+ <RecentSearchesBackLink+ render={(props) => (+ <Link+ from="/p/$projectId/brand-lookup"+ to="/p/$projectId/brand-lookup"+ params={{ projectId }}+ search={{ q: undefined, c: undefined, scope: undefined }}+ replace+ {...props}+ />+ )}+ />+ <BrandLookupResults result={resultData} projectId={projectId} />+ </>+ ) : !errorMessage ? (+ <RecentSearches+ items={history}+ loaded={historyLoaded}+ onRemove={removeHistoryItem}+ emptyIcon={Sparkles}+ emptyTitle="Search a brand name or domain to see how AI cites it"+ getTitle={(item) => (+ <>+ {item.query}+ {/* Only non-default scopes are stored, so this badge always+ adds information the query string doesn't carry. */}+ {item.scope ? (+ <span className="badge badge-ghost badge-sm ml-2">+ {RESEARCH_SCOPE_LABELS[item.scope]}+ </span>+ ) : null}+ </>+ )}+ getSubtitle={(item) =>+ item.competitors.length > 0+ ? `vs ${item.competitors.join(", ")}`+ : null+ }+ renderLink={(item, props) => (<Linkfrom="/p/$projectId/brand-lookup"to="/p/$projectId/brand-lookup"params={{ projectId }}- search={{ q: undefined, c: undefined, scope: undefined }}+ search={{+ q: item.query,+ c:+ item.competitors.length > 0+ ? item.competitors.join(",")+ : undefined,+ scope: item.scope,+ }}replace- className="btn btn-ghost btn-sm gap-2 px-0 text-base-content/70 hover:bg-transparent"- >- <ArrowLeft className="size-4" />- Recent searches- </Link>- </div>- <BrandLookupResults result={resultData} projectId={projectId} />- </>- ) : !errorMessage ? (- <BrandLookupHistorySection- projectId={projectId}- history={history}- historyLoaded={historyLoaded}- onRemoveHistoryItem={removeHistoryItem}+ {...props}+ />+ )}/>) : null}</>diff --git a/src/client/features/ai-search/PromptExplorerPage.tsx b/src/client/features/ai-search/PromptExplorerPage.tsxindex 13368fb4..75a4aa50 100644--- a/src/client/features/ai-search/PromptExplorerPage.tsx+++ b/src/client/features/ai-search/PromptExplorerPage.tsx@@ -4,8 +4,8 @@ import { Link } from "@tanstack/react-router";import { identity, sortBy } from "remeda";import {AlertCircle,- ArrowLeft,Columns3,+ MessageSquare,SearchCheck,Sparkles,} from "lucide-react";@@ -18,8 +18,12 @@ import { getStandardErrorMessage } from "@/client/lib/error-messages";import { PromptExplorerForm } from "@/client/features/ai-search/components/PromptExplorerForm";import { PromptExplorerResults } from "@/client/features/ai-search/components/PromptExplorerResults";import { PromptExplorerLoadingState } from "@/client/features/ai-search/components/PromptExplorerLoadingState";-import { PromptExplorerHistorySection } from "@/client/features/ai-search/components/PromptExplorerHistorySection";+import {+ RecentSearches,+ RecentSearchesBackLink,+} from "@/client/components/RecentSearches";import { AiSearchPaidPlanGate } from "@/client/features/ai-search/components/AiSearchPaidPlanGate";+import { formatModelLabel } from "@/client/features/ai-search/platformLabels";import { usePromptExplorerSearchHistory } from "@/client/hooks/usePromptExplorerSearchHistory";import {PROMPT_EXPLORER_MAX_PROMPT_LENGTH,@@ -240,27 +244,50 @@ function PromptExplorerPageInner({<PromptExplorerLoadingState modelCount={form.models.length} />) : resultData ? (<>- <div>+ <RecentSearchesBackLink+ render={(props) => (+ <Link+ from="/p/$projectId/prompt-explorer"+ to="/p/$projectId/prompt-explorer"+ params={{ projectId }}+ search={{}}+ replace+ {...props}+ />+ )}+ />+ <PromptExplorerResults result={resultData} />+ </>+ ) : !errorMessage ? (+ <RecentSearches+ items={history}+ loaded={historyLoaded}+ onRemove={removeHistoryItem}+ emptyIcon={MessageSquare}+ emptyTitle="Enter a prompt to compare model answers"+ getTitle={(item) => item.prompt}+ getSubtitle={(item) =>+ item.models.map(formatModelLabel).join(", ")+ }+ renderLink={(item, props) => (<Linkfrom="/p/$projectId/prompt-explorer"to="/p/$projectId/prompt-explorer"params={{ projectId }}- search={{}}+ search={{+ q: item.prompt,+ models: item.models,+ web: item.webSearch ? undefined : false,+ cc:+ item.webSearchCountryCode === "US"+ ? undefined+ : item.webSearchCountryCode,+ hb: item.highlightBrand || undefined,+ }}replace- className="btn btn-ghost btn-sm gap-2 px-0 text-base-content/70 hover:bg-transparent"- >- <ArrowLeft className="size-4" />- Recent searches- </Link>- </div>- <PromptExplorerResults result={resultData} />- </>- ) : !errorMessage ? (- <PromptExplorerHistorySection- projectId={projectId}- history={history}- historyLoaded={historyLoaded}- onRemoveHistoryItem={removeHistoryItem}+ {...props}+ />+ )}/>) : null}</>diff --git a/src/client/features/ai-search/components/BrandLookupCitationTables.tsx b/src/client/features/ai-search/components/BrandLookupCitationTables.tsxindex 32161676..db86075e 100644--- a/src/client/features/ai-search/components/BrandLookupCitationTables.tsx+++ b/src/client/features/ai-search/components/BrandLookupCitationTables.tsx@@ -316,7 +316,7 @@ export function buildTopQueriesColumns({meta: { cellClassName: "w-px whitespace-nowrap text-right align-top" },cell: ({ row }) => (<span- className="tooltip tooltip-left opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100"+ className="tooltip tooltip-left reveal-on-hover"data-tip="Run this prompt in Prompt Explorer"><Linkdiff --git a/src/client/features/ai-search/components/BrandLookupHistorySection.tsx b/src/client/features/ai-search/components/BrandLookupHistorySection.tsxdeleted file mode 100644index aead7191..00000000--- a/src/client/features/ai-search/components/BrandLookupHistorySection.tsx+++ /dev/null@@ -1,64 +0,0 @@-import { Link } from "@tanstack/react-router";-import { Sparkles } from "lucide-react";-import {- HISTORY_ITEM_LINK_CLASS,- SearchHistorySection,-} from "@/client/features/ai-search/components/SearchHistorySection";-import type { BrandLookupSearchHistoryItem } from "@/client/hooks/useBrandLookupSearchHistory";-import { RESEARCH_SCOPE_LABELS } from "@/shared/researchScope";--type Props = {- projectId: string;- history: BrandLookupSearchHistoryItem[];- historyLoaded: boolean;- onRemoveHistoryItem: (timestamp: number) => void;-};--export function BrandLookupHistorySection({ projectId, ...props }: Props) {- return (- <SearchHistorySection- {...props}- emptyIcon={Sparkles}- emptyMessage="Search a brand name or domain to see how AI cites it"- noun="lookup"- renderItemLink={(item, content) => (- <Link- from="/p/$projectId/brand-lookup"- to="/p/$projectId/brand-lookup"- params={{ projectId }}- search={{- q: item.query,- c:- item.competitors.length > 0- ? item.competitors.join(",")- : undefined,- scope: item.scope,- }}- replace- className={HISTORY_ITEM_LINK_CLASS}- >- {content}- </Link>- )}- renderItem={(item) => (- <div className="min-w-0">- <p className="flex items-center gap-2 truncate font-medium text-base-content">- {item.query}- {/* Only non-default scopes are stored, so this badge always adds- information the query string doesn't already carry. */}- {item.scope ? (- <span className="badge badge-ghost badge-sm shrink-0">- {RESEARCH_SCOPE_LABELS[item.scope]}- </span>- ) : null}- </p>- {item.competitors.length > 0 ? (- <p className="truncate text-xs text-base-content/50">- vs {item.competitors.join(", ")}- </p>- ) : null}- </div>- )}- />- );-}diff --git a/src/client/features/ai-search/components/PromptExplorerHistorySection.tsx b/src/client/features/ai-search/components/PromptExplorerHistorySection.tsxdeleted file mode 100644index 527ba648..00000000--- a/src/client/features/ai-search/components/PromptExplorerHistorySection.tsx+++ /dev/null@@ -1,57 +0,0 @@-import { Link } from "@tanstack/react-router";-import { MessageSquare } from "lucide-react";-import {- HISTORY_ITEM_LINK_CLASS,- SearchHistorySection,-} from "@/client/features/ai-search/components/SearchHistorySection";-import { formatModelLabel } from "@/client/features/ai-search/platformLabels";-import type { PromptExplorerSearchHistoryItem } from "@/client/hooks/usePromptExplorerSearchHistory";--type Props = {- projectId: string;- history: PromptExplorerSearchHistoryItem[];- historyLoaded: boolean;- onRemoveHistoryItem: (timestamp: number) => void;-};--export function PromptExplorerHistorySection({ projectId, ...props }: Props) {- return (- <SearchHistorySection- {...props}- emptyIcon={MessageSquare}- emptyMessage="Enter a prompt to compare model answers"- noun="prompt"- renderItemLink={(item, content) => (- <Link- from="/p/$projectId/prompt-explorer"- to="/p/$projectId/prompt-explorer"- params={{ projectId }}- search={{- q: item.prompt,- models: item.models,- web: item.webSearch ? undefined : false,- cc:- item.webSearchCountryCode === "US"- ? undefined- : item.webSearchCountryCode,- hb: item.highlightBrand || undefined,- }}- replace- className={HISTORY_ITEM_LINK_CLASS}- >- {content}- </Link>- )}- renderItem={(item) => (- <>- <p className="font-medium text-base-content truncate">- {item.prompt}- </p>- <p className="text-sm text-base-content/60 truncate">- {item.models.map(formatModelLabel).join(", ")}- </p>- </>- )}- />- );-}diff --git a/src/client/features/ai-search/components/SearchHistorySection.tsx b/src/client/features/ai-search/components/SearchHistorySection.tsxdeleted file mode 100644index 553024c3..00000000--- a/src/client/features/ai-search/components/SearchHistorySection.tsx+++ /dev/null@@ -1,101 +0,0 @@-import type { ComponentType, ReactNode } from "react";-import { Clock, History, X } from "lucide-react";--type Props<TItem extends { timestamp: number }> = {- history: TItem[];- historyLoaded: boolean;- onRemoveHistoryItem: (timestamp: number) => void;- /**- * Renders the clickable area of a history row. The caller is responsible- * for wrapping `content` in a <Link> (or other clickable element) so that- * cmd+click and right-click → "open in new tab" behave natively.- */- renderItemLink: (item: TItem, content: ReactNode) => ReactNode;- /** Icon component rendered in the empty state (e.g. Sparkles, MessageSquare). */- emptyIcon: ComponentType<{ className?: string }>;- /** Empty-state headline copy. */- emptyMessage: string;- /**- * Label noun used in the "{n} recent {noun}(s)" header (e.g. "lookup",- * "prompt"). Pluralization is handled by the component.- */- noun: string;- /** Item body — primary (and optional secondary) text shown in each row. */- renderItem: (item: TItem) => ReactNode;-};--export function SearchHistorySection<TItem extends { timestamp: number }>({- history,- historyLoaded,- onRemoveHistoryItem,- renderItemLink,- emptyIcon: EmptyIcon,- emptyMessage,- noun,- renderItem,-}: Props<TItem>) {- if (!historyLoaded) {- return null;- }-- if (history.length === 0) {- return (- <section className="rounded-2xl border border-dashed border-base-300 bg-base-100/70 p-6 text-center text-base-content/55 space-y-2">- <EmptyIcon className="size-9 mx-auto opacity-35" />- <p className="text-base font-medium text-base-content/80">- {emptyMessage}- </p>- </section>- );- }-- return (- <section className="rounded-2xl border border-base-300 bg-base-100 p-5 md:p-6">- <div className="flex items-center justify-between mb-4">- <div className="flex items-center gap-2">- <History className="size-4 text-base-content/45" />- <span className="text-sm text-base-content/60">- {history.length} recent {noun}- {history.length !== 1 ? "s" : ""}- </span>- </div>- </div>-- <div className="grid gap-2">- {history.map((item) => (- <div- key={item.timestamp}- className="group flex items-center gap-2 rounded-lg border border-base-300 bg-base-100 p-2"- >- {renderItemLink(- item,- <>- <Clock className="size-4 text-base-content/40 shrink-0" />- <div className="min-w-0">{renderItem(item)}</div>- </>,- )}- <div className="flex items-center gap-2 shrink-0">- <span className="text-xs text-base-content/40">- {new Date(item.timestamp).toLocaleDateString(undefined, {- month: "short",- day: "numeric",- })}- </span>- <button- type="button"- className="btn btn-ghost btn-xs opacity-0 group-hover:opacity-100 p-1"- onClick={() => onRemoveHistoryItem(item.timestamp)}- aria-label="Remove from history"- >- <X className="size-3" />- </button>- </div>- </div>- ))}- </div>- </section>- );-}--export const HISTORY_ITEM_LINK_CLASS =- "flex min-w-0 flex-1 items-center gap-3 rounded-md px-1 py-1 text-left transition-colors hover:bg-base-200";diff --git a/src/client/features/audit/launch/AuditHistorySection.tsx b/src/client/features/audit/launch/AuditHistorySection.tsxindex 3d4a8d3e..1f24b06d 100644--- a/src/client/features/audit/launch/AuditHistorySection.tsx+++ b/src/client/features/audit/launch/AuditHistorySection.tsx@@ -87,7 +87,7 @@ function HistoryActions({onDelete: (auditId: string) => void;}) {return (- <div className="flex items-center justify-end gap-2 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100">+ <div className="flex items-center justify-end gap-2 reveal-on-hover"><Linkto="/p/$projectId/audit"params={{ projectId }}diff --git a/src/client/features/backlinks/BacklinksHistorySection.tsx b/src/client/features/backlinks/BacklinksHistorySection.tsxdeleted file mode 100644index dc21fff6..00000000--- a/src/client/features/backlinks/BacklinksHistorySection.tsx+++ /dev/null@@ -1,97 +0,0 @@-import { Link } from "@tanstack/react-router";-import { Clock, History, Link2, X } from "lucide-react";-import type { BacklinksSearchHistoryItem } from "@/client/hooks/useBacklinksSearchHistory";-import { RESEARCH_SCOPE_LABELS } from "@/shared/researchScope";-import { toScopeSearchParam } from "@/shared/researchScope";--type Props = {- projectId: string;- history: BacklinksSearchHistoryItem[];- historyLoaded: boolean;- onRemoveHistoryItem: (timestamp: number) => void;-};--export function BacklinksHistorySection({- projectId,- history,- historyLoaded,- onRemoveHistoryItem,-}: Props) {- if (!historyLoaded) {- return null;- }-- if (history.length === 0) {- return (- <section className="rounded-2xl border border-dashed border-base-300 bg-base-100/70 p-6 text-center text-base-content/55 space-y-2">- <Link2 className="size-9 mx-auto opacity-35" />- <p className="text-base font-medium text-base-content/80">- Enter a domain or URL to get started- </p>- </section>- );- }-- return (- <section className="rounded-2xl border border-base-300 bg-base-100 p-5 md:p-6">- <div className="flex items-center justify-between mb-4">- <div className="flex items-center gap-2">- <History className="size-4 text-base-content/45" />- <span className="text-sm text-base-content/60">- {history.length} recent search{history.length !== 1 ? "es" : ""}- </span>- </div>- </div>-- <div className="grid gap-2">- {history.map((item) => (- <div- key={item.timestamp}- className="group flex items-center gap-2 rounded-lg border border-base-300 bg-base-100 p-2"- >- <Link- to="/p/$projectId/backlinks"- params={{ projectId }}- search={(prev) => ({- ...prev,- target: item.target,- scope: toScopeSearchParam(item.target, item.scope),- tab: undefined,- page: undefined,- sort: undefined,- order: undefined,- })}- replace- className="flex min-w-0 flex-1 items-center gap-3 rounded-md px-1 py-1 text-left transition-colors hover:bg-base-200"- >- <Clock className="size-4 text-base-content/40 shrink-0" />- <div className="min-w-0">- <p className="font-medium text-base-content truncate">- {item.target}- </p>- <p className="text-sm text-base-content/60 truncate">- {RESEARCH_SCOPE_LABELS[item.scope]}- </p>- </div>- </Link>- <div className="flex items-center gap-2 shrink-0">- <span className="text-xs text-base-content/40">- {new Date(item.timestamp).toLocaleDateString(undefined, {- month: "short",- day: "numeric",- })}- </span>- <button- type="button"- className="btn btn-ghost btn-xs opacity-0 group-hover:opacity-100 p-1"- onClick={() => onRemoveHistoryItem(item.timestamp)}- >- <X className="size-3" />- </button>- </div>- </div>- ))}- </div>- </section>- );-}diff --git a/src/client/features/backlinks/BacklinksOverviewPanels.tsx b/src/client/features/backlinks/BacklinksOverviewPanels.tsxindex e6f4a031..cfb7b352 100644--- a/src/client/features/backlinks/BacklinksOverviewPanels.tsx+++ b/src/client/features/backlinks/BacklinksOverviewPanels.tsx@@ -1,5 +1,5 @@import { Link } from "@tanstack/react-router";-import { ArrowLeft } from "lucide-react";+import { RecentSearchesBackLink } from "@/client/components/RecentSearches";import { RESEARCH_SCOPE_LABELS } from "@/shared/researchScope";import { HeaderHelpLabel } from "@/client/components/table/HeaderHelpLabel";import {@@ -22,26 +22,25 @@ export function BacklinksOverviewPanels({}) {return (<>- <div>- <Link- to="/p/$projectId/backlinks"- params={{ projectId }}- search={{- target: undefined,- scope: undefined,- tab: undefined,- page: undefined,- size: undefined,- sort: undefined,- order: undefined,- }}- replace- className="btn btn-ghost btn-sm gap-2 px-0 text-base-content/70 hover:bg-transparent"- >- <ArrowLeft className="size-4" />- Recent searches- </Link>- </div>+ <RecentSearchesBackLink+ render={(props) => (+ <Link+ to="/p/$projectId/backlinks"+ params={{ projectId }}+ search={{+ target: undefined,+ scope: undefined,+ tab: undefined,+ page: undefined,+ size: undefined,+ sort: undefined,+ order: undefined,+ }}+ replace+ {...props}+ />+ )}+ /><div className="flex flex-wrap items-center gap-2 text-sm text-base-content/65"><span className="badge badge-outline">{RESEARCH_SCOPE_LABELS[data.scope]}diff --git a/src/client/features/backlinks/BacklinksPageContent.tsx b/src/client/features/backlinks/BacklinksPageContent.tsxindex 50845b48..0a4dba96 100644--- a/src/client/features/backlinks/BacklinksPageContent.tsx+++ b/src/client/features/backlinks/BacklinksPageContent.tsx@@ -1,4 +1,6 @@import { useMemo } from "react";+import { Link } from "@tanstack/react-router";+import { Link2 } from "lucide-react";import type { OnChangeFn, SortingState } from "@tanstack/react-table";import { BacklinksOverviewPanels } from "./BacklinksOverviewPanels";import { BacklinksResultsCard } from "./BacklinksPageSections";@@ -6,7 +8,6 @@ import {BacklinksErrorState,BacklinksLoadingState,} from "./BacklinksPageStates";-import { BacklinksHistorySection } from "./BacklinksHistorySection";import type { BacklinksSearchHistoryItem } from "@/client/hooks/useBacklinksSearchHistory";import type {BacklinksSearchState,@@ -17,6 +18,11 @@ import type { BacklinksDomainExpansion } from "./useBacklinksDomainExpansion";import type { BacklinksFiltersState } from "./useBacklinksFilters";import type { BacklinksPageData } from "./useBacklinksPageData";import { SearchTabStrip } from "@/client/features/search-tabs/SearchTabStrip";+import { RecentSearches } from "@/client/components/RecentSearches";+import {+ RESEARCH_SCOPE_LABELS,+ toScopeSearchParam,+} from "@/shared/researchScope";import type { useSearchTabNavigation } from "@/client/features/search-tabs/useSearchTabNavigation";type BacklinksBodyProps = {@@ -86,11 +92,31 @@ export function BacklinksBody({if (!searchState.target) {return (- <BacklinksHistorySection- projectId={projectId}- history={history}- historyLoaded={historyLoaded}- onRemoveHistoryItem={onRemoveHistoryItem}+ <RecentSearches+ items={history}+ loaded={historyLoaded}+ onRemove={onRemoveHistoryItem}+ emptyIcon={Link2}+ emptyTitle="Enter a domain or URL to get started"+ getTitle={(item) => item.target}+ getSubtitle={(item) => RESEARCH_SCOPE_LABELS[item.scope]}+ renderLink={(item, props) => (+ <Link+ to="/p/$projectId/backlinks"+ params={{ projectId }}+ search={(prev) => ({+ ...prev,+ target: item.target,+ scope: toScopeSearchParam(item.target, item.scope),+ tab: undefined,+ page: undefined,+ sort: undefined,+ order: undefined,+ })}+ replace+ {...props}+ />+ )}/>);}diff --git a/src/client/features/domain/DomainOverviewPage.tsx b/src/client/features/domain/DomainOverviewPage.tsxindex 78a2bf0a..070d082b 100644--- a/src/client/features/domain/DomainOverviewPage.tsx+++ b/src/client/features/domain/DomainOverviewPage.tsx@@ -1,7 +1,7 @@/* eslint-disable max-lines, max-lines-per-function -- Domain Overview keeps page-only orchestration colocated to avoid fake indirection. */import { useCallback, useEffect, useMemo, useRef, type FormEvent } from "react";import { useForm, useStore } from "@tanstack/react-form";-import { ArrowLeft } from "lucide-react";+import { Globe } from "lucide-react";import { toast } from "sonner";import {DEFAULT_DOMAIN_KEYWORDS_PAGE_SIZE,@@ -19,7 +19,10 @@ import {} from "@/client/features/domain/domainSearchValidation";import { useDomainOverviewQuery } from "@/client/features/domain/hooks/useDomainOverviewQuery";import { DomainOverviewLoadingState } from "@/client/features/domain/components/DomainOverviewLoadingState";-import { DomainHistorySection } from "@/client/features/domain/components/DomainHistorySection";+import {+ RecentSearches,+ RecentSearchesBackLink,+} from "@/client/components/RecentSearches";import { DomainSearchCard } from "@/client/features/domain/components/DomainSearchCard";import { KeywordsTab } from "@/client/features/domain/components/KeywordsTab";import { PagesTab } from "@/client/features/domain/components/PagesTab";@@ -526,19 +529,18 @@ export function DomainOverviewPage({const tabControls = routeState.domain ? (<div className="flex flex-col gap-2">- <div>- <button- type="button"- className="btn btn-ghost btn-sm gap-2 px-0 text-base-content/70 hover:bg-transparent"- onClick={() => {- searchTabs.setActiveTab(null);- onShowRecentSearches();- }}- >- <ArrowLeft className="size-4" />- Recent searches- </button>- </div>+ <RecentSearchesBackLink+ render={(props) => (+ <button+ type="button"+ onClick={() => {+ searchTabs.setActiveTab(null);+ onShowRecentSearches();+ }}+ {...props}+ />+ )}+ /><SearchTabStripprojectId={projectId}activeTabId={searchTabs.activeTabId}@@ -581,12 +583,22 @@ export function DomainOverviewPage({<DomainOverviewLoadingState /></>) : state.overview === null ? (- <div className="space-y-4 pt-1">- <DomainHistorySection- history={state.history}- historyLoaded={state.historyLoaded}- onRemoveHistoryItem={state.removeHistoryItem}- onSelectHistoryItem={state.handleHistorySelect}+ <div className="pt-1">+ <RecentSearches+ items={state.history}+ loaded={state.historyLoaded}+ onRemove={state.removeHistoryItem}+ emptyIcon={Globe}+ emptyTitle="Enter a domain to get started"+ getTitle={(item) => item.domain}+ getSubtitle={(item) => RESEARCH_SCOPE_LABELS[item.scope]}+ renderLink={(item, props) => (+ <button+ type="button"+ onClick={() => state.handleHistorySelect(item)}+ {...props}+ />+ )}/></div>) : (diff --git a/src/client/features/domain/components/DomainHistorySection.tsx b/src/client/features/domain/components/DomainHistorySection.tsxdeleted file mode 100644index 0592af71..00000000--- a/src/client/features/domain/components/DomainHistorySection.tsx+++ /dev/null@@ -1,86 +0,0 @@-import { Clock, History, X } from "lucide-react";-import { Globe } from "lucide-react";-import type { DomainHistoryItem } from "@/client/features/domain/types";-import { RESEARCH_SCOPE_LABELS } from "@/shared/researchScope";--type Props = {- history: DomainHistoryItem[];- historyLoaded: boolean;- onRemoveHistoryItem: (timestamp: number) => void;- onSelectHistoryItem: (item: DomainHistoryItem) => void;-};--export function DomainHistorySection({- history,- historyLoaded,- onRemoveHistoryItem,- onSelectHistoryItem,-}: Props) {- if (!historyLoaded) {- return null;- }-- if (history.length === 0) {- return (- <section className="rounded-2xl border border-dashed border-base-300 bg-base-100/70 p-6 text-center text-base-content/55 space-y-2">- <Globe className="size-9 mx-auto opacity-35" />- <p className="text-base font-medium text-base-content/80">- Enter a domain to get started- </p>- </section>- );- }-- return (- <section className="rounded-2xl border border-base-300 bg-base-100 p-5 md:p-6">- <div className="flex items-center justify-between mb-4">- <div className="flex items-center gap-2">- <History className="size-4 text-base-content/45" />- <span className="text-sm text-base-content/60">- {history.length} recent search{history.length !== 1 ? "es" : ""}- </span>- </div>- </div>-- <div className="grid gap-2">- {history.map((item) => (- <div- key={item.timestamp}- className="group flex items-center gap-2 rounded-lg border border-base-300 bg-base-100 p-2"- >- <button- type="button"- className="flex min-w-0 flex-1 items-center gap-3 rounded-md px-1 py-1 text-left transition-colors hover:bg-base-200"- onClick={() => onSelectHistoryItem(item)}- >- <Clock className="size-4 text-base-content/40 shrink-0" />- <div className="min-w-0">- <p className="font-medium text-base-content truncate">- {item.domain}- </p>- <p className="text-sm text-base-content/60 truncate">- {RESEARCH_SCOPE_LABELS[item.scope]}- </p>- </div>- </button>- <div className="flex items-center gap-2 shrink-0">- <span className="text-xs text-base-content/40">- {new Date(item.timestamp).toLocaleDateString(undefined, {- month: "short",- day: "numeric",- })}- </span>- <button- type="button"- className="btn btn-ghost btn-xs opacity-0 group-hover:opacity-100 p-1"- onClick={() => onRemoveHistoryItem(item.timestamp)}- >- <X className="size-3" />- </button>- </div>- </div>- ))}- </div>- </section>- );-}diff --git a/src/client/features/domain/types.ts b/src/client/features/domain/types.tsindex cddebf74..1e8a0855 100644--- a/src/client/features/domain/types.ts+++ b/src/client/features/domain/types.ts@@ -67,13 +67,3 @@ export type DomainControlsValues = {export type DomainSortMode = DomainControlsValues["sort"];export type SortOrder = "asc" | "desc";export type DomainActiveTab = "keywords" | "pages";--export type DomainHistoryItem = {- timestamp: number;- domain: string;- scope: ResearchScope;- sort: DomainSortMode;- tab: DomainActiveTab;- search?: string;- locationCode?: number;-};diff --git a/src/client/features/keywords/page/KeywordResearchEmptyState.tsx b/src/client/features/keywords/page/KeywordResearchEmptyState.tsxindex 08db176c..d849095e 100644--- a/src/client/features/keywords/page/KeywordResearchEmptyState.tsx+++ b/src/client/features/keywords/page/KeywordResearchEmptyState.tsx@@ -1,5 +1,6 @@import { Link } from "@tanstack/react-router";-import { Clock, Globe, History, Search, X } from "lucide-react";+import { Globe, Search } from "lucide-react";+import { RecentSearches } from "@/client/components/RecentSearches";import { LOCATIONS } from "@/client/features/keywords/utils";import type { KeywordResearchControllerState } from "./types";@@ -56,85 +57,33 @@ function SearchHistoryState({controller: KeywordResearchControllerState;projectId: string;}) {- const { history, historyLoaded, removeHistoryItem } = controller;-- if (!historyLoaded) {- return null;- }-return (- <div className="space-y-4 pt-1">- {history.length > 0 ? (- <section className="rounded-2xl border border-base-300 bg-base-100 p-5 md:p-6">- <div className="flex items-center justify-between mb-4">- <div className="flex items-center gap-2">- <History className="size-4 text-base-content/45" />- <span className="text-sm text-base-content/60">- {history.length} recent search- {history.length !== 1 ? "es" : ""}- </span>- </div>- </div>- <div className="grid gap-2">- {history.map((item) => (- <div- key={item.timestamp}- className="group flex items-center gap-2 rounded-lg border border-base-300 bg-base-100 p-2"- >- <Link- from="/p/$projectId/keywords"- to="/p/$projectId/keywords"- params={{ projectId }}- search={{- q: item.keyword,- loc: item.locationCode,- locName: item.localLocationName,- grp: controller.preferredGroupKeywords ? true : undefined,- }}- replace- className="flex min-w-0 flex-1 items-center gap-3 rounded-md px-1 py-1 text-left transition-colors hover:bg-base-200"- >- <Clock className="size-4 shrink-0 text-base-content/40" />- <div className="min-w-0">- <p className="truncate font-medium text-base-content">- {item.keyword}- </p>- <p className="truncate text-sm text-base-content/60">- {item.locationName}- </p>- </div>- </Link>- <div className="flex shrink-0 items-center gap-2">- <span className="text-xs text-base-content/40">- {new Date(item.timestamp).toLocaleDateString(undefined, {- month: "short",- day: "numeric",- })}- </span>- <button- type="button"- className="btn btn-ghost btn-xs opacity-0 group-hover:opacity-100 p-1"- onClick={() => removeHistoryItem(item.timestamp)}- >- <X className="size-3" />- </button>- </div>- </div>- ))}- </div>- </section>- ) : (- <section className="rounded-2xl border border-dashed border-base-300 bg-base-100/70 p-6 text-center text-base-content/50 space-y-3">- <Search className="size-10 mx-auto opacity-40" />- <p className="text-lg font-medium text-base-content/80">- Enter a keyword to get started- </p>- <p className="text-sm max-w-md mx-auto">- Search for any keyword to see volume, difficulty, CPC, and related- keyword ideas.- </p>- </section>- )}+ <div className="pt-1">+ <RecentSearches+ items={controller.history}+ loaded={controller.historyLoaded}+ onRemove={controller.removeHistoryItem}+ emptyIcon={Search}+ emptyTitle="Enter a keyword to get started"+ emptyDescription="Search for any keyword to see volume, difficulty, CPC, and related keyword ideas."+ getTitle={(item) => item.keyword}+ getSubtitle={(item) => item.locationName}+ renderLink={(item, props) => (+ <Link+ from="/p/$projectId/keywords"+ to="/p/$projectId/keywords"+ params={{ projectId }}+ search={{+ q: item.keyword,+ loc: item.locationCode,+ locName: item.localLocationName,+ grp: controller.preferredGroupKeywords ? true : undefined,+ }}+ replace+ {...props}+ />+ )}+ /></div>);}diff --git a/src/client/features/keywords/page/KeywordResearchPage.tsx b/src/client/features/keywords/page/KeywordResearchPage.tsxindex 51e088ec..0721bd21 100644--- a/src/client/features/keywords/page/KeywordResearchPage.tsx+++ b/src/client/features/keywords/page/KeywordResearchPage.tsx@@ -1,6 +1,7 @@import { Link } from "@tanstack/react-router";import { useCallback, useMemo } from "react";-import { AlertCircle, ArrowLeft } from "lucide-react";+import { AlertCircle } from "lucide-react";+import { RecentSearchesBackLink } from "@/client/components/RecentSearches";import { getErrorCode } from "@/client/lib/error-messages";import { BILLING_ROUTE } from "@/shared/billing";import { formatLocationLabel } from "@/shared/keyword-locations";@@ -206,15 +207,16 @@ export function KeywordResearchPage(input: Props) {<KeywordResearchSearchBar controller={controller} />{controller.hasSearched ? (<div className="flex flex-col gap-2">- <button- type="button"- data-testid="keyword-research-recent-searches"- className="btn btn-ghost btn-sm w-fit gap-2 px-0 text-base-content/70 hover:bg-transparent"- onClick={showRecentSearches}- >- <ArrowLeft className="size-4" />- Recent searches- </button>+ <RecentSearchesBackLink+ render={(props) => (+ <button+ type="button"+ data-testid="keyword-research-recent-searches"+ onClick={showRecentSearches}+ {...props}+ />+ )}+ /><SearchTabStripprojectId={projectId}tabs={searchTabs.tabs}diff --git a/src/client/features/sam/SamSidebarPanel.tsx b/src/client/features/sam/SamSidebarPanel.tsxindex 29718ac4..bbd85808 100644--- a/src/client/features/sam/SamSidebarPanel.tsx+++ b/src/client/features/sam/SamSidebarPanel.tsx@@ -166,18 +166,22 @@ export function SamSidebarPanel({>{session.title}</button>- <span className="shrink-0 text-xs text-base-content/40 group-hover:hidden">- {ageLabel(session.updatedAt)}- </span>- <button- type="button"- aria-label="Archive chat"- className="btn btn-ghost btn-xs btn-square hidden group-hover:inline-flex"- disabled={archiveSession.isPending}- onClick={() => archiveSession.mutate(session.id)}- >- <Archive className="size-3.5 text-base-content/50" />- </button>+ {/* The age and the Archive button share one grid cell, so the+ button takes the place of the age when it shows. */}+ <div className="grid shrink-0 place-items-center *:col-start-1 *:row-start-1">+ <span className="text-xs text-base-content/40 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0 pointer-coarse:opacity-0">+ {ageLabel(session.updatedAt)}+ </span>+ <button+ type="button"+ aria-label="Archive chat"+ className="btn btn-ghost btn-xs btn-square reveal-on-hover"+ disabled={archiveSession.isPending}+ onClick={() => archiveSession.mutate(session.id)}+ >+ <Archive className="size-3.5 text-base-content/50" />+ </button>+ </div></div>);})diff --git a/src/client/hooks/useBrandLookupSearchHistory.ts b/src/client/hooks/useBrandLookupSearchHistory.tsindex 8d6b4400..598b2380 100644--- a/src/client/hooks/useBrandLookupSearchHistory.ts+++ b/src/client/hooks/useBrandLookupSearchHistory.ts@@ -11,12 +11,6 @@ const brandLookupSearchBodySchema = z.object({scope: researchScopeSchema.optional(),});-type BrandLookupSearchBody = z.infer<typeof brandLookupSearchBodySchema>;--export type BrandLookupSearchHistoryItem = BrandLookupSearchBody & {- timestamp: number;-};-export function useBrandLookupSearchHistory(projectId: string) {return useTimestampedSearchHistory({storageKey: `brand-lookup-search-history:${projectId}`,diff --git a/src/client/hooks/usePromptExplorerSearchHistory.ts b/src/client/hooks/usePromptExplorerSearchHistory.tsindex a6df3b2c..01c3fcf1 100644--- a/src/client/hooks/usePromptExplorerSearchHistory.ts+++ b/src/client/hooks/usePromptExplorerSearchHistory.ts@@ -16,10 +16,6 @@ const promptExplorerSearchBodySchema = z.object({type PromptExplorerSearchBody = z.infer<typeof promptExplorerSearchBodySchema>;-export type PromptExplorerSearchHistoryItem = PromptExplorerSearchBody & {- timestamp: number;-};-function sameModels(a: string[], b: string[]): boolean {if (a.length !== b.length) return false;const sortedA = sortBy(a, identity());diff --git a/src/client/styles/app.css b/src/client/styles/app.cssindex c9a4c1f0..0b03902a 100644--- a/src/client/styles/app.css+++ b/src/client/styles/app.css@@ -123,6 +123,12 @@ select {}}+/* Row actions that appear on hover. Keyboard focus inside the row and touch+ screens (no hover) show them too. Put `group` on the row. */+@utility reveal-on-hover {+ @apply opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 pointer-coarse:opacity-100;+}+/* Touch device optimizations */@media (pointer: coarse) {html {