Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(content-editor): ask regulated pages for a qualified reviewer, from Authors (00273, CE-049, part e) (#1476)

Cihan8cb526717b8f
diff --git a/supabase/migrations/00273_content_draft_reviewer.sql b/supabase/migrations/00273_content_draft_reviewer.sql
new file mode 100644
index 000000000..6485c06f5
--- /dev/null
+++ b/supabase/migrations/00273_content_draft_reviewer.sql
@@ -0,0 +1,51 @@
+-- ============================================================================
+-- 00273: Quality CE-049 — a qualified reviewer for regulated pages
+-- ============================================================================
+-- A consumer page that advises on health, finance or law (the page read's
+-- `regulated`, 00270) asks for a qualified reviewer: "Reviewed by {name,
+-- credential}", from Authors only (Quality spec §4b). Like the author
+-- (00257), it is page metadata: the editor shows it outside the page,
+-- never in the page's text.
+--
+-- * content_drafts.reviewer_id: one of the brand's organization's authors,
+-- else null.
+
+alter table public.content_drafts
+ add column if not exists reviewer_id uuid
+ references public.content_authors(id) on delete set null;
+
+create index if not exists content_drafts_reviewer
+ on public.content_drafts (reviewer_id)
+ where reviewer_id is not null;
+
+comment on column public.content_drafts.reviewer_id is
+ 'Quality CE-049 (00273): the qualified person who reviewed a regulated page (content_authors), page metadata — never the page''s text; null when none.';
+
+create or replace function public.content_draft_reviewer()
+returns trigger
+language plpgsql
+set search_path = ''
+as $$
+begin
+ if new.reviewer_id is not null
+ and (tg_op = 'INSERT' or new.reviewer_id is distinct from old.reviewer_id)
+ and not exists (
+ select 1
+ from public.content_authors a
+ join public.brands b on b.organization_id = a.organization_id
+ where a.id = new.reviewer_id and b.id = new.brand_id
+ )
+ then
+ raise exception 'content draft reviewer is not one of the brand''s organization'
+ using errcode = '23514';
+ end if;
+ return new;
+end;
+$$;
+
+drop trigger if exists content_drafts_reviewer on public.content_drafts;
+create trigger content_drafts_reviewer
+ before insert or update of reviewer_id on public.content_drafts
+ for each row execute function public.content_draft_reviewer();
+
+notify pgrst, 'reload schema';
diff --git a/supabase/schema.sql b/supabase/schema.sql
index 739d5a030..27fe8b5a4 100644
--- a/supabase/schema.sql
+++ b/supabase/schema.sql
@@ -39238,6 +39238,61 @@ comment on table public.content_image_uploads is
notify pgrst, 'reload schema';
+-- ─────────────────────────────────────────────────────────────────────────
+-- migrations/00273_content_draft_reviewer.sql
+-- ─────────────────────────────────────────────────────────────────────────
+-- ============================================================================
+-- 00273: Quality CE-049 — a qualified reviewer for regulated pages
+-- ============================================================================
+-- A consumer page that advises on health, finance or law (the page read's
+-- `regulated`, 00270) asks for a qualified reviewer: "Reviewed by {name,
+-- credential}", from Authors only (Quality spec §4b). Like the author
+-- (00257), it is page metadata: the editor shows it outside the page,
+-- never in the page's text.
+--
+-- * content_drafts.reviewer_id: one of the brand's organization's authors,
+-- else null.
+
+alter table public.content_drafts
+ add column if not exists reviewer_id uuid
+ references public.content_authors(id) on delete set null;
+
+create index if not exists content_drafts_reviewer
+ on public.content_drafts (reviewer_id)
+ where reviewer_id is not null;
+
+comment on column public.content_drafts.reviewer_id is
+ 'Quality CE-049 (00273): the qualified person who reviewed a regulated page (content_authors), page metadata — never the page''s text; null when none.';
+
+create or replace function public.content_draft_reviewer()
+returns trigger
+language plpgsql
+set search_path = ''
+as $$
+begin
+ if new.reviewer_id is not null
+ and (tg_op = 'INSERT' or new.reviewer_id is distinct from old.reviewer_id)
+ and not exists (
+ select 1
+ from public.content_authors a
+ join public.brands b on b.organization_id = a.organization_id
+ where a.id = new.reviewer_id and b.id = new.brand_id
+ )
+ then
+ raise exception 'content draft reviewer is not one of the brand''s organization'
+ using errcode = '23514';
+ end if;
+ return new;
+end;
+$$;
+
+drop trigger if exists content_drafts_reviewer on public.content_drafts;
+create trigger content_drafts_reviewer
+ before insert or update of reviewer_id on public.content_drafts
+ for each row execute function public.content_draft_reviewer();
+
+notify pgrst, 'reload schema';
+
-- ─────────────────────────────────────────────────────────────────────────
-- migrations/00276_organization_insert_columns.sql
-- ─────────────────────────────────────────────────────────────────────────
diff --git a/web/messages/en.json b/web/messages/en.json
index 169fb0650..8661b9979 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -4329,6 +4329,18 @@
},
"rulesChip": "Rules {met}/{total}",
"rulesChipHint": "Rules this page meets now. Open the Rules tab.",
+ "reviewer": {
+ "title": "Reviewed by",
+ "add": "Add reviewer",
+ "by": "Reviewed by {name}",
+ "byTitle": "Reviewed by {name}, {title}",
+ "change": "Reviewed by {name}: change the reviewer",
+ "hint": "A page that advises on health, money or the law names the qualified person who reviewed it. Page info, not the page's text.",
+ "none": "No reviewer",
+ "qualified": "Qualified people only, from your authors: their title is the credential.",
+ "manage": "Manage authors",
+ "failed": "Couldn't set the reviewer. Try again."
+ },
"author": {
"by": "By {name}",
"change": "By {name}: change who the page is by",
@@ -4701,6 +4713,15 @@
"detail": "Prices, your trial and other facts read from your own site: the page is checked against the ones you approve",
"done": "Your brand facts are reviewed"
},
+ "reviewer": {
+ "title": "Add a qualified reviewer",
+ "next": "add a qualified reviewer",
+ "detail": {
+ "pick": "{topic, select, health {The page advises readers on their health} finance {The page advises readers on their money} other {The page advises readers on a legal matter}}: name the qualified person who reviewed it (their title is the credential)",
+ "addAuthor": "{topic, select, health {The page advises readers on their health} finance {The page advises readers on their money} other {The page advises readers on a legal matter}}: add the qualified person who reviewed it in Settings › Authors, with their credential as the title"
+ },
+ "done": "A qualified reviewer is named"
+ },
"visualProof": {
"title": "Show your own image",
"next": "show your own image",
@@ -4789,6 +4810,7 @@
"reviewBrandFacts": "Review now",
"addProof": "Add now",
"confirmImage": "Confirm now",
+ "pickReviewer": "Pick now",
"addImage": "Add now"
},
"later": "Later"
@@ -4808,6 +4830,7 @@
"addProof": "Add proof link",
"addProofFor": "Add a proof link to “{claim}”",
"confirmImage": "Confirm",
+ "pickReviewer": "Pick reviewer",
"addImage": "Add image",
"confirmImageFailed": "Couldn't save that. Try again.",
"confirmImageFull": "This page keeps 50 confirmed images already.",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
index d884c5822..7acd61f9b 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
@@ -41,6 +41,7 @@ import {
unmarkContentDraftReady,
restoreDraftVersion,
setContentDraftAuthor,
+ setContentDraftReviewer,
confirmDraftAuthor,
keepDraftSource,
confirmOwnImage,
@@ -137,6 +138,7 @@ import { useBrandStore } from '@/stores/use-brand-store';
import { AgentCard } from './_agent-card';
import { AgentDrafting, draftingKey } from './_agent-drafting';
import { AuthorMenu, MANAGE_AUTHORS_PATH } from './_author-menu';
+import { ReviewerMenu } from './_reviewer-menu';
import { BeforePublish, TRUST_GATE, type ReadyAnyway, type ReadyToPaste } from './_before-publish';
import { FlashBlock, findBlock, flashKey } from './_flash-block';
import { useAgentRun } from './_use-agent-run';
@@ -548,6 +550,8 @@ export function DraftEditor({
// Read, or failed to: the header's score waits for it either way.
const [authorsTried, setAuthorsTried] = useState(false);
const [authorId, setAuthorId] = useState(draft.authorId);
+ // The qualified reviewer of a page that advises on health, finance or law (CE-049).
+ const [reviewerId, setReviewerId] = useState(draft.reviewerId);
// The author the database holds, and the latest pick: a slower pick that
// fails after a later one landed doesn't roll the menu back.
const savedAuthor = useRef(draft.authorId);
@@ -746,6 +750,10 @@ export function DraftEditor({
authorConfirmed,
],
);
+ // A page that advises consumers on health, finance or law (the page's read)
+ // asks for a qualified reviewer, one of Authors.
+ const regulated = sourcesOn ? (pageRead.read?.regulated ?? null) : null;
+ const pageReviewer = authorsRead?.authors.find((a) => a.id === reviewerId) ?? null;
// Confirm: only the person can tell their own image from stock.
const [confirmingImages, setConfirmingImages] = useState(false);
const confirmImage = async (src: string) => {
@@ -936,6 +944,8 @@ export function DraftEditor({
brandFacts: brandFacts ? { pending: pendingFacts, had: hadPendingFacts } : null,
proofs: sourcesOn ? { asks: proofAsks, had: hadProofs } : null,
visual,
+ // Once the authors are read: who the reviewer is, and whether any can be.
+ reviewer: regulated && authorsRead ? { topic: regulated, picked: !!pageReviewer } : null,
confirmed: authorConfirmed,
})
: [];
@@ -967,6 +977,24 @@ export function DraftEditor({
: null;
// Quality's Pick author opens the header's menu.
const [authorMenuOpen, setAuthorMenuOpen] = useState(false);
+ // Quality's Pick reviewer opens its menu beside the author's (CE-049).
+ const [reviewerMenuOpen, setReviewerMenuOpen] = useState(false);
+ // As the author's: a slower pick that fails after a later one landed doesn't roll it back.
+ const savedReviewer = useRef(draft.reviewerId);
+ const reviewerPick = useRef(0);
+ const pickReviewer = async (next: string | null) => {
+ if (next === reviewerId) return;
+ const pick = ++reviewerPick.current;
+ setReviewerId(next);
+ try {
+ await setContentDraftReviewer(draft.id, next);
+ savedReviewer.current = next;
+ } catch (err) {
+ console.error('Failed to set the reviewer:', err);
+ if (pick === reviewerPick.current) setReviewerId(savedReviewer.current);
+ toast.error(t('reviewer.failed'));
+ }
+ };
// Quality's Add opens Brief › Your input.
const addInput = () => {
if (!panelOpen) togglePanel();
@@ -1028,6 +1056,10 @@ export function DraftEditor({
name: pageAuthor?.name ?? t('author.organization', { brand: brandName }),
}),
pageAuthor?.title && t('author.titleAt', { title: pageAuthor.title, brand: brandName }),
+ pageReviewer &&
+ (pageReviewer.title
+ ? t('reviewer.byTitle', { name: pageReviewer.name, title: pageReviewer.title })
+ : t('reviewer.by', { name: pageReviewer.name })),
t('author.updated', {
date: format.dateTime(
Math.max(
@@ -2652,6 +2684,15 @@ export function DraftEditor({
inContent={bylineInContent}
/>
)}
+ {authorsRead && (regulated || pageReviewer) && (
+ <ReviewerMenu
+ authors={authorsRead.authors}
+ reviewerId={pageReviewer?.id ?? null}
+ onPick={(next) => void pickReviewer(next)}
+ open={reviewerMenuOpen}
+ onOpenChange={setReviewerMenuOpen}
+ />
+ )}
<DraftMethodBadge method={draft.method} />
<DraftStatusBadge status={status} />
<button
@@ -2894,6 +2935,7 @@ export function DraftEditor({
quality={quality}
onShowPlaceholder={showFirstPlaceholder}
onPickAuthor={() => setAuthorMenuOpen(true)}
+ onPickReviewer={() => setReviewerMenuOpen(true)}
onAddInput={addInput}
onAddSource={sourcesOn ? addSource : undefined}
onConfirmImages={() => setConfirmingImages(true)}
@@ -2935,6 +2977,7 @@ export function DraftEditor({
onShowInPage={showInPage}
onShowPlaceholder={showFirstPlaceholder}
onPickAuthor={() => setAuthorMenuOpen(true)}
+ onPickReviewer={() => setReviewerMenuOpen(true)}
yourInput={inputsRead.status === 'off' ? null : inputsRead}
onAddInput={addInput}
onConfirmAuthor={confirmAuthor}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.test.tsx
index e3e30e817..103419936 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.test.tsx
@@ -57,6 +57,7 @@ const onPickAuthor = vi.fn();
const onShowPlaceholder = vi.fn();
const onAddSource = vi.fn();
const onConfirmImages = vi.fn();
+const onPickReviewer = vi.fn();
const MOMENTS: NudgeMoment[] = ['agent', 'acceptAll', 'markReady'];
/** The editor's part: the hook, a button per moment, and the nudge while it shows. */
@@ -79,6 +80,7 @@ function Harness({ todos, author }: { todos: QualityTodo[]; author: ContentAutho
onPickAuthor={onPickAuthor}
onAddSource={onAddSource}
onConfirmImages={onConfirmImages}
+ onPickReviewer={onPickReviewer}
onLater={nudge.later}
onAct={nudge.close}
/>
@@ -203,6 +205,26 @@ describe('NextNudge', () => {
expect(onConfirmImages).toHaveBeenCalled();
});
+ it('opens the reviewer menu for a regulated page (CE-049, part e)', async () => {
+ onPickReviewer.mockReset();
+ await render([
+ {
+ id: 'reviewer',
+ done: false,
+ gain: 0,
+ score: 'eeat',
+ action: 'pickReviewer',
+ topic: 'legal',
+ },
+ ]);
+ await act(async () => nudgeAt('agent'));
+ expect(nudge()!.textContent).toBe(
+ 'Next for you: add a qualified reviewer · 1 of 1Pick nowLater',
+ );
+ await act(async () => button('Pick now').click());
+ expect(onPickReviewer).toHaveBeenCalled();
+ });
+
it('counts the open ones and skips the done', async () => {
await render([{ ...pick, done: true }, profile], ada);
await act(async () => nudgeAt('markReady'));
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.tsx
index 2b1357547..6f26f9f28 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.tsx
@@ -94,6 +94,7 @@ export function NextNudge({
onAddSource,
onConfirmImages,
onAddImage,
+ onPickReviewer,
onLater,
onAct,
}: {
@@ -110,6 +111,8 @@ export function NextNudge({
/** Visual proof's: Confirm, or the first open spot's Add image (CE-049). */
onConfirmImages?: () => void;
onAddImage?: () => void;
+ /** A regulated page's: the header's reviewer menu (CE-049). */
+ onPickReviewer?: () => void;
onLater: () => void;
/** It was acted on: it goes. */
onAct: () => void;
@@ -204,6 +207,19 @@ export function NextNudge({
{t(`act.${action}`)}
</button>
)
+ ) : action === 'pickReviewer' ? (
+ onPickReviewer && (
+ <button
+ type="button"
+ className={actClass}
+ onClick={() => {
+ onAct();
+ onPickReviewer();
+ }}
+ >
+ {t('act.pickReviewer')}
+ </button>
+ )
) : action === 'reviewBrandFacts' ? (
quality.brandFactsPath && (
<Link href={quality.brandFactsPath} className={actClass} onClick={onAct}>
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx
index 1eb9dfead..3132038e9 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx
@@ -94,6 +94,7 @@ const onKeep = vi.fn();
const onAddSource = vi.fn();
const onConfirmImages = vi.fn();
const onAddImage = vi.fn();
+const onPickReviewer = vi.fn();
const onConfirmAuthor = vi.fn();
async function render(quality: QualityRead | Readability | null) {
@@ -111,6 +112,7 @@ async function render(quality: QualityRead | Readability | null) {
onAddSource={onAddSource}
onConfirmImages={onConfirmImages}
onAddImage={onAddImage}
+ onPickReviewer={onPickReviewer}
onConfirmAuthor={onConfirmAuthor}
/>
</NextIntlClientProvider>,
@@ -663,6 +665,29 @@ describe('QualityTab', () => {
expect(onAddImage).toHaveBeenCalled();
});
+ it('asks for a qualified reviewer, and opens their menu (CE-049, part e)', async () => {
+ onPickReviewer.mockReset();
+ const score = eeat({ author: ada });
+ await render({
+ ...read(null),
+ eeat: score,
+ todos: qualityTodos({
+ eeat: score,
+ author: ada,
+ hasAuthors: true,
+ reviewer: { topic: 'finance', picked: false },
+ }),
+ });
+ const row = [...container.querySelectorAll('[aria-label="Your to-dos"] li')].find((li) =>
+ li.textContent?.startsWith('Add a qualified reviewer'),
+ )!;
+ expect(row.textContent).toContain(
+ 'The page advises readers on their money: name the qualified person who reviewed it',
+ );
+ await act(async () => row.querySelector('button')!.click());
+ expect(onPickReviewer).toHaveBeenCalled();
+ });
+
it("shows the site's trust, what is missing and the way to Site Audit", async () => {
const siteTrust = {
checks: {
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsx
index d802511a4..6da59f575 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsx
@@ -114,6 +114,7 @@ export function QualityTab({
onRemove,
onConfirmImages,
onAddImage,
+ onPickReviewer,
onConfirmAuthor,
}: {
quality: QualityRead;
@@ -137,6 +138,8 @@ export function QualityTab({
onConfirmImages?: () => void;
/** Opens the first open visual proof spot's Add image (CE-049). */
onAddImage?: () => void;
+ /** Opens the header's reviewer menu (CE-049). */
+ onPickReviewer?: () => void;
}) {
const t = useTranslations('contentEditor.editor.quality');
const tSite = useTranslations('audit.siteTrust.checks');
@@ -211,6 +214,7 @@ export function QualityTab({
onAddSource={onAddSource}
onConfirmImages={onConfirmImages}
onAddImage={onAddImage}
+ onPickReviewer={onPickReviewer}
onConfirm={onConfirmAuthor}
/>
))}
@@ -395,6 +399,19 @@ export function useTodoCopy() {
detail: todo.done ? t('brandFacts.done') : t('brandFacts.detail'),
};
}
+ // A qualified reviewer for a page that advises on health, finance or law (CE-049).
+ if (todo.id === 'reviewer') {
+ const topic = todo.topic ?? 'health';
+ return {
+ title: t('reviewer.title'),
+ next: t('reviewer.next'),
+ detail: todo.done
+ ? t('reviewer.done')
+ : todo.action === 'addAuthor'
+ ? t('reviewer.detail.addAuthor', { topic })
+ : t('reviewer.detail.pick', { topic }),
+ };
+ }
// An image the person took themself (CE-049).
if (todo.id === 'visualProof') {
const count = todo.count ?? 0;
@@ -463,6 +480,7 @@ function TodoRow({
onAddSource,
onConfirmImages,
onAddImage,
+ onPickReviewer,
onConfirm,
}: {
todo: QualityTodo;
@@ -474,6 +492,7 @@ function TodoRow({
onAddSource?: (claim: ClaimMark) => void;
onConfirmImages?: () => void;
onAddImage?: () => void;
+ onPickReviewer?: () => void;
onConfirm?: (what: 'real' | 'profile', on: boolean) => void;
}) {
const t = useTranslations('contentEditor.editor.quality');
@@ -590,6 +609,12 @@ function TodoRow({
{t('addImage')}
</Button>
)
+ ) : todo.action === 'pickReviewer' ? (
+ onPickReviewer && (
+ <Button variant="outline" size="sm" className="h-7 shrink-0" onClick={onPickReviewer}>
+ {t('pickReviewer')}
+ </Button>
+ )
) : todo.action === 'reviewBrandFacts' ? (
quality.brandFactsPath && (
<Link
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_reviewer-menu.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_reviewer-menu.test.tsx
new file mode 100644
index 000000000..86ff47e0b
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_reviewer-menu.test.tsx
@@ -0,0 +1,91 @@
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { NextIntlClientProvider } from 'next-intl';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import messages from '../../../../../../../../messages/en.json';
+import type { ContentAuthor } from '@/lib/content/authors';
+
+vi.mock('@/i18n/navigation', () => ({
+ Link: ({ href, ...props }: { href: string } & Record<string, unknown>) => (
+ <a href={href} {...props} />
+ ),
+}));
+
+const { ReviewerMenu } = await import('./_reviewer-menu');
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =
+ true;
+
+const author = (over: Partial<ContentAuthor>): ContentAuthor => ({
+ id: 'a1',
+ name: 'Ada Lovelace',
+ title: 'Head of Content',
+ bio: null,
+ photoUrl: null,
+ sameAs: [],
+ userId: null,
+ createdBy: null,
+ defaultFor: [],
+ pages: 0,
+ ...over,
+});
+const AUTHORS = [
+ author({ defaultFor: ['b1'] }),
+ author({ id: 'a2', name: 'Bob Stone', title: null }),
+];
+
+let container: HTMLDivElement;
+let root: Root;
+const onPick = vi.fn();
+
+beforeEach(() => {
+ onPick.mockReset();
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+});
+
+afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+ document.body.replaceChildren();
+});
+
+async function render(reviewerId: string | null) {
+ await act(async () => {
+ root.render(
+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">
+ <ReviewerMenu authors={AUTHORS} reviewerId={reviewerId} onPick={onPick} />
+ </NextIntlClientProvider>,
+ );
+ });
+}
+
+const trigger = () => container.querySelector<HTMLElement>('button')!;
+const items = () => [...document.querySelectorAll<HTMLElement>('[role="menuitemradio"]')];
+const click = (el: Element | undefined) => act(async () => void (el as HTMLElement).click());
+
+/** Who reviewed a page that advises on health, money or the law (CE-049). */
+describe('ReviewerMenu', () => {
+ it('asks for a reviewer, then names them; their title is the credential', async () => {
+ await render(null);
+ expect(trigger().textContent).toBe('Add reviewer');
+ await click(trigger());
+ expect(items().map((i) => i.textContent)).toEqual([
+ 'Ada LovelaceHead of Content',
+ 'Bob Stone',
+ 'No reviewer',
+ ]);
+ expect(document.body.textContent).toContain(
+ 'Qualified people only, from your authors: their title is the credential.',
+ );
+ await click(items()[0]);
+ expect(onPick).toHaveBeenLastCalledWith('a1');
+
+ await render('a1');
+ expect(trigger().textContent).toBe('Reviewed by Ada Lovelace');
+ await click(trigger());
+ await click(items()[2]);
+ expect(onPick).toHaveBeenLastCalledWith(null);
+ });
+});
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_reviewer-menu.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_reviewer-menu.tsx
new file mode 100644
index 000000000..f0636c3e8
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_reviewer-menu.tsx
@@ -0,0 +1,94 @@
+'use client';
+
+import { useTranslations } from 'next-intl';
+import { ChevronDown, Settings } from 'lucide-react';
+import { Link } from '@/i18n/navigation';
+import { badgeVariants } from '@/components/ui/badge';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuGroup,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import type { ContentAuthor } from '@/lib/content/authors';
+import { cn } from '@/lib/utils';
+import { MANAGE_AUTHORS_PATH } from './_author-menu';
+
+/** No reviewer in the menu. */
+const NONE = 'none';
+
+/**
+ * Who reviewed a page that advises on health, finance or law (Quality spec
+ * §4b, CE-049): "Reviewed by {name} ▾", a qualified person from Authors
+ * (their title is the credential), or none. Page metadata beside the
+ * author: the page's text never names them.
+ */
+export function ReviewerMenu({
+ authors,
+ reviewerId,
+ onPick,
+ open,
+ onOpenChange,
+}: {
+ authors: ContentAuthor[];
+ reviewerId: string | null;
+ onPick: (reviewerId: string | null) => void;
+ /** Open from outside too: Quality's Pick reviewer. */
+ open?: boolean;
+ onOpenChange?: (open: boolean) => void;
+}) {
+ const t = useTranslations('contentEditor.editor.reviewer');
+ const reviewer = authors.find((a) => a.id === reviewerId) ?? null;
+
+ return (
+ <DropdownMenu open={open} onOpenChange={(next) => onOpenChange?.(next)}>
+ <DropdownMenuTrigger
+ aria-label={reviewer ? t('change', { name: reviewer.name }) : t('add')}
+ title={t('hint')}
+ className={cn(
+ badgeVariants({ variant: 'outline' }),
+ 'max-w-56 cursor-pointer gap-1 font-normal hover:bg-muted',
+ !reviewer &&
+ 'border-amber-200 bg-amber-50 text-amber-800 hover:bg-amber-100 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300 dark:hover:bg-amber-900',
+ )}
+ >
+ <span className="truncate">{reviewer ? t('by', { name: reviewer.name }) : t('add')}</span>
+ <ChevronDown className="h-3 w-3 shrink-0 opacity-60" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="w-72">
+ <DropdownMenuGroup>
+ <DropdownMenuLabel>{t('title')}</DropdownMenuLabel>
+ <DropdownMenuRadioGroup
+ value={reviewer?.id ?? NONE}
+ onValueChange={(value) => onPick(value === NONE ? null : value)}
+ >
+ {authors.map((a) => (
+ <DropdownMenuRadioItem key={a.id} value={a.id} closeOnClick>
+ <span className="min-w-0">
+ <span className="block truncate">{a.name}</span>
+ {a.title && (
+ <span className="block truncate text-xs text-muted-foreground">{a.title}</span>
+ )}
+ </span>
+ </DropdownMenuRadioItem>
+ ))}
+ <DropdownMenuRadioItem value={NONE} closeOnClick>
+ {t('none')}
+ </DropdownMenuRadioItem>
+ </DropdownMenuRadioGroup>
+ </DropdownMenuGroup>
+ <DropdownMenuSeparator />
+ <p className="px-1.5 py-1 text-xs text-muted-foreground">{t('qualified')}</p>
+ <DropdownMenuItem render={<Link href={MANAGE_AUTHORS_PATH} />} className="text-xs">
+ <Settings className="h-3.5 w-3.5" />
+ {t('manage')}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx
index 2d9358ce6..7cde5dbe8 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx
@@ -138,6 +138,7 @@ export function EditorSidePanel({
onRemoveClaim,
onConfirmImages,
onAddImage,
+ onPickReviewer,
}: {
draft: ContentDraft;
/** The brand's business type as the editor holds it (Quality CE-056). */
@@ -204,6 +205,8 @@ export function EditorSidePanel({
/** Quality's visual proof (CE-049): Confirm the page's images, or Add image at a spot. */
onConfirmImages?: () => void;
onAddImage?: () => void;
+ /** Quality's Pick reviewer: the header's reviewer menu (CE-049). */
+ onPickReviewer?: () => void;
}) {
const t = useTranslations('contentEditor.editor.panel');
const tEditor = useTranslations('contentEditor.editor');
@@ -455,6 +458,7 @@ export function EditorSidePanel({
onRemove={onRemoveClaim}
onConfirmImages={onConfirmImages}
onAddImage={onAddImage}
+ onPickReviewer={onPickReviewer}
/>
</div>
)}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
index d2fadb21f..42a804160 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
@@ -19,6 +19,7 @@ const unmarkContentDraftReady = vi.fn();
const saveContentDraft = vi.fn();
const setContentDraftPageType = vi.fn();
const setContentDraftAuthor = vi.fn();
+const setContentDraftReviewer = vi.fn();
const keepDraftSource = vi.fn();
const confirmDraftAuthor = vi.fn();
const checkDraftClaims = vi.fn();
@@ -93,6 +94,7 @@ vi.mock('@/lib/actions/content-drafts', () => ({
saveContentDraft: (...args: unknown[]) => saveContentDraft(...args),
setContentDraftPageType: (...args: unknown[]) => setContentDraftPageType(...args),
setContentDraftAuthor: (...args: unknown[]) => setContentDraftAuthor(...args),
+ setContentDraftReviewer: (...args: unknown[]) => setContentDraftReviewer(...args),
keepDraftSource: (...args: unknown[]) => keepDraftSource(...args),
confirmDraftAuthor: (...args: unknown[]) => confirmDraftAuthor(...args),
checkDraftClaims: (...args: unknown[]) => checkDraftClaims(...args),
@@ -220,6 +222,7 @@ const draft = (over: Partial<ContentDraft> = {}): ContentDraft => ({
bodyHtml: '<h1>Pipeline forecasting</h1><p>Teams trust it.</p>',
author: 'agent',
authorId: null,
+ reviewerId: null,
rules: { set: null, source: null, overrides: {}, textRules: [] },
keptSources: [],
authorConfirmed: { real: false, profile: false },
@@ -297,6 +300,7 @@ beforeEach(() => {
saveBlob.mockReset();
setContentDraftPageType.mockReset().mockResolvedValue(undefined);
setContentDraftAuthor.mockReset().mockResolvedValue(undefined);
+ setContentDraftReviewer.mockReset().mockResolvedValue(undefined);
keepDraftSource.mockReset();
confirmDraftAuthor.mockReset().mockResolvedValue(undefined);
checkDraftClaims.mockReset().mockResolvedValue({ blocks: [], pending: 0, limited: false });
@@ -3208,6 +3212,71 @@ describe('the side panel', () => {
expect(box.getAttribute('aria-checked')).toBe('false');
});
+ it('asks a page that advises on health for a qualified reviewer, and names them (CE-049, part e)', async () => {
+ process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '2';
+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });
+ getContentAuthors.mockResolvedValue({
+ authors: [
+ {
+ id: 'a1',
+ name: 'Dr. Ada Lovelace',
+ title: 'MD, Cardiologist',
+ bio: null,
+ photoUrl: null,
+ sameAs: [],
+ userId: null,
+ createdBy: null,
+ defaultFor: [],
+ pages: null,
+ },
+ ],
+ brands: [{ id: 'b1', name: 'Acme' }],
+ me: { id: 'u1', role: 'admin' },
+ });
+ readDraftPage.mockResolvedValue({
+ spots: [],
+ proofs: [],
+ regulated: 'health',
+ pending: false,
+ limited: false,
+ paused: false,
+ });
+ getContentDraft.mockResolvedValue(claimed);
+ window.innerWidth = 1440;
+ await renderPage();
+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));
+ const reviewerButton = () =>
+ [...container.querySelectorAll<HTMLButtonElement>('header button')].find((b) =>
+ /^(Add reviewer|Reviewed by)/.test(b.textContent ?? ''),
+ )!;
+ expect(reviewerButton().textContent).toBe('Add reviewer');
+ await act(async () => reviewerButton().click());
+ const item = [...document.querySelectorAll<HTMLElement>('[role="menuitemradio"]')].find((i) =>
+ i.textContent?.startsWith('Dr. Ada Lovelace'),
+ )!;
+ await act(async () => item.click());
+ expect(setContentDraftReviewer).toHaveBeenCalledWith('d1', 'a1');
+ expect(reviewerButton().textContent).toBe('Reviewed by Dr. Ada Lovelace');
+ // In the Page info strip, outside the page.
+ expect(container.querySelector('[data-page-info]')!.textContent).toContain(
+ 'Reviewed by Dr. Ada Lovelace, MD, Cardiologist',
+ );
+ // A save that fails puts back the reviewer saved, and says so.
+ vi.spyOn(console, 'error').mockImplementation(() => {});
+ try {
+ setContentDraftReviewer.mockRejectedValueOnce(new Error('offline'));
+ await act(async () => reviewerButton().click());
+ const none = [...document.querySelectorAll<HTMLElement>('[role="menuitemradio"]')].find(
+ (i) => i.textContent === 'No reviewer',
+ )!;
+ await act(async () => none.click());
+ expect(toast.error).toHaveBeenCalledWith("Couldn't set the reviewer. Try again.");
+ expect(reviewerButton().textContent).toBe('Reviewed by Dr. Ada Lovelace');
+ } finally {
+ vi.mocked(console.error).mockRestore();
+ }
+ });
+
it('holds the score for the visual proof when the claims land first, and scores without the own images when they can’t be read (review, #1475)', async () => {
process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '2';
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });
diff --git a/web/src/lib/actions/content-drafts.test.ts b/web/src/lib/actions/content-drafts.test.ts
index ef3e0c7d3..79131c063 100644
--- a/web/src/lib/actions/content-drafts.test.ts
+++ b/web/src/lib/actions/content-drafts.test.ts
@@ -108,6 +108,7 @@ const {
unmarkContentDraftReady,
confirmOwnImage,
getOwnImages,
+ setContentDraftReviewer,
} = await import('./content-drafts');
const { bodyHash } = await import('@/lib/content/editor');
@@ -363,6 +364,23 @@ describe('setContentDraftAuthor', () => {
});
});
+describe('setContentDraftReviewer (Quality CE-049, 00273)', () => {
+ const REVIEWER = '7c9e6679-7425-40de-944b-e07fc1f90ae7';
+
+ it('sets the qualified reviewer, or none; refuses an id that is not one', async () => {
+ updated = { id: DRAFT };
+ await setContentDraftReviewer(DRAFT, REVIEWER);
+ expect(calls[0]).toMatchObject({
+ op: 'update',
+ value: { reviewer_id: REVIEWER },
+ filters: [['eq', 'id', DRAFT]],
+ });
+ await setContentDraftReviewer(DRAFT, null);
+ expect(calls[1]).toMatchObject({ op: 'update', value: { reviewer_id: null } });
+ await expect(setContentDraftReviewer(DRAFT, 'dr-who')).rejects.toThrow('invalid');
+ });
+});
+
describe('own images (Quality CE-049, 00270)', () => {
const SRC = 'https://cdn.example/run.png';
diff --git a/web/src/lib/actions/content-drafts.ts b/web/src/lib/actions/content-drafts.ts
index 5dffce759..de688ced1 100644
--- a/web/src/lib/actions/content-drafts.ts
+++ b/web/src/lib/actions/content-drafts.ts
@@ -228,7 +228,7 @@ export async function getContentDraft(id: string): Promise<ContentDraft | null>
const { data, error } = await supabase
.from('content_drafts')
.select(
- `id, brand_id, title, page_type, page_type_source, method, status, body_html, author, author_id, source_url, rules, kept_sources, author_real_at, author_profile_at, action_id, agent_state, agent_state_at, agent_run, updated_at, archived_at, ${BRAND_SITE}, actions(action_no)`,
+ `id, brand_id, title, page_type, page_type_source, method, status, body_html, author, author_id, reviewer_id, source_url, rules, kept_sources, author_real_at, author_profile_at, action_id, agent_state, agent_state_at, agent_run, updated_at, archived_at, ${BRAND_SITE}, actions(action_no)`,
)
.eq('id', id)
.maybeSingle();
@@ -247,6 +247,7 @@ export async function getContentDraft(id: string): Promise<ContentDraft | null>
bodyHtml: data.body_html,
author: data.author === 'agent' ? 'agent' : 'user',
authorId: data.author_id,
+ reviewerId: data.reviewer_id,
rules: draftRulesSchema.safeParse(data.rules).data ?? NO_DRAFT_RULES,
keptSources: data.kept_sources ?? [],
authorConfirmed: { real: !!data.author_real_at, profile: !!data.author_profile_at },
@@ -1372,6 +1373,33 @@ export async function setContentDraftAuthor(id: string, authorId: string | null)
if (!data) throw new Error('not_found');
}
+/**
+ * Sets the qualified person who reviewed a regulated page (Quality CE-049,
+ * 00273), one of Authors, or none. The database checks they are the brand's
+ * organization's.
+ */
+export async function setContentDraftReviewer(
+ id: string,
+ reviewerId: string | null,
+): Promise<void> {
+ if (
+ !draftId.safeParse(id).success ||
+ (reviewerId !== null && !z.guid().safeParse(reviewerId).success)
+ ) {
+ throw new Error('invalid');
+ }
+ const supabase = await createClient();
+ const { data, error } = await supabase
+ .from('content_drafts')
+ .update({ reviewer_id: reviewerId })
+ .eq('id', id)
+ .select('id')
+ .maybeSingle();
+ if (error?.code === OTHER_ORGANIZATION) throw new Error('invalid');
+ if (error) throw new Error(error.message);
+ if (!data) throw new Error('not_found');
+}
+
/**
* Confirms, or takes back, what the person says of the author their site
* names (00271): a real person (`real`), their profile with a bio and links
diff --git a/web/src/lib/content/drafts.ts b/web/src/lib/content/drafts.ts
index 60b94473c..e4050a846 100644
--- a/web/src/lib/content/drafts.ts
+++ b/web/src/lib/content/drafts.ts
@@ -164,6 +164,11 @@ export interface ContentDraft {
* organization byline ("{Brand} Team").
*/
authorId: string | null;
+ /**
+ * The qualified person who reviewed a page that advises on health,
+ * finance or law (Quality CE-049, 00273): page metadata, from Authors.
+ */
+ reviewerId: string | null;
/** What the person changed on the page's rules for this draft (CE-009). */
rules: DraftRules;
/** Weak or competitors' sources the person kept (Quality CE-046, 00263): they don't lower Trust. */
diff --git a/web/src/lib/content/quality-todos.test.ts b/web/src/lib/content/quality-todos.test.ts
index 85a157ae8..a35b9af54 100644
--- a/web/src/lib/content/quality-todos.test.ts
+++ b/web/src/lib/content/quality-todos.test.ts
@@ -341,6 +341,29 @@ describe('qualityTodos', () => {
});
});
+ it('asks a page that advises on health, money or the law for a qualified reviewer (CE-049)', () => {
+ const review = (picked: boolean, hasAuthors = true) =>
+ qualityTodos({
+ eeat: eeat({ author: author() }),
+ author: author(),
+ hasAuthors,
+ reviewer: { topic: 'health', picked },
+ brandFacts: { pending: 1, had: true },
+ }).map(({ id, done, action, topic }) => ({ id, done, action, topic }));
+ expect(review(false).slice(-2)).toEqual([
+ { id: 'reviewer', done: false, action: 'pickReviewer', topic: 'health' },
+ { id: 'brandFacts', done: false, action: 'reviewBrandFacts', topic: undefined },
+ ]);
+ expect(review(false, false).at(-2)).toMatchObject({ id: 'reviewer', action: 'addAuthor' });
+ expect(review(true).at(-2)).toMatchObject({ id: 'reviewer', done: true, action: null });
+ // Not regulated: none.
+ expect(
+ qualityTodos({ eeat: eeat({ author: author() }), author: author(), hasAuthors: true }).map(
+ (t) => t.id,
+ ),
+ ).not.toContain('reviewer');
+ });
+
it("keeps a linked proof checked when the next read carries its block with the link's space (review, #1468)", () => {
const read = 'We are ISO 27001-certified for every plan.';
const linked = 'We are ISO 27001 -certified for every plan.';
diff --git a/web/src/lib/content/quality-todos.ts b/web/src/lib/content/quality-todos.ts
index 4e7683734..af900e3c5 100644
--- a/web/src/lib/content/quality-todos.ts
+++ b/web/src/lib/content/quality-todos.ts
@@ -31,6 +31,7 @@ export type QualityTodoId =
| 'visualProof'
| 'expertQuote'
| 'proof'
+ | 'reviewer'
| 'brandFacts';
/**
@@ -47,6 +48,7 @@ export type QualityTodoAction =
| 'addProof'
| 'confirmImage'
| 'addImage'
+ | 'pickReviewer'
| 'reviewBrandFacts';
export interface QualityTodo {
@@ -66,6 +68,8 @@ export interface QualityTodo {
proof?: { claim: string; block: string; kind: ProofKind; sentence: string };
/** How many it is about (placeholders, brand facts to approve). */
count?: number;
+ /** What a regulated page advises on: its reviewer's field (CE-049). */
+ topic?: 'health' | 'finance' | 'legal';
/**
* With no author picked: the person's own word for the author their site
* names (00271), a tick box beside the to-do, and whether it's ticked.
@@ -95,6 +99,7 @@ export function qualityTodos({
brandFacts = null,
proofs = null,
visual = null,
+ reviewer = null,
confirmed = null,
}: {
eeat: Score<EeatCheckId> | null;
@@ -129,6 +134,12 @@ export function qualityTodos({
* person's own, and the visual proof spots open (as eeat takes them).
*/
visual?: { images: number; own: number; openSpots: number } | null;
+ /**
+ * Phase 2 (CE-049): a page that advises consumers on health, finance or
+ * law (the page read's `regulated`) asks for a qualified reviewer, from
+ * Authors; null otherwise.
+ */
+ reviewer?: { topic: 'health' | 'finance' | 'legal'; picked: boolean } | null;
/** What the person confirmed of the author their site names (00271), or null where they can't. */
confirmed?: { real: boolean; profile: boolean } | null;
}): QualityTodo[] {
@@ -178,7 +189,19 @@ export function qualityTodos({
} satisfies QualityTodo,
];
});
- if (!eeat || eeat.score === null) return [...fill, ...proofTodos, ...facts];
+ const review: QualityTodo[] = reviewer
+ ? [
+ {
+ id: 'reviewer',
+ done: reviewer.picked,
+ gain: 0,
+ score: 'eeat',
+ action: reviewer.picked ? null : hasAuthors ? 'pickReviewer' : 'addAuthor',
+ topic: reviewer.topic,
+ },
+ ]
+ : [];
+ if (!eeat || eeat.score === null) return [...fill, ...proofTodos, ...review, ...facts];
// No author picked: the one the site names may be confirmed instead, the
// profile once the author is.
const byConfirm = !author && !!confirmed;
@@ -240,6 +263,7 @@ export function qualityTodos({
] satisfies QualityTodo[])
: []),
...proofTodos,
+ ...review,
...facts,
];
}
diff --git a/web/src/types/supabase.ts b/web/src/types/supabase.ts
index 22e44c67d..7845a4fa7 100644
--- a/web/src/types/supabase.ts
+++ b/web/src/types/supabase.ts
@@ -1003,6 +1003,7 @@ export type Database = {
prompt_ids: string[]
published_at: string | null
published_url: string | null
+ reviewer_id: string | null
rules: Json | null
source_url: string | null
score_after: number | null
@@ -1041,6 +1042,7 @@ export type Database = {
prompt_ids?: string[]
published_at?: string | null
published_url?: string | null
+ reviewer_id?: string | null
rules?: Json | null
source_url?: string | null
score_after?: number | null
@@ -1079,6 +1081,7 @@ export type Database = {
prompt_ids?: string[]
published_at?: string | null
published_url?: string | null
+ reviewer_id?: string | null
rules?: Json | null
source_url?: string | null
score_after?: number | null
@@ -1096,6 +1099,13 @@ export type Database = {
referencedRelation: "content_authors"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "content_drafts_reviewer_id_fkey"
+ columns: ["reviewer_id"]
+ isOneToOne: false
+ referencedRelation: "content_authors"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "content_drafts_opportunity_id_fkey"
columns: ["opportunity_id"]