Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Port project settings, integration controls, and context to shadcn (EVE-307) (#752)
Carter Smith5bf603055849
diff --git a/src/client/features/crawler-access/CrawlerAccessForm.tsx b/src/client/features/crawler-access/CrawlerAccessForm.tsxindex c1b57e01..c5102967 100644--- a/src/client/features/crawler-access/CrawlerAccessForm.tsx+++ b/src/client/features/crawler-access/CrawlerAccessForm.tsx@@ -1,7 +1,8 @@import { useMutation, useQueryClient } from "@tanstack/react-query";-import { useState } from "react";import { toast } from "sonner";-import { Button } from "@/client/components/ui/button";+import { z } from "zod";+import { revalidateLogic } from "@tanstack/react-form";+import { useAppForm } from "@/client/components/form/useAppForm";import { saveCrawlerCredential } from "@/serverFunctions/crawlerAccess";import {isCrawlerAccessExpired,@@ -11,6 +12,19 @@ import {export const crawlerCredentialsQueryKey = ["crawler-credentials"];export const saveCrawlerCredentialMutationKey = ["save-crawler-credential"];+const signatureSchema = z.object({+ host: z.string().trim().min(1, "Enter a domain."),+ signatureInput: z+ .string()+ .trim()+ .min(1, "Enter Signature-Input.")+ .refine(+ (value) => !isCrawlerAccessExpired(parseSignatureExpiry(value)),+ "This signature has already expired. Create a new one in Shopify admin.",+ ),+ signature: z.string().trim().min(1, "Enter Signature."),+});+/*** The two values a merchant copies out of Shopify admin. `Signature-Agent` is* a constant we add ourselves, so it is not asked for here.@@ -28,19 +42,14 @@ export function CrawlerAccessForm({onSaved?: () => void;}) {const queryClient = useQueryClient();- const [host, setHost] = useState(initialHost);- const [signatureInput, setSignatureInput] = useState("");- const [signature, setSignature] = useState("");const saveMutation = useMutation({mutationKey: saveCrawlerCredentialMutationKey,- mutationFn: () =>+ mutationFn: (values: z.infer<typeof signatureSchema>) =>saveCrawlerCredential({- data: { projectId, host, signatureInput, signature },+ data: { projectId, ...values },}),onSuccess: async (saved) => {- setSignatureInput("");- setSignature("");await queryClient.invalidateQueries({queryKey: crawlerCredentialsQueryKey,});@@ -49,76 +58,61 @@ export function CrawlerAccessForm({},});- const isExpired = isCrawlerAccessExpired(- parseSignatureExpiry(signatureInput),- );- const canSave =- !isExpired &&- projectId !== "" &&- host.trim() !== "" &&- signatureInput.trim() !== "" &&- signature.trim() !== "";+ const form = useAppForm({+ defaultValues: { host: initialHost, signatureInput: "", signature: "" },+ validationLogic: revalidateLogic(),+ validators: { onDynamic: signatureSchema },+ onSubmit: async ({ value, formApi }) => {+ await saveMutation.mutateAsync(value);+ formApi.reset({ ...value, signatureInput: "", signature: "" });+ },+ });return (- <form- className="space-y-3"- onSubmit={(event) => {- event.preventDefault();- if (canSave) saveMutation.mutate();- }}- >- {!lockHost && (- <label className="block space-y-1">- <span className="text-sm font-medium">Domain</span>- <input- type="text"- className="input input-bordered input-sm w-full font-mono"- placeholder="store.example.com"- value={host}- onChange={(event) => setHost(event.target.value)}- />- </label>- )}-- <label className="block space-y-1">- <span className="text-sm font-medium">Signature-Input</span>- <input- type="password"- autoComplete="off"- data-ph-mask- className="input input-bordered input-sm w-full font-mono"- placeholder="sig1=(...);expires=..."- value={signatureInput}- onChange={(event) => setSignatureInput(event.target.value)}- />- {isExpired && (- <span className="block text-sm text-error">- This signature has already expired. Create a new one in Shopify- admin.- </span>- )}- </label>-- <label className="block space-y-1">- <span className="text-sm font-medium">Signature</span>- <input- type="password"- autoComplete="off"- data-ph-mask- className="input input-bordered input-sm w-full font-mono"- placeholder="sig1=:...:"- value={signature}- onChange={(event) => setSignature(event.target.value)}- />- </label>-- <Button- type="submit"- pending={saveMutation.isPending}- disabled={!canSave}- >- Save signature- </Button>- </form>+ <form.AppForm>+ <form.Form className="space-y-3">+ {!lockHost ? (+ <form.AppField name="host">+ {(field) => (+ <field.TextField+ label="Domain"+ placeholder="store.example.com"+ className="font-mono"+ required+ />+ )}+ </form.AppField>+ ) : null}+ <form.AppField name="signatureInput">+ {(field) => (+ <field.TextField+ label="Signature-Input"+ type="password"+ autoComplete="off"+ data-ph-mask+ className="font-mono"+ placeholder="sig1=(...);expires=..."+ required+ />+ )}+ </form.AppField>+ <form.AppField name="signature">+ {(field) => (+ <field.TextField+ label="Signature"+ type="password"+ autoComplete="off"+ data-ph-mask+ className="font-mono"+ placeholder="sig1=:...:"+ required+ />+ )}+ </form.AppField>+ <form.SubmitButton disabled={!projectId}>+ Save signature+ </form.SubmitButton>+ </form.Form>+ </form.AppForm>);}diff --git a/src/client/features/integrations/GoogleAccountRemovalDialog.tsx b/src/client/features/integrations/GoogleAccountRemovalDialog.tsxindex 99698dbd..d98cadd6 100644--- a/src/client/features/integrations/GoogleAccountRemovalDialog.tsx+++ b/src/client/features/integrations/GoogleAccountRemovalDialog.tsx@@ -1,7 +1,15 @@-import { useEffect, useId, useRef } from "react";import { toast } from "sonner";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { getStandardErrorMessage } from "@/client/lib/error-messages";+import { Button } from "@/client/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from "@/client/components/ui/dialog";import {getGoogleAccountRemovalImpact,removeGoogleAccount,@@ -20,8 +28,6 @@ export function GoogleAccountRemovalDialog({onClose: () => void;onRemoved: () => void;}) {- const dialog = useRef<HTMLDialogElement>(null);- const titleId = useId();const queryClient = useQueryClient();const impact = useQuery({queryKey: ["googleAccountRemovalImpact", provider, accountId],@@ -59,45 +65,39 @@ export function GoogleAccountRemovalDialog({onRemoved();},});- useEffect(() => {- const element = dialog.current;- element?.showModal();- return () => element?.close();- }, []);const name = provider === "gsc" ? "Search Console" : "Google Analytics";return (- <dialog- ref={dialog}- aria-labelledby={titleId}- className="modal"- onCancel={(event) => {- event.preventDefault();- if (!removal.isPending) onClose();+ <Dialog+ open+ onOpenChange={(open) => {+ if (!open && !removal.isPending) onClose();}}>- <div className="modal-box max-w-md space-y-4">- <h3 id={titleId} className="text-lg font-semibold">- Remove Google account?- </h3>+ <DialogContent className="sm:max-w-md" showCloseButton={false}>+ <DialogHeader>+ <DialogTitle>Remove Google account?</DialogTitle>+ <DialogDescription>+ This removes the account’s {name} connection from OpenSEO. You can+ reconnect it anytime.+ </DialogDescription>+ </DialogHeader><p className="break-all text-sm font-medium">{label}</p>- <p className="text-sm text-base-content/70">- This removes the account’s {name} connection from OpenSEO. You can- reconnect it anytime.- </p>{impact.isPending ? (- <p role="status" className="text-sm text-base-content/60">+ <p role="status" className="text-sm text-muted-foreground">Checking connected projects…</p>) : impact.isError ? (<div role="alert" className="text-sm">- <p className="text-error">Couldn't check connected projects.</p>- <button- type="button"- className="btn btn-ghost btn-sm"+ <p className="text-destructive">+ Couldn't check connected projects.+ </p>+ <Button+ variant="ghost"+ size="sm"onClick={() => void impact.refetch()}>Try again- </button>+ </Button></div>) : impact.data.projectCount > 0 ? (<p className="text-sm font-medium">@@ -105,36 +105,36 @@ export function GoogleAccountRemovalDialog({project{impact.data.projectCount === 1 ? "" : "s"}.</p>) : (- <p className="text-sm text-base-content/60">+ <p className="text-sm text-muted-foreground">No projects will be affected.</p>)}{removal.isError ? (- <p role="alert" className="text-sm text-error">+ <p role="alert" className="text-sm text-destructive">{getStandardErrorMessage(removal.error)}</p>) : null}- <div className="flex flex-wrap justify-end gap-2">- <button- type="button"- className="btn btn-ghost btn-sm"+ <DialogFooter>+ <Button+ variant="ghost"+ size="sm"disabled={removal.isPending}onClick={onClose}>Cancel- </button>- <button- type="button"- className="btn btn-error btn-sm"+ </Button>+ <Button+ variant="destructive"+ size="sm"disabled={!impact.isSuccess || impact.isFetching || removal.isPending}onClick={() => removal.mutate()}>{removal.isPending ? "Removing…" : "Remove account"}- </button>- </div>- </div>- </dialog>+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>);}diff --git a/src/client/features/integrations/GoogleConnectedState.tsx b/src/client/features/integrations/GoogleConnectedState.tsxindex e17b09a6..8d8804fe 100644--- a/src/client/features/integrations/GoogleConnectedState.tsx+++ b/src/client/features/integrations/GoogleConnectedState.tsx@@ -1,3 +1,5 @@+import { Button } from "@/client/components/ui/button";+export function GoogleConnectedState({property,detail,@@ -26,12 +28,14 @@ export function GoogleConnectedState({{property || detail}</p>{detail ? (- <p className="mt-1 text-xs text-base-content/50">+ <p className="mt-1 text-xs text-muted-foreground">ID {detail.replace(/^properties\//, "")}</p>) : null}{email ? (- <p className="mt-1 break-all text-sm text-base-content/60">{email}</p>+ <p className="mt-1 break-all text-sm text-muted-foreground">+ {email}+ </p>) : null}</div>{canManage || canManageAccounts ? (@@ -39,23 +43,15 @@ export function GoogleConnectedState({disabled={disconnecting || disabled}className="flex flex-wrap items-center gap-1">- <button- type="button"- className="btn btn-outline btn-sm border-base-300"- onClick={onChange}- >+ <Button variant="outline" size="sm" onClick={onChange}>{canManage? "Change property or account": "Manage Google accounts"}- </button>+ </Button>{canManage ? (- <button- type="button"- className="btn btn-ghost btn-sm text-error hover:bg-error/10"- onClick={onDisconnect}- >+ <Button variant="destructive" size="sm" onClick={onDisconnect}>{disconnecting ? "Disconnecting…" : "Disconnect project"}- </button>+ </Button>) : null}</fieldset>) : null}diff --git a/src/client/features/integrations/GoogleOAuthSetupWarning.tsx b/src/client/features/integrations/GoogleOAuthSetupWarning.tsxindex 7c594d61..d9873852 100644--- a/src/client/features/integrations/GoogleOAuthSetupWarning.tsx+++ b/src/client/features/integrations/GoogleOAuthSetupWarning.tsx@@ -1,5 +1,10 @@import { AlertTriangle } from "lucide-react";import { SafeExternalLink } from "@/client/components/SafeExternalLink";+import {+ Alert,+ AlertDescription,+ AlertTitle,+} from "@/client/components/ui/alert";export function GoogleOAuthSetupWarning({integrationName,@@ -9,11 +14,11 @@ export function GoogleOAuthSetupWarning({docsUrl: string;}) {return (- <div className="alert alert-warning items-start text-sm">- <AlertTriangle className="mt-0.5 size-4 shrink-0" />- <div className="space-y-1">- <p className="font-medium">Google OAuth client not configured</p>- <p className="text-base-content/70">+ <Alert variant="warning">+ <AlertTriangle className="size-4" />+ <AlertTitle>Google OAuth client not configured</AlertTitle>+ <AlertDescription>+ <p>Add your Google client ID and secret to this OpenSEO deployment beforeconnecting {integrationName}.</p>@@ -22,7 +27,7 @@ export function GoogleOAuthSetupWarning({label="Open setup guide"className="inline-flex items-center gap-1 font-medium underline underline-offset-2"/>- </div>- </div>+ </AlertDescription>+ </Alert>);}diff --git a/src/client/features/integrations/GoogleProjectEmptyState.tsx b/src/client/features/integrations/GoogleProjectEmptyState.tsxindex ceb1cf7b..c04d50d9 100644--- a/src/client/features/integrations/GoogleProjectEmptyState.tsx+++ b/src/client/features/integrations/GoogleProjectEmptyState.tsx@@ -1,5 +1,6 @@import type { ReactNode } from "react";import { GoogleGlyph } from "@/client/features/gsc/GoogleGlyph";+import { Button } from "@/client/components/ui/button";export function GoogleProjectEmptyState({name,@@ -20,25 +21,22 @@ export function GoogleProjectEmptyState({}) {return (<div className="space-y-4">- <p className="text-sm text-base-content/70">+ <p className="text-sm text-muted-foreground">{hasGrant? `Choose a ${name} property to finish connecting this project.`: `Connect ${name} to see this project’s data.`}</p><div className="flex flex-wrap items-center gap-1">{canManage || hasGrant ? (- <button- type="button"+ <Button+ variant="outline"+ size="sm"onClick={hasGrant ? onChoose : onLink}- disabled={disabled}- aria-busy={disabled}- 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 shadow-sm transition hover:bg-base-200 disabled:opacity-50"+ pending={disabled}>- {disabled ? (- <span className="loading loading-spinner loading-xs" />- ) : (- !hasGrant && <GoogleGlyph className="size-[18px]" />- )}+ {!disabled && !hasGrant ? (+ <GoogleGlyph className="size-[18px]" />+ ) : null}{disabled? "Opening Google…": canManage@@ -46,7 +44,7 @@ export function GoogleProjectEmptyState({? "Choose property": "Connect": "Manage Google accounts"}- </button>+ </Button>) : null}{children}</div>diff --git a/src/client/features/integrations/GooglePropertyPicker.tsx b/src/client/features/integrations/GooglePropertyPicker.tsxindex 34d35fd7..d605507b 100644--- a/src/client/features/integrations/GooglePropertyPicker.tsx+++ b/src/client/features/integrations/GooglePropertyPicker.tsx@@ -1,6 +1,8 @@import { GoogleAccountRemovalDialog } from "@/client/features/integrations/GoogleAccountRemovalDialog";import { QueryError } from "@/client/components/QueryState";import { Spinner } from "@/client/components/Spinner";+import { Button } from "@/client/components/ui/button";+import { Input } from "@/client/components/ui/input";import {useId,useRef,@@ -106,16 +108,10 @@ 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}- >+ const saveButton = readOnly ? null : (+ <Button size="sm" onClick={onSave} disabled={!canSave || saving}>{saving ? "Saving…" : saveLabel}- </button>+ </Button>);return (<div className="space-y-4">@@ -135,13 +131,13 @@ export function GooglePropertyPicker({<p className="mb-2 text-sm font-medium">{readOnly ? "Manage Google accounts" : "Choose property"}</p>- <button+ <Buttonref={trigger}- type="button"+ variant="outline"aria-expanded={open}aria-controls={panelId}disabled={saving}- className="flex w-full items-center justify-between gap-3 rounded-lg border border-base-300 px-3.5 py-3 text-left text-sm hover:bg-base-200/40 disabled:opacity-50"+ className="h-auto w-full justify-between gap-3 px-3.5 py-3 text-left font-normal"onClick={() => {setOpen(!open);setSearch("");@@ -152,31 +148,31 @@ export function GooglePropertyPicker({{selected?.name ?? "Select a property…"}</span>{selectedAccount ? (- <span className="mt-0.5 block truncate text-xs text-base-content/50">+ <span className="mt-0.5 block truncate text-xs text-muted-foreground">{accountLabel(selectedAccount)}</span>) : null}</span>- <ChevronDown className="size-4 shrink-0 text-base-content/50" />- </button>+ <ChevronDown className="size-4 shrink-0 text-muted-foreground" />+ </Button>{open ? (<divid={panelId}role="region"aria-label="Google properties"- className="mt-2 overflow-hidden rounded-lg border border-base-300 bg-base-100 shadow-sm"+ className="mt-2 overflow-hidden rounded-lg border border-border bg-popover shadow-sm"onKeyDown={(event) => handlePropertyKeyDown(event, close)}>- <label className="flex items-center gap-2 border-b border-base-300 px-3.5 py-3">- <Search className="size-4 shrink-0 text-base-content/40" />- <input+ <label className="flex items-center gap-2 border-b border-border px-3.5 py-3">+ <Search className="size-4 shrink-0 text-muted-foreground" />+ <InputautoFocustype="search"aria-label="Search properties or accounts"placeholder="Search properties or accounts…"value={search}onChange={(event) => setSearch(event.target.value)}- className="min-w-0 w-full bg-transparent text-sm outline-none"+ className="h-auto min-w-0 border-0 bg-transparent p-0 shadow-none focus-visible:ring-0"/></label><div className="max-h-72 overflow-y-auto overscroll-contain p-1.5">@@ -200,51 +196,48 @@ export function GooglePropertyPicker({role="group"aria-label={accountLabel(account)}>- <div className="flex items-center justify-between gap-2 px-2 py-2 text-xs font-medium text-base-content/55">+ <div className="flex items-center justify-between gap-2 px-2 py-2 text-xs font-medium text-muted-foreground"><span className="min-w-0 break-all">{accountLabel(account)}</span>- <button- type="button"- className="btn btn-ghost btn-xs shrink-0 text-error"+ <Button+ variant="ghost"+ size="xs"+ className="shrink-0 text-destructive"disabled={saving}onClick={() => setRemoving(account)}aria-label={`Remove ${accountLabel(account)}`}>Remove account- </button>+ </Button></div>{account.requiresReconnect ? (<div className="flex flex-wrap items-center justify-between gap-2 px-2 pb-2 text-sm">- <span className="text-base-content/60">+ <span className="text-muted-foreground">Connection expired</span>- <button- type="button"- className="btn btn-ghost btn-xs"+ <Button+ variant="ghost"+ size="xs"onClick={onReconnect}aria-label={`Reconnect ${accountLabel(account)}`}disabled={linking}aria-busy={linking}>{linking ? "Opening Google…" : "Reconnect"}- </button>+ </Button></div>) : account.unavailable ? (<div className="flex flex-wrap items-center justify-between gap-2 px-2 pb-2 text-sm">- <span className="text-base-content/60">+ <span className="text-muted-foreground">Couldn't load properties</span>- <button- type="button"- className="btn btn-ghost btn-xs"- onClick={onRetry}- >+ <Button variant="ghost" size="xs" onClick={onRetry}>Try again- </button>+ </Button></div>) : account.properties.length === 0 ? (- <p className="px-2 pb-3 text-sm text-base-content/50">+ <p className="px-2 pb-3 text-sm text-muted-foreground">No properties available</p>) : (@@ -253,15 +246,16 @@ export function GooglePropertyPicker({selection?.accountId === account.accountId &&selection?.propertyId === property.id;return (- <button+ <Buttonkey={property.id}data-propertytype="button"+ variant="ghost"aria-pressed={chosen}disabled={readOnly || !property.selectable || saving}- className={`flex w-full items-center justify-between gap-3 rounded-md px-2 py-2.5 text-left text-sm hover:bg-base-200 focus-visible:outline-2 focus-visible:outline-primary disabled:opacity-40 ${chosen ? "bg-base-200" : ""}`}+ className={`h-auto w-full justify-between gap-3 rounded-md px-2 py-2.5 text-left font-normal hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-40 ${chosen ? "bg-accent" : ""}`}onClick={() => {onSelect({accountId: account.accountId,@@ -275,7 +269,7 @@ export function GooglePropertyPicker({{property.name}</span>{property.detail ? (- <span className="mt-0.5 block text-xs text-base-content/50">+ <span className="mt-0.5 block text-xs text-muted-foreground">{property.detail}</span>) : null}@@ -288,14 +282,14 @@ export function GooglePropertyPicker({{chosen ? (<Check className="size-4 shrink-0" />) : null}- </button>+ </Button>);}))}</div>))}{filtered.length === 0 ? (- <p className="p-3 text-sm text-base-content/50">+ <p className="p-3 text-sm text-muted-foreground">{query? "No matching properties or accounts": "Add a Google account to find properties."}@@ -304,21 +298,17 @@ export function GooglePropertyPicker({</>)}</div>- <div className="border-t border-base-300 p-1.5">- <button- type="button"- className="flex w-full items-center gap-2 rounded-md px-2 py-2.5 text-left text-sm font-medium hover:bg-base-200"+ <div className="border-t border-border p-1.5">+ <Button+ variant="ghost"+ className="h-auto w-full justify-start px-2 py-2.5"onClick={onReconnect}disabled={saving || linking}- aria-busy={linking}+ pending={linking}>- {linking ? (- <span className="loading loading-spinner loading-xs" />- ) : (- <Plus className="size-4" />- )}+ {linking ? null : <Plus className="size-4" />}{linking ? "Opening Google…" : "Add Google account"}- </button>+ </Button></div></div>) : null}@@ -329,14 +319,14 @@ export function GooglePropertyPicker({<div className="flex flex-wrap items-center gap-1">{saveButton}{secondaryAction ? (- <button- type="button"- className="btn btn-ghost btn-sm"+ <Button+ variant="ghost"+ size="sm"disabled={saving || secondaryAction.disabled}onClick={secondaryAction.onClick}>{secondaryAction.label}- </button>+ </Button>) : null}</div>)}diff --git a/src/client/features/projects/ProjectGeneralSettings.tsx b/src/client/features/projects/ProjectGeneralSettings.tsxindex 7f4c886a..2cb3f2f3 100644--- a/src/client/features/projects/ProjectGeneralSettings.tsx+++ b/src/client/features/projects/ProjectGeneralSettings.tsx@@ -125,7 +125,7 @@ function GeneralSection({ project }: { project: ProjectSummary }) {/>)}</form.Field>- <span className="text-xs text-base-content/50">+ <span className="text-xs text-muted-foreground">Keyword, SERP, and domain data uses this country and languageunless a call asks for a different one.</span>diff --git a/src/client/features/projects/ProjectPageHeader.tsx b/src/client/features/projects/ProjectPageHeader.tsxnew file mode 100644index 00000000..cb4e00af--- /dev/null+++ b/src/client/features/projects/ProjectPageHeader.tsx@@ -0,0 +1,23 @@+import { useQuery } from "@tanstack/react-query";+import { BackLink, PageHeader } from "@/client/components/PageHeader";+import { projectsQueryOptions } from "./projectQueries";++export function ProjectPageHeader({+ projectId,+ title,+ showBackLink = false,+}: {+ projectId: string;+ title: string;+ showBackLink?: boolean;+}) {+ const projectsQuery = useQuery(projectsQueryOptions());+ const project = projectsQuery.data?.find((entry) => entry.id === projectId);++ return (+ <div className="space-y-4">+ {showBackLink ? <BackLink to="/projects">Projects</BackLink> : null}+ <PageHeader title={title} description={project?.name ?? " "} />+ </div>+ );+}diff --git a/src/client/features/projects/SettingsTabs.tsx b/src/client/features/projects/SettingsTabs.tsxnew file mode 100644index 00000000..7df39f7d--- /dev/null+++ b/src/client/features/projects/SettingsTabs.tsx@@ -0,0 +1,23 @@+import { NavTab, NavTabs } from "@/client/components/NavTabs";++const tabs = [+ { to: "/p/$projectId/settings" as const, label: "General", exact: true },+ { to: "/p/$projectId/settings/integrations" as const, label: "Integrations" },+];++export function SettingsTabs({ projectId }: { projectId: string }) {+ return (+ <NavTabs label="Project settings sections">+ {tabs.map((tab) => (+ <NavTab+ key={tab.to}+ to={tab.to}+ params={{ projectId }}+ activeOptions={{ exact: tab.exact ?? false }}+ >+ {tab.label}+ </NavTab>+ ))}+ </NavTabs>+ );+}diff --git a/src/client/features/projects/project-context/CompetitorsSection.tsx b/src/client/features/projects/project-context/CompetitorsSection.tsxindex 044f15e0..e80d85c7 100644--- a/src/client/features/projects/project-context/CompetitorsSection.tsx+++ b/src/client/features/projects/project-context/CompetitorsSection.tsx@@ -1,17 +1,11 @@import * as React from "react";-import { InlineConfirm } from "@/client/components/InlineConfirm";-import { Pencil, Plus } from "lucide-react";-import type { ProjectContextUpdate } from "@/types/schemas/projectContext";-import {- listClass,- Provenance,- RowActions,- useContextUpdate,- type ContextCompetitor,-} from "./shared";-import { EmptyState } from "@/client/components/EmptyState";+import { Input } from "@/client/components/ui/input";import { FormActions } from "@/client/components/FormActions";-import { SectionHeader } from "@/client/components/PageHeader";+import type { ProjectContextUpdate } from "@/types/schemas/projectContext";+import { EditableListSection } from "./EditableListSection";+import { Provenance, useContextUpdate, type ContextCompetitor } from "./shared";++type CompetitorDraft = { domain: string; name: string; notes: string };export function CompetitorsSection({projectId,@@ -21,19 +15,17 @@ export function CompetitorsSection({competitors: ContextCompetitor[];}) {const update = useContextUpdate(projectId);- const [adding, setAdding] = React.useState(false);- const [editingId, setEditingId] = React.useState<string | null>(null);- const save = (previousDomain: string | null, draft: CompetitorDraft) => {+ const save = (+ previousDomain: string | null,+ draft: CompetitorDraft,+ close: () => void,+ ) => {const ops: ProjectContextUpdate[] = [];- // Competitors upsert by domain, so a retyped domain has to drop the old row- // before the new one lands.if (previousDomain && previousDomain !== draft.domain.trim()) {ops.push({ removeCompetitors: [previousDomain] });}- // Send the fields even when blank: an omitted field means "keep what's- // stored" (so agent writes merge), so clearing one from the form has to- // send the empty string.+ // Blank values clear stored fields. Omission would preserve agent writes.ops.push({addCompetitors: [{@@ -43,118 +35,49 @@ export function CompetitorsSection({},],});- update.mutate(ops, {- onSuccess: () => {- setAdding(false);- setEditingId(null);- },- });+ update.mutate(ops, { onSuccess: close });};return (- <section className="space-y-3">- <SectionHeader- title="Competitors"- hint="The sites you measure yourself against."- action={- <button- type="button"- className="btn btn-ghost btn-xs"- onClick={() => setAdding(true)}- >- <Plus className="size-3.5" />- Add competitor- </button>- }- />-- {adding ? (- <div className={listClass}>- <CompetitorForm- pending={update.isPending}- onCancel={() => setAdding(false)}- onSave={(draft) => save(null, draft)}- />+ <EditableListSection+ title="Competitors"+ hint="The sites you measure yourself against."+ addLabel="Add competitor"+ emptyTitle="No competitors yet"+ emptyDescription="Add the sites you compete with, or ask SAM to find them from your rankings and save them here."+ items={competitors}+ getId={(item) => item.id}+ getLabel={(item) => item.domain}+ pending={update.isPending}+ onRemove={(item) => update.mutate([{ removeCompetitors: [item.domain] }])}+ renderItem={(item) => (+ <div className="min-w-0 space-y-0.5">+ <div className="flex flex-wrap items-baseline gap-x-2">+ <span className="truncate text-sm font-medium">{item.domain}</span>+ {item.name ? (+ <span className="truncate text-xs text-muted-foreground">+ {item.name}+ </span>+ ) : null}+ </div>+ {item.notes ? (+ <p className="text-sm text-muted-foreground">{item.notes}</p>+ ) : null}+ <Provenance by={item.updatedBy} at={item.updatedAt} /></div>- ) : null}-- {competitors.length === 0 ? (- adding ? null : (- <EmptyState- size="sm"- icon={null}- title="No competitors yet"- description="Add the sites you compete with, or ask SAM to find them from your rankings and save them here."- />- )- ) : (- <ul className={listClass}>- {competitors.map((competitor) =>- editingId === competitor.id ? (- <li key={competitor.id}>- <CompetitorForm- initial={competitor}- pending={update.isPending}- onCancel={() => setEditingId(null)}- onSave={(draft) => save(competitor.domain, draft)}- />- </li>- ) : (- <li- key={competitor.id}- className="flex items-start justify-between gap-3 p-3"- >- <div className="min-w-0 space-y-0.5">- <div className="flex flex-wrap items-baseline gap-x-2">- <span className="truncate text-sm font-medium">- {competitor.domain}- </span>- {competitor.name ? (- <span className="truncate text-xs text-base-content/60">- {competitor.name}- </span>- ) : null}- </div>- {competitor.notes ? (- <p className="text-sm text-base-content/70">- {competitor.notes}- </p>- ) : null}- <Provenance- by={competitor.updatedBy}- at={competitor.updatedAt}- />- </div>- <RowActions>- <button- type="button"- className="btn btn-ghost btn-xs"- aria-label={`Edit ${competitor.domain}`}- onClick={() => setEditingId(competitor.id)}- >- <Pencil className="size-3.5" />- </button>- <InlineConfirm- label={`Remove ${competitor.domain}`}- pending={update.isPending}- onConfirm={() =>- update.mutate([- { removeCompetitors: [competitor.domain] },- ])- }- />- </RowActions>- </li>- ),- )}- </ul>)}- </section>+ renderForm={(item, close) => (+ <CompetitorForm+ initial={item}+ pending={update.isPending}+ onCancel={close}+ onSave={(draft) => save(item?.domain ?? null, draft, close)}+ />+ )}+ />);}-type CompetitorDraft = { domain: string; name: string; notes: string };-function CompetitorForm({initial,pending,@@ -174,7 +97,7 @@ function CompetitorForm({return (<form- className="space-y-2 bg-base-200/40 p-3"+ className="space-y-2 bg-muted/40 p-3"onSubmit={(event) => {event.preventDefault();if (!draft.domain.trim() || pending) return;@@ -182,35 +105,29 @@ function CompetitorForm({}}><div className="grid gap-2 sm:grid-cols-2">- <input+ <InputautoFocus- type="text"value={draft.domain}onChange={(event) =>setDraft({ ...draft, domain: event.target.value })}placeholder="competitor.com"maxLength={255}- className="input input-bordered input-sm w-full"aria-label="Competitor domain"/>- <input- type="text"+ <Inputvalue={draft.name}onChange={(event) => setDraft({ ...draft, name: event.target.value })}placeholder="Name (optional)"maxLength={120}- className="input input-bordered input-sm w-full"aria-label="Competitor name"/></div>- <input- type="text"+ <Inputvalue={draft.notes}onChange={(event) => setDraft({ ...draft, notes: event.target.value })}placeholder="Why they matter — e.g. wins every comparison keyword (optional)"maxLength={500}- className="input input-bordered input-sm w-full"aria-label="Competitor notes"/><FormActionsdiff --git a/src/client/features/projects/project-context/EditableListSection.test.ts b/src/client/features/projects/project-context/EditableListSection.test.tsnew file mode 100644index 00000000..8799a64a--- /dev/null+++ b/src/client/features/projects/project-context/EditableListSection.test.ts@@ -0,0 +1,35 @@+import { createElement, type ReactNode } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { load } from "cheerio";+import { expect, it, vi } from "vitest";+import { EditableListSection } from "./EditableListSection";++vi.mock("./shared", () => ({+ RowActions: ({ children }: { children: ReactNode }) => children,+ listClass: "",+}));++type Item = { id: string; label: string };++it("keeps context list drafts in place while a save is pending", () => {+ const html = renderToStaticMarkup(+ createElement(EditableListSection<Item>, {+ title: "Competitors",+ hint: "Competitor sites",+ addLabel: "Add competitor",+ emptyTitle: "No competitors",+ emptyDescription: "Add one",+ items: [{ id: "a", label: "alpha.com" }],+ getId: (item) => item.id,+ getLabel: (item) => item.label,+ renderItem: (item) => item.label,+ renderForm: () => null,+ onRemove: vi.fn(),+ pending: true,+ }),+ );+ const $ = load(html);++ expect($("button:contains('Add competitor')").is(":disabled")).toBe(true);+ expect($("button[aria-label='Edit alpha.com']").is(":disabled")).toBe(true);+});diff --git a/src/client/features/projects/project-context/EditableListSection.tsx b/src/client/features/projects/project-context/EditableListSection.tsxnew file mode 100644index 00000000..8b22c297--- /dev/null+++ b/src/client/features/projects/project-context/EditableListSection.tsx@@ -0,0 +1,104 @@+import { useState, type ReactNode } from "react";+import { Pencil, Plus } from "lucide-react";+import { Button } from "@/client/components/ui/button";+import { EmptyState } from "@/client/components/EmptyState";+import { InlineConfirm } from "@/client/components/InlineConfirm";+import { SectionHeader } from "@/client/components/PageHeader";+import { RowActions, listClass } from "./shared";++/** The same add, edit, and remove interaction for both context lists. */+export function EditableListSection<T>({+ title,+ hint,+ addLabel,+ emptyTitle,+ emptyDescription,+ items,+ getId,+ getLabel,+ renderItem,+ renderForm,+ onRemove,+ pending,+}: {+ title: string;+ hint: string;+ addLabel: string;+ emptyTitle: string;+ emptyDescription: string;+ items: T[];+ getId: (item: T) => string;+ getLabel: (item: T) => string;+ renderItem: (item: T) => ReactNode;+ renderForm: (item: T | undefined, close: () => void) => ReactNode;+ onRemove: (item: T) => void;+ pending: boolean;+}) {+ const [editing, setEditing] = useState<string | null>(null);+ const close = () => setEditing(null);++ return (+ <section className="space-y-3">+ <SectionHeader+ title={title}+ hint={hint}+ action={+ <Button+ variant="ghost"+ size="xs"+ disabled={pending}+ onClick={() => setEditing("add")}+ >+ <Plus className="size-3.5" />+ {addLabel}+ </Button>+ }+ />+ {editing === "add" ? (+ <div className={listClass}>{renderForm(undefined, close)}</div>+ ) : null}+ {items.length === 0 ? (+ editing === "add" ? null : (+ <EmptyState+ size="sm"+ icon={null}+ title={emptyTitle}+ description={emptyDescription}+ />+ )+ ) : (+ <ul className={listClass}>+ {items.map((item) => {+ const id = getId(item);+ return editing === id ? (+ <li key={id}>{renderForm(item, close)}</li>+ ) : (+ <li+ key={id}+ className="flex items-start justify-between gap-3 p-3"+ >+ {renderItem(item)}+ <RowActions>+ <Button+ variant="ghost"+ size="icon-xs"+ disabled={pending}+ aria-label={`Edit ${getLabel(item)}`}+ onClick={() => setEditing(id)}+ >+ <Pencil className="size-3.5" />+ </Button>+ <InlineConfirm+ label={`Remove ${getLabel(item)}`}+ pending={pending}+ onConfirm={() => onRemove(item)}+ />+ </RowActions>+ </li>+ );+ })}+ </ul>+ )}+ </section>+ );+}diff --git a/src/client/features/projects/project-context/KeyPagesSection.tsx b/src/client/features/projects/project-context/KeyPagesSection.tsxindex 1832b4dc..de9e3005 100644--- a/src/client/features/projects/project-context/KeyPagesSection.tsx+++ b/src/client/features/projects/project-context/KeyPagesSection.tsx@@ -1,21 +1,21 @@import * as React from "react";-import { InlineConfirm } from "@/client/components/InlineConfirm";-import { Pencil, Plus } from "lucide-react";+import { Badge } from "@/client/components/ui/badge";+import { FormActions } from "@/client/components/FormActions";+import { Input } from "@/client/components/ui/input";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/client/components/ui/select";import {KEY_PAGE_ROLES,type KeyPageRole,type ProjectContextUpdate,} from "@/types/schemas/projectContext";-import {- listClass,- Provenance,- RowActions,- useContextUpdate,- type ContextKeyPage,-} from "./shared";-import { EmptyState } from "@/client/components/EmptyState";-import { FormActions } from "@/client/components/FormActions";-import { SectionHeader } from "@/client/components/PageHeader";+import { EditableListSection } from "./EditableListSection";+import { Provenance, useContextUpdate, type ContextKeyPage } from "./shared";const ROLE_LABELS: Record<KeyPageRole, string> = {hub: "Hub page",@@ -23,6 +23,17 @@ const ROLE_LABELS: Record<KeyPageRole, string> = {money: "Money page",other: "Other",};+const roleItems = KEY_PAGE_ROLES.map((role) => ({+ value: role,+ label: ROLE_LABELS[role],+}));++type KeyPageDraft = {+ url: string;+ role: KeyPageRole;+ topic: string;+ notes: string;+};export function KeyPagesSection({projectId,@@ -32,19 +43,17 @@ export function KeyPagesSection({keyPages: ContextKeyPage[];}) {const update = useContextUpdate(projectId);- const [adding, setAdding] = React.useState(false);- const [editingId, setEditingId] = React.useState<string | null>(null);- const save = (previousUrl: string | null, draft: KeyPageDraft) => {+ const save = (+ previousUrl: string | null,+ draft: KeyPageDraft,+ close: () => void,+ ) => {const ops: ProjectContextUpdate[] = [];- // Key pages upsert by URL, so a retyped URL has to drop the old row before- // the new one lands.if (previousUrl && previousUrl !== draft.url.trim()) {ops.push({ removeKeyPages: [previousUrl] });}- // Send the fields even when blank: an omitted field means "keep what's- // stored" (so agent writes merge), so clearing one from the form has to- // send the empty string.+ // Blank values clear stored fields. Omission would preserve agent writes.ops.push({addKeyPages: [{@@ -55,119 +64,52 @@ export function KeyPagesSection({},],});- update.mutate(ops, {- onSuccess: () => {- setAdding(false);- setEditingId(null);- },- });+ update.mutate(ops, { onSuccess: close });};return (- <section className="space-y-3">- <SectionHeader- title="Key pages"- hint="A shortlist of the pages that carry the site — not an inventory."- action={- <button- type="button"- className="btn btn-ghost btn-xs"- onClick={() => setAdding(true)}- >- <Plus className="size-3.5" />- Add page- </button>- }- />-- {adding ? (- <div className={listClass}>- <KeyPageForm- pending={update.isPending}- onCancel={() => setAdding(false)}- onSave={(draft) => save(null, draft)}- />+ <EditableListSection+ title="Key pages"+ hint="A shortlist of the pages that carry the site — not an inventory."+ addLabel="Add page"+ emptyTitle="No key pages yet"+ emptyDescription="Add the handful that has to rank, or let an agent propose them from your last site audit."+ items={keyPages}+ getId={(item) => item.id}+ getLabel={(item) => item.url}+ pending={update.isPending}+ onRemove={(item) => update.mutate([{ removeKeyPages: [item.url] }])}+ renderItem={(item) => (+ <div className="min-w-0 space-y-0.5">+ <div className="flex flex-wrap items-baseline gap-x-2">+ <span className="truncate text-sm font-medium">{item.url}</span>+ <Badge variant="secondary" size="sm">+ {ROLE_LABELS[item.role]}+ </Badge>+ </div>+ {item.topic ? (+ <p className="text-sm text-muted-foreground">+ Target: {item.topic}+ </p>+ ) : null}+ {item.notes ? (+ <p className="text-sm text-muted-foreground">{item.notes}</p>+ ) : null}+ <Provenance by={item.updatedBy} at={item.updatedAt} /></div>- ) : null}-- {keyPages.length === 0 ? (- adding ? null : (- <EmptyState- size="sm"- icon={null}- title="No key pages yet"- description="Add the handful that has to rank, or let an agent propose them from your last site audit."- />- )- ) : (- <ul className={listClass}>- {keyPages.map((page) =>- editingId === page.id ? (- <li key={page.id}>- <KeyPageForm- initial={page}- pending={update.isPending}- onCancel={() => setEditingId(null)}- onSave={(draft) => save(page.url, draft)}- />- </li>- ) : (- <li- key={page.id}- className="flex items-start justify-between gap-3 p-3"- >- <div className="min-w-0 space-y-0.5">- <div className="flex flex-wrap items-baseline gap-x-2">- <span className="truncate text-sm font-medium">- {page.url}- </span>- <span className="badge badge-ghost badge-sm shrink-0">- {ROLE_LABELS[page.role]}- </span>- </div>- {page.topic ? (- <p className="text-sm text-base-content/70">- Target: {page.topic}- </p>- ) : null}- {page.notes ? (- <p className="text-sm text-base-content/70">{page.notes}</p>- ) : null}- <Provenance by={page.updatedBy} at={page.updatedAt} />- </div>- <RowActions>- <button- type="button"- className="btn btn-ghost btn-xs"- aria-label={`Edit ${page.url}`}- onClick={() => setEditingId(page.id)}- >- <Pencil className="size-3.5" />- </button>- <InlineConfirm- label={`Remove ${page.url}`}- pending={update.isPending}- onConfirm={() =>- update.mutate([{ removeKeyPages: [page.url] }])- }- />- </RowActions>- </li>- ),- )}- </ul>)}- </section>+ renderForm={(item, close) => (+ <KeyPageForm+ initial={item}+ pending={update.isPending}+ onCancel={close}+ onSave={(draft) => save(item?.url ?? null, draft, close)}+ />+ )}+ />);}-type KeyPageDraft = {- url: string;- role: KeyPageRole;- topic: string;- notes: string;-};-function KeyPageForm({initial,pending,@@ -188,62 +130,55 @@ function KeyPageForm({return (<form- className="space-y-2 bg-base-200/40 p-3"+ className="space-y-2 bg-muted/40 p-3"onSubmit={(event) => {event.preventDefault();if (!draft.url.trim() || pending) return;onSave(draft);}}>- <input+ <InputautoFocus- type="text"value={draft.url}onChange={(event) => setDraft({ ...draft, url: event.target.value })}placeholder="example.com/pricing"maxLength={2048}- className="input input-bordered input-sm w-full"aria-label="Page URL"/><div className="grid gap-2 sm:grid-cols-2">- <select+ <Select+ items={roleItems}value={draft.role}- onChange={(event) =>- setDraft({- ...draft,- role:- KEY_PAGE_ROLES.find((role) => role === event.target.value) ??- draft.role,- })- }- className="select select-bordered select-sm w-full"- aria-label="Page role"+ onValueChange={(role) => {+ if (role !== null) setDraft({ ...draft, role });+ }}>- {KEY_PAGE_ROLES.map((role) => (- <option key={role} value={role}>- {ROLE_LABELS[role]}- </option>- ))}- </select>- <input- type="text"+ <SelectTrigger className="w-full" aria-label="Page role">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {KEY_PAGE_ROLES.map((role) => (+ <SelectItem key={role} value={role}>+ {ROLE_LABELS[role]}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <Inputvalue={draft.topic}onChange={(event) =>setDraft({ ...draft, topic: event.target.value })}placeholder="Target topic (optional)"maxLength={200}- className="input input-bordered input-sm w-full"aria-label="Target topic"/></div>- <input- type="text"+ <Inputvalue={draft.notes}onChange={(event) => setDraft({ ...draft, notes: event.target.value })}placeholder="Notes (optional)"maxLength={500}- className="input input-bordered input-sm w-full"aria-label="Page notes"/><FormActionsdiff --git a/src/client/features/projects/project-context/ProjectContextPage.tsx b/src/client/features/projects/project-context/ProjectContextPage.tsxindex c8b5a209..efc3378f 100644--- a/src/client/features/projects/project-context/ProjectContextPage.tsx+++ b/src/client/features/projects/project-context/ProjectContextPage.tsx@@ -23,6 +23,9 @@ import {import { EmptyState } from "@/client/components/EmptyState";import { FormActions } from "@/client/components/FormActions";import { SectionHeader } from "@/client/components/PageHeader";+import { Button } from "@/client/components/ui/button";+import { Input } from "@/client/components/ui/input";+import { Textarea } from "@/client/components/ui/textarea";const SECTION_HINTS: Record<ProjectContextSectionKey, string> = {business_overview: "What you sell, who buys it, and where.",@@ -60,7 +63,7 @@ export function ProjectContextPage({ projectId }: { projectId: string }) {// key remounts the whole page when the project switches under it, so no// draft, open form, or edit state can carry over to another project.<div key={projectId} className="space-y-8">- <p className="text-sm text-base-content/70">+ <p className="text-sm text-muted-foreground">What SAM, Claude Code, and any connected MCP client know about thisproject. They read it before they work and write back what theylearn, so correct anything that looks wrong.@@ -163,18 +166,20 @@ function ProseSections({<div className="flex flex-wrap items-baseline justify-between gap-x-3"><labelhtmlFor={`context-${key}`}- className="text-sm font-medium text-base-content"+ className="text-sm font-medium text-foreground">{PROJECT_CONTEXT_SECTION_LABELS[key]}</label>{section ? (<Provenance by={section.updatedBy} at={section.updatedAt} />) : (- <span className="text-xs text-base-content/40">Empty</span>+ <span className="text-xs text-muted-foreground">Empty</span>)}</div>- <p className="text-xs text-base-content/50">{SECTION_HINTS[key]}</p>- <textarea+ <p className="text-xs text-muted-foreground">+ {SECTION_HINTS[key]}+ </p>+ <Textareaid={`context-${key}`}value={draftOf(key)}onChange={(event) => {@@ -193,20 +198,19 @@ function ProseSections({rows={4}maxLength={PROSE_MAX_CHARS}placeholder={SECTION_PLACEHOLDERS[key]}- className="textarea textarea-bordered w-full text-sm"/></div>);})}<div className="flex justify-end">- <button+ <Buttontype="submit"- className="btn btn-primary btn-sm"+ size="sm"disabled={update.isPending || changed.length === 0}>Save changes- </button>+ </Button></div></form>);@@ -255,7 +259,7 @@ function CustomSections({) : (<divkey={custom.slug}- className="space-y-2 rounded-lg border border-base-300 bg-base-100 p-3"+ className="space-y-2 rounded-lg border border-border bg-card p-3"><div className="flex items-start justify-between gap-3"><div className="min-w-0">@@ -265,14 +269,14 @@ function CustomSections({<Provenance by={custom.updatedBy} at={custom.updatedAt} /></div><RowActions>- <button- type="button"- className="btn btn-ghost btn-xs"+ <Button+ variant="ghost"+ size="icon-xs"aria-label={`Edit ${custom.title ?? custom.slug}`}onClick={() => setEditingSlug(custom.slug)}><Pencil className="size-3.5" />- </button>+ </Button><InlineConfirmlabel={`Delete ${custom.title ?? custom.slug}`}pending={update.isPending}@@ -282,7 +286,7 @@ function CustomSections({/></RowActions></div>- <p className="whitespace-pre-wrap text-sm text-base-content/70">+ <p className="whitespace-pre-wrap text-sm text-muted-foreground">{custom.content}</p></div>@@ -310,28 +314,25 @@ function CustomSectionForm({return (<form- className="space-y-2 rounded-lg border border-base-300 bg-base-200/40 p-3"+ className="space-y-2 rounded-lg border border-border bg-muted/40 p-3"onSubmit={(event) => {event.preventDefault();if (pending || !content.trim()) return;onSave(title.trim() || custom.slug, content);}}>- <input- type="text"+ <Inputvalue={title}onChange={(event) => setTitle(event.target.value)}placeholder={custom.slug}maxLength={120}- className="input input-bordered input-sm w-full"aria-label="Section title"/>- <textarea+ <Textareavalue={content}onChange={(event) => setContent(event.target.value)}rows={5}maxLength={PROSE_MAX_CHARS}- className="textarea textarea-bordered w-full text-sm"aria-label="Section content"/><FormActions@@ -375,8 +376,8 @@ function ResearchLog({className="flex items-start justify-between gap-3 p-3"><div className="min-w-0 space-y-0.5">- <p className="text-sm text-base-content/80">{entry.summary}</p>- <div className="flex flex-wrap items-baseline gap-x-2 text-xs text-base-content/40">+ <p className="text-sm text-foreground">{entry.summary}</p>+ <div className="flex flex-wrap items-baseline gap-x-2 text-xs text-muted-foreground"><span>{entry.entryDate}</span><Provenance by={entry.createdBy} /></div>diff --git a/src/client/features/projects/project-context/shared.tsx b/src/client/features/projects/project-context/shared.tsxindex d3d4ecee..84da079d 100644--- a/src/client/features/projects/project-context/shared.tsx+++ b/src/client/features/projects/project-context/shared.tsx@@ -52,7 +52,7 @@ const AUTHOR_LABELS: Record<ContextAuthor, string> = {export function Provenance({ by, at }: { by: ContextAuthor; at?: string }) {return (- <span className="text-xs text-base-content/40">+ <span className="text-xs text-muted-foreground">{at? `Updated by ${AUTHOR_LABELS[by]} · ${formatRelativeTime(at)}`: `Added by ${AUTHOR_LABELS[by]}`}@@ -61,7 +61,7 @@ export function Provenance({ by, at }: { by: ContextAuthor; at?: string }) {}export const listClass =- "divide-y divide-base-300 overflow-hidden rounded-lg border border-base-300 bg-base-100";+ "divide-y divide-border overflow-hidden rounded-lg border border-border bg-card";/** Row actions and footer buttons shared by the inline competitor/page forms. */export function RowActions({ children }: { children: ReactNode }) {diff --git a/src/client/features/settings/CrawlerAccessSettings.tsx b/src/client/features/settings/CrawlerAccessSettings.tsxindex d1b9f82c..3bb69b3c 100644--- a/src/client/features/settings/CrawlerAccessSettings.tsx+++ b/src/client/features/settings/CrawlerAccessSettings.tsx@@ -11,6 +11,16 @@ import {listCrawlerCredentials,} from "@/serverFunctions/crawlerAccess";import { isCrawlerAccessExpired } from "@/shared/crawler-access";+import { Button } from "@/client/components/ui/button";+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from "@/client/components/ui/table";+import { SectionHeader } from "@/client/components/PageHeader";const formatDate = (value: string) => new Date(value).toLocaleDateString();@@ -43,29 +53,27 @@ export function CrawlerAccessSettings({ projectId }: { projectId: string }) {return (<section className="space-y-3">- <h2 className="text-sm font-medium text-base-content/50">- Crawler access- </h2>+ <SectionHeader title="Crawler access" /><div className="flex items-start justify-between gap-6"><div><p className="text-sm">Let the audit crawler through Shopify</p>- <p className="mt-1 text-sm text-base-content/60">+ <p className="mt-1 text-sm text-muted-foreground">Paste the signature you created in Shopify admin under Online Store→ Preferences → Crawler access. Every audit of that domainin your organization sends it with each request.</p></div>- <button- type="button"- className="btn btn-sm"+ <Button+ variant="outline"+ size="sm"onClick={() => setIsAdding((value) => !value)}>{isAdding ? "Cancel" : "Add signature"}- </button>+ </Button></div>{isAdding && (- <div className="rounded-lg border border-base-300 bg-base-100 p-4">+ <div className="rounded-lg border border-border bg-card p-4"><CrawlerAccessFormprojectId={projectId}initialHost=""@@ -75,52 +83,54 @@ export function CrawlerAccessSettings({ projectId }: { projectId: string }) {)}{credentialsQuery.isError ? (- <p className="text-sm text-error">+ <p className="text-sm text-destructive">We couldn't load your crawler access.</p>) : credentials.length > 0 ? (- <div className="overflow-x-auto rounded-lg border border-base-300 bg-base-100">- <table className="table table-sm">- <thead>- <tr>- <th>Domain</th>- <th>Type</th>- <th>Added</th>- <th>Expires</th>- <th className="w-10"></th>- </tr>- </thead>- <tbody>+ <div className="overflow-hidden rounded-lg border border-border bg-card">+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>Domain</TableHead>+ <TableHead>Type</TableHead>+ <TableHead>Added</TableHead>+ <TableHead>Expires</TableHead>+ <TableHead className="w-10" />+ </TableRow>+ </TableHeader>+ <TableBody>{credentials.map((credential) => (- <tr key={credential.id} className="hover">- <td className="font-mono">{credential.host}</td>- <td className="text-base-content/70">Shopify signature</td>- <td className="text-base-content/70">+ <TableRow key={credential.id}>+ <TableCell className="font-mono">{credential.host}</TableCell>+ <TableCell className="text-muted-foreground">+ Shopify signature+ </TableCell>+ <TableCell className="text-muted-foreground">{formatDate(credential.createdAt)}- </td>- <td className="text-base-content/70">+ </TableCell>+ <TableCell className="text-muted-foreground">{credential.expiresAt? formatDate(credential.expiresAt): "Unknown"}{isCrawlerAccessExpired(credential.expiresAt) && (- <span className="ml-2 text-error">Expired</span>+ <span className="ml-2 text-destructive">Expired</span>)}- </td>- <td>- <button- type="button"- className="btn btn-ghost btn-xs"+ </TableCell>+ <TableCell>+ <Button+ variant="ghost"+ size="icon-xs"aria-label={`Remove crawler access for ${credential.host}`}disabled={deleteMutation.isPending}onClick={() => deleteMutation.mutate(credential.id)}><Trash2 className="size-4" />- </button>- </td>- </tr>+ </Button>+ </TableCell>+ </TableRow>))}- </tbody>- </table>+ </TableBody>+ </Table></div>) : null}</section>diff --git a/src/routes/_app/p/$projectId/context.tsx b/src/routes/_app/p/$projectId/context.tsxindex fe5c8b35..ed5bbb20 100644--- a/src/routes/_app/p/$projectId/context.tsx+++ b/src/routes/_app/p/$projectId/context.tsx@@ -1,7 +1,5 @@import { createFileRoute } from "@tanstack/react-router";-import { projectsQueryOptions } from "@/client/features/projects/projectQueries";-import { useQuery } from "@tanstack/react-query";-import { PageHeader } from "@/client/components/PageHeader";+import { ProjectPageHeader } from "@/client/features/projects/ProjectPageHeader";import { ProjectContextPage } from "@/client/features/projects/project-context/ProjectContextPage";export const Route = createFileRoute("/_app/p/$projectId/context")({@@ -10,13 +8,10 @@ export const Route = createFileRoute("/_app/p/$projectId/context")({function ProjectContextRoute() {const { projectId } = Route.useParams();- const projectsQuery = useQuery(projectsQueryOptions());- const project = projectsQuery.data?.find((entry) => entry.id === projectId);-return (<div className="h-full overflow-auto"><div className="mx-auto w-full max-w-2xl space-y-8 p-4 py-8 pb-24 sm:p-6 md:py-12 md:pb-12">- <PageHeader title="Context" description={project?.name ?? " "} />+ <ProjectPageHeader projectId={projectId} title="Context" /><ProjectContextPage projectId={projectId} /></div>diff --git a/src/routes/_app/p/$projectId/settings.tsx b/src/routes/_app/p/$projectId/settings.tsxindex 5413fd61..317acac7 100644--- a/src/routes/_app/p/$projectId/settings.tsx+++ b/src/routes/_app/p/$projectId/settings.tsx@@ -1,44 +1,24 @@import { createFileRoute, Outlet } from "@tanstack/react-router";-import { NavTab, NavTabs } from "@/client/components/NavTabs";-import { projectsQueryOptions } from "@/client/features/projects/projectQueries";-import { useQuery } from "@tanstack/react-query";-import { BackLink, PageHeader } from "@/client/components/PageHeader";+import { ProjectPageHeader } from "@/client/features/projects/ProjectPageHeader";+import { SettingsTabs } from "@/client/features/projects/SettingsTabs";export const Route = createFileRoute("/_app/p/$projectId/settings")({component: ProjectSettingsLayout,});-const tabs = [- { to: "/p/$projectId/settings" as const, label: "General", exact: true },- { to: "/p/$projectId/settings/integrations" as const, label: "Integrations" },-];-function ProjectSettingsLayout() {const { projectId } = Route.useParams();- const projectsQuery = useQuery(projectsQueryOptions());- const project = projectsQuery.data?.find((entry) => entry.id === projectId);return (<div className="h-full overflow-auto"><div className="mx-auto w-full max-w-2xl space-y-8 p-4 py-8 pb-24 sm:p-6 md:py-12 md:pb-12"><div className="space-y-4">- <BackLink to="/projects">Projects</BackLink>- <PageHeader+ <ProjectPageHeader+ projectId={projectId}title="Project settings"- description={project?.name ?? " "}+ showBackLink/>- <NavTabs label="Project settings sections">- {tabs.map((tab) => (- <NavTab- key={tab.to}- to={tab.to}- params={{ projectId }}- activeOptions={{ exact: tab.exact ?? false }}- >- {tab.label}- </NavTab>- ))}- </NavTabs>+ <SettingsTabs projectId={projectId} /></div><Outlet />