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.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat(content-editor): confirm the page's own images, E-E-A-T's visual proof (CE-049, part d) (#1475)
Cihanb4ff5ac21364
diff --git a/web/messages/en.json b/web/messages/en.jsonindex ee37da110..169fb0650 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -4016,7 +4016,8 @@"captionLabel": "Caption (optional)","cancel": "Cancel","insert": "Add image",- "gone": "That passage isn't on the page any more, so the image wasn't added."+ "gone": "That passage isn't on the page any more, so the image wasn't added.",+ "own": "This is our own image (a screenshot or photo we took), not stock"}},"image": {@@ -4700,6 +4701,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"},+ "visualProof": {+ "title": "Show your own image",+ "next": "show your own image",+ "detail": {+ "confirm": "{count, plural, one {Is the page's image your own (a screenshot or photo you took), not stock? Confirm it} other {Are any of the page's # images your own (screenshots or photos you took), not stock? Confirm them}}",+ "add": "A screenshot or photo you took, where the margin suggests one"+ },+ "done": "The page shows your own image"+ },"proof": {"title": {"award": "Link the award page for “{claim}”",@@ -4777,7 +4787,9 @@"editAuthor": "Edit now","addInput": "Add now","reviewBrandFacts": "Review now",- "addProof": "Add now"+ "addProof": "Add now",+ "confirmImage": "Confirm now",+ "addImage": "Add now"},"later": "Later"},@@ -4795,6 +4807,18 @@"addSourceTo": "Add a source to “{claim}”","addProof": "Add proof link","addProofFor": "Add a proof link to “{claim}”",+ "confirmImage": "Confirm",+ "addImage": "Add image",+ "confirmImageFailed": "Couldn't save that. Try again.",+ "confirmImageFull": "This page keeps 50 confirmed images already.",+ "confirmImages": {+ "title": "Your own images",+ "description": "Only you can tell your own screenshots and photos from stock. Your own count as visual proof.",+ "own": "Our own image, not stock",+ "confirmed": "Confirmed: our own image",+ "noAlt": "No alt text",+ "done": "Done"+ },"remove": "Remove","removeClaim": "Remove “{sentence}” from the page","claimNoSource": "No source for this claim. Add a source, or take it out. Content Agent will not make one up.",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_confirm-images-dialog.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_confirm-images-dialog.test.tsxnew file mode 100644index 000000000..93483de76--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_confirm-images-dialog.test.tsx@@ -0,0 +1,60 @@+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 { ConfirmImagesDialog } from './_confirm-images-dialog';++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =+ true;++/** Quality's Confirm (CE-049): the page's images, each the person's own or not. */++let container: HTMLDivElement;+let root: Root;+const onConfirm = vi.fn();++beforeEach(() => {+ onConfirm.mockReset();+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+});+afterEach(() => {+ act(() => root.unmount());+ container.remove();+ document.body.replaceChildren();+});++describe('ConfirmImagesDialog', () => {+ it('lists the images, the confirmed ones ticked for good, and confirms one on its box', async () => {+ await act(async () =>+ root.render(+ <NextIntlClientProvider locale="en" messages={messages}>+ <ConfirmImagesDialog+ images={[+ { src: 'https://cdn.example/run.png', alt: 'A forecast run' },+ { src: 'https://cdn.example/team.jpg', alt: '' },+ ]}+ own={new Set(['https://cdn.example/team.jpg'])}+ onConfirm={onConfirm}+ onClose={() => {}}+ />+ </NextIntlClientProvider>,+ ),+ );+ const rows = [...document.querySelectorAll('[role="dialog"] li')];+ expect(rows.map((row) => row.textContent)).toEqual([+ 'A forecast runOur own image, not stock',+ 'No alt textConfirmed: our own image',+ ]);+ expect(rows[0].querySelector('img')!.getAttribute('referrerpolicy')).toBe('no-referrer');+ const boxes = [...document.querySelectorAll<HTMLButtonElement>('[role="checkbox"]')];+ // Confirmed for good: nothing to untick, focus kept on it.+ expect(boxes[1].getAttribute('aria-disabled')).toBe('true');+ await act(async () => boxes[1].click());+ expect(onConfirm).not.toHaveBeenCalled();+ await act(async () => boxes[0].click());+ expect(onConfirm).toHaveBeenCalledWith('https://cdn.example/run.png');+ });+});diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_confirm-images-dialog.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_confirm-images-dialog.tsxnew file mode 100644index 000000000..415c4cbba--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_confirm-images-dialog.tsx@@ -0,0 +1,83 @@+'use client';++import { useId } from 'react';+import { useTranslations } from 'next-intl';+import { Button } from '@/components/ui/button';+import { Checkbox } from '@/components/ui/checkbox';+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@/components/ui/dialog';++/**+ * Quality's Confirm (CE-049, 00270): the page's images, each with "Our own+ * image, not stock". Only the person can tell: their word is kept with who+ * gave it, and E-E-A-T counts the page's own images as visual proof. A+ * confirmation stays (there's nothing to take back: it's their statement).+ */+export function ConfirmImagesDialog({+ images,+ own,+ onConfirm,+ onClose,+}: {+ images: readonly { src: string; alt: string }[];+ own: ReadonlySet<string>;+ onConfirm: (src: string) => void;+ onClose: () => void;+}) {+ const t = useTranslations('contentEditor.editor.quality.confirmImages');+ const id = useId();+ return (+ <Dialog open onOpenChange={(next) => !next && onClose()}>+ <DialogContent className="max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg">+ <DialogHeader>+ <DialogTitle>{t('title')}</DialogTitle>+ <DialogDescription>{t('description')}</DialogDescription>+ </DialogHeader>+ <ul className="divide-y rounded-xl border">+ {images.map((image, i) => {+ const mine = own.has(image.src);+ return (+ <li key={image.src} className="flex items-center gap-3 px-3 py-2.5">+ {/* The image as the page shows it; its host sees no referrer. */}+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img+ src={image.src}+ alt=""+ loading="lazy"+ referrerPolicy="no-referrer"+ className="h-12 w-16 shrink-0 rounded-md border bg-muted object-cover"+ />+ <div className="min-w-0 flex-1">+ <p className="truncate text-sm">{image.alt || t('noAlt')}</p>+ <div className="mt-1 flex items-center gap-2">+ <Checkbox+ id={`${id}-${i}`}+ checked={mine}+ // Kept in reach (focus stays on it once ticked); nothing to untick.+ aria-disabled={mine}+ onCheckedChange={(on) => on === true && !mine && onConfirm(image.src)}+ />+ <label htmlFor={`${id}-${i}`} className="text-xs text-muted-foreground">+ {mine ? t('confirmed') : t('own')}+ </label>+ </div>+ </div>+ </li>+ );+ })}+ </ul>+ <DialogFooter>+ <Button variant="outline" onClick={onClose}>+ {t('done')}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ );+}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.tsxindex fa4ca02d1..d884c5822 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@@ -43,6 +43,8 @@ import {setContentDraftAuthor,confirmDraftAuthor,keepDraftSource,+ confirmOwnImage,+ getOwnImages,setContentDraftPageType,startAgentWriting,startPageRewrite,@@ -109,7 +111,7 @@ import {import { proofKey, qualityTodos } from '@/lib/content/quality-todos';import { readability, sentencesOf } from '@/lib/content/readability';import { brandFactsPath, factMismatches } from '@/lib/content/brand-facts';-import { MAX_PROOF_TODOS, proofsOnPage, type ProofSpot } from '@/lib/content/page-read';+import { MAX_PROOF_TODOS, pageImages, proofsOnPage, type ProofSpot } from '@/lib/content/page-read';import {liveSkips,nextStep,@@ -161,7 +163,8 @@ import { PageInfoStrip, pageInfoKey } from './_page-info';import { WeakSourcesMarks, weakSourcesKey } from './_weak-sources';import { ClaimMarksExtension, claimMarksKey, textRanges, writingBlock } from './_claim-marks';import { ProofImageDialog } from './_proof-image-dialog';-import { ProofSpotsExtension, proofSpotsKey } from './_proof-spots';+import { ProofSpotsExtension, openSpotPlaces, proofSpotsKey } from './_proof-spots';+import { ConfirmImagesDialog } from './_confirm-images-dialog';import { useClaims } from './_use-claims';import { useBrandFacts } from './_use-brand-facts';import { usePageRead } from './_use-page-read';@@ -577,9 +580,6 @@ export function DraftEditor({() => (inputs ? inputsUsed(pageBlocks.map((b) => b.text).join('\n'), inputs) : null),[inputs, pageBlocks],);- // E-E-A-T from the author (and, in phase 2, the person's experience and- // data), Trust from the page's figures and links (their reads from the- // API): with Readability, the scores and the header chip's average (CE-039).// With no author picked, the person's own word for the one their site// names (00271): ticked here, saved behind, put back if the save fails.const [authorConfirmed, setAuthorConfirmed] = useState(draft.authorConfirmed);@@ -601,13 +601,7 @@ export function DraftEditor({}).finally(() => setConfirming(false));};- const eeatScore = useMemo(- () =>- qualityOn && authorsRead && !inputsPending- ? eeat({ author: pageAuthor, used, confirmed: authorConfirmed })- : null,- [qualityOn, authorsRead, inputsPending, pageAuthor, used, authorConfirmed],- );+ // Trust from the page's figures and links (their reads from the API).const { checks: linkChecks, pending: linksPending } = useLinkChecks(draft.id,autosave.savedAt,@@ -701,6 +695,77 @@ export function DraftEditor({.map(proofKey).filter((key) => !hadProofs.has(key));if (newProofs.length > 0) setHadProofs(new Set([...hadProofs, ...newProofs]));+ // The page's images the person confirmed are their own, not stock (CE-049,+ // 00270): E-E-A-T's visual proof. Read once; a confirm adds to it at once.+ const [ownImages, setOwnImages] = useState<ReadonlySet<string> | null>(null);+ useEffect(() => {+ if (!sourcesOn) return;+ let live = true;+ // A confirm made before the read lands stays. A failed call (the+ // network, a deploy) counts the confirms made so far: E-E-A-T still scores.+ void getOwnImages(draft.id)+ .then((srcs) => live && setOwnImages((prev) => new Set([...srcs, ...(prev ?? [])])))+ .catch((err) => {+ console.error('Failed to read the own images:', err);+ if (live) setOwnImages((prev) => prev ?? new Set());+ });+ return () => {+ live = false;+ };+ }, [draft.id, sourcesOn]);+ const images = useMemo(() => (sourcesOn ? pageImages(pageHtml) : []), [sourcesOn, pageHtml]);+ // The visual proof spots still open, as the margin shows them.+ const openSpots =+ editor && pageRead.read ? openSpotPlaces(editor.state.doc, pageRead.read.spots).length : 0;+ const visualImages = images.length;+ const visualOwn = ownImages ? images.filter((image) => ownImages.has(image.src)).length : 0;+ // Once the page's read and the confirmations are in.+ const visualRead = sourcesOn && pageRead.settled && ownImages !== null;+ const visual = useMemo(+ () => (visualRead ? { images: visualImages, own: visualOwn, openSpots } : null),+ [visualRead, visualImages, visualOwn, openSpots],+ );+ // E-E-A-T from the author (and, in phase 2, the person's experience and+ // data, and their own images); with Trust and Readability, the scores and+ // the header chip's average (CE-039).+ // In phase 2 it waits for the visual proof too, so it doesn't move once that lands.+ const eeatScore = useMemo(+ () =>+ qualityOn && authorsRead && !inputsPending && (!sourcesOn || visualRead)+ ? eeat({ author: pageAuthor, used, visual, confirmed: authorConfirmed })+ : null,+ [+ qualityOn,+ authorsRead,+ inputsPending,+ sourcesOn,+ visualRead,+ pageAuthor,+ used,+ visual,+ authorConfirmed,+ ],+ );+ // Confirm: only the person can tell their own image from stock.+ const [confirmingImages, setConfirmingImages] = useState(false);+ const confirmImage = async (src: string) => {+ // Already confirmed: nothing to take back if the save fails.+ const had = ownImages?.has(src) ?? false;+ setOwnImages((prev) => new Set([...(prev ?? []), src]));+ const takeBack = () => {+ if (!had) setOwnImages((prev) => new Set([...(prev ?? [])].filter((own) => own !== src)));+ };+ try {+ if ((await confirmOwnImage(draft.id, src)) === 'full') {+ takeBack();+ toast.error(t('quality.confirmImageFull'));+ }+ } catch (err) {+ console.error('Failed to confirm the image:', err);+ takeBack();+ toast.error(t('quality.confirmImageFailed'));+ }+ };// Out of the editor (to Quality, to Before you publish): the block left// for later is read too.useEffect(() => {@@ -870,6 +935,7 @@ export function DraftEditor({trust: trustScore,brandFacts: brandFacts ? { pending: pendingFacts, had: hadPendingFacts } : null,proofs: sourcesOn ? { asks: proofAsks, had: hadProofs } : null,+ visual,confirmed: authorConfirmed,}): [];@@ -930,6 +996,8 @@ export function DraftEditor({// against, and the page's read (its proof to-dos; what it finds scores).!(sourcesOn && factsState.status === 'loading') &&!pageRead.reading &&+ // E-E-A-T's visual proof: the page's read and the own images (CE-049).+ (!sourcesOn || visualRead) &&// Phase 2 reads the page as saved: an edit's score waits for its save.!(sourcesOn && saving);const [shownQuality, setShownQuality] = useState<{ score: number | null } | null>(null);@@ -1668,6 +1736,12 @@ export function DraftEditor({// The page read's visual proof spots (CE-049), in the draft's margin: not// while the agent changes the page. Add image opens their dialog.const [spotFor, setSpotFor] = useState<ProofSpot | null>(null);+ // Quality's Add image (CE-049, part d): the first spot still open.+ const addImage = () => {+ if (!editor || !pageRead.read) return;+ const [first] = openSpotPlaces(editor.state.doc, pageRead.read.spots);+ if (first) setSpotFor(first.spot);+ };const spotList = sourcesOn && !agentBusy ? (pageRead.read?.spots ?? null) : null;useEffect(() => {if (!editor || editor.isDestroyed) return;@@ -2822,6 +2896,8 @@ export function DraftEditor({onPickAuthor={() => setAuthorMenuOpen(true)}onAddInput={addInput}onAddSource={sourcesOn ? addSource : undefined}+ onConfirmImages={() => setConfirmingImages(true)}+ onAddImage={addImage}onLater={nudge.later}onAct={nudge.close}/>@@ -2865,6 +2941,8 @@ export function DraftEditor({onKeepSource={sourcesOn ? (url) => void keepSource(url) : undefined}onAddSource={sourcesOn ? addSource : undefined}onRemoveClaim={sourcesOn ? removeClaim : undefined}+ onConfirmImages={() => setConfirmingImages(true)}+ onAddImage={addImage}/>) : (<EditorPanelRail onOpen={openPanelTab} />@@ -2872,7 +2950,20 @@ export function DraftEditor({</div>{editor && spotFor && (- <ProofImageDialog editor={editor} spot={spotFor} onClose={() => setSpotFor(null)} />+ <ProofImageDialog+ editor={editor}+ spot={spotFor}+ onClose={() => setSpotFor(null)}+ onOwn={(src) => void confirmImage(src)}+ />+ )}+ {confirmingImages && ownImages && (+ <ConfirmImagesDialog+ images={images}+ own={ownImages}+ onConfirm={(src) => void confirmImage(src)}+ onClose={() => setConfirmingImages(false)}+ />)}{quality && exportOpen && exportChecks && (<ExportDialogdiff --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.tsxindex a080749e3..e3e30e817 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@@ -56,6 +56,7 @@ let root: Root;const onPickAuthor = vi.fn();const onShowPlaceholder = vi.fn();const onAddSource = vi.fn();+const onConfirmImages = vi.fn();const MOMENTS: NudgeMoment[] = ['agent', 'acceptAll', 'markReady'];/** The editor's part: the hook, a button per moment, and the nudge while it shows. */@@ -77,6 +78,7 @@ function Harness({ todos, author }: { todos: QualityTodo[]; author: ContentAuthoonShowPlaceholder={onShowPlaceholder}onPickAuthor={onPickAuthor}onAddSource={onAddSource}+ onConfirmImages={onConfirmImages}onLater={nudge.later}onAct={nudge.close}/>@@ -190,6 +192,17 @@ describe('NextNudge', () => {expect(nudge()!.textContent).toContain('add proof for “SOC 2 certified”');});+ it("opens Confirm for the page's own images (CE-049, part d)", async () => {+ onConfirmImages.mockReset();+ await render([+ { id: 'visualProof', done: false, gain: 8, score: 'eeat', action: 'confirmImage', count: 1 },+ ]);+ await act(async () => nudgeAt('agent'));+ expect(nudge()!.textContent).toBe('Next for you: show your own image · 1 of 1Confirm nowLater');+ await act(async () => button('Confirm now').click());+ expect(onConfirmImages).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.tsxindex 1cc7c204e..2b1357547 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@@ -92,6 +92,8 @@ export function NextNudge({onPickAuthor,onAddInput,onAddSource,+ onConfirmImages,+ onAddImage,onLater,onAct,}: {@@ -105,6 +107,9 @@ export function NextNudge({onAddInput?: () => void;/** A proof to-do's: its claim selected, the link dialog open (CE-049). */onAddSource?: (claim: ClaimMark) => void;+ /** Visual proof's: Confirm, or the first open spot's Add image (CE-049). */+ onConfirmImages?: () => void;+ onAddImage?: () => void;onLater: () => void;/** It was acted on: it goes. */onAct: () => void;@@ -186,6 +191,19 @@ export function NextNudge({{t('act.addProof')}</button>)+ ) : action === 'confirmImage' || action === 'addImage' ? (+ (action === 'confirmImage' ? onConfirmImages : onAddImage) && (+ <button+ type="button"+ className={actClass}+ onClick={() => {+ onAct();+ (action === 'confirmImage' ? onConfirmImages : onAddImage)!();+ }}+ >+ {t(`act.${action}`)}+ </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]/_proof-image-dialog.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_proof-image-dialog.test.tsxindex bcb87491e..eb50d9b02 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_proof-image-dialog.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_proof-image-dialog.test.tsx@@ -57,11 +57,12 @@ const input = (id: string) => document.querySelector<HTMLInputElement>(`#${id}`)const button = (name: string) =>[...document.querySelectorAll<HTMLButtonElement>('button')].find((b) => b.textContent === name)!;const onClose = vi.fn();+const onOwn = vi.fn();const render = () =>act(async () =>root.render(<NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">- <ProofImageDialog editor={editor} spot={SPOT} onClose={onClose} />+ <ProofImageDialog editor={editor} spot={SPOT} onClose={onClose} onOwn={onOwn} /></NextIntlClientProvider>,),);@@ -116,6 +117,15 @@ describe('ProofImageDialog', () => {expect(editor.getHTML()).toContain(`<img src="${SRC}" alt="The Ridge 28 after a rain test">`);});+ it("says the image put in is the person's own when they tick it (CE-049, part d)", async () => {+ onOwn.mockReset();+ await render();+ await act(async () => setValue(input('proof-image-src'), SRC));+ await act(async () => document.querySelector<HTMLButtonElement>('#proof-image-own')!.click());+ await act(async () => button('Add image').click());+ expect(onOwn).toHaveBeenCalledWith(SRC);+ });+it('says so when the passage left the page meanwhile', async () => {await render();editor.commands.setContent('<p>Written over.</p>');diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_proof-image-dialog.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_proof-image-dialog.tsxindex f4f434296..f20437492 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_proof-image-dialog.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_proof-image-dialog.tsx@@ -5,6 +5,7 @@ import type { Editor } from '@tiptap/core';import { useTranslations } from 'next-intl';import { toast } from 'sonner';import { Button } from '@/components/ui/button';+import { Checkbox } from '@/components/ui/checkbox';import {Dialog,DialogClose,@@ -60,15 +61,19 @@ export function ProofImageDialog({editor,spot,onClose,+ onOwn,}: {editor: Editor;spot: ProofSpot;onClose: () => void;+ /** The image put in is the person's own, not stock (CE-049, part d): they ticked it. */+ onOwn?: (src: string) => void;}) {const t = useTranslations('contentEditor.editor.proofSpots.dialog');const [src, setSrc] = useState('');const [alt, setAlt] = useState(spot.alt);const [caption, setCaption] = useState('');+ const [own, setOwn] = useState(false);const [invalid, setInvalid] = useState<'src' | 'alt' | null>(null);const fieldRef = useRef<HTMLInputElement>(null);@@ -87,6 +92,8 @@ export function ProofImageDialog({}if (!insertProofImage(editor, spot, { src: safe, alt: alt.trim(), caption })) {toast.error(t('gone'));+ } else if (own) {+ onOwn?.(safe);}onClose();};@@ -161,6 +168,19 @@ export function ProofImageDialog({{/* Enter in any field adds it. */}<button type="submit" hidden /></form>+ {onOwn && (+ <div className="flex items-start gap-2">+ <Checkbox+ id="proof-image-own"+ className="mt-px"+ checked={own}+ onCheckedChange={(on) => setOwn(on === true)}+ />+ <Label htmlFor="proof-image-own" className="text-xs leading-snug font-normal">+ {t('own')}+ </Label>+ </div>+ )}<DialogFooter><DialogClose render={<Button variant="outline" />}>{t('cancel')}</DialogClose><Button onClick={insert}>{t('insert')}</Button>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.tsxindex f3ed73507..1eb9dfead 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@@ -92,6 +92,8 @@ const onShowPlaceholder = vi.fn();const onAddInput = vi.fn();const onKeep = vi.fn();const onAddSource = vi.fn();+const onConfirmImages = vi.fn();+const onAddImage = vi.fn();const onConfirmAuthor = vi.fn();async function render(quality: QualityRead | Readability | null) {@@ -107,6 +109,8 @@ async function render(quality: QualityRead | Readability | null) {onAddInput={onAddInput}onKeep={onKeep}onAddSource={onAddSource}+ onConfirmImages={onConfirmImages}+ onAddImage={onAddImage}onConfirmAuthor={onConfirmAuthor}/></NextIntlClientProvider>,@@ -623,6 +627,42 @@ describe('QualityTab', () => {expect(container.textContent).toContain('Link the test report for “40% faster”');});+ it("asks to confirm the page's own images, or to add one at a spot (CE-049, part d)", async () => {+ const none = { experience: false, data: false, quote: false };+ const quality = (images: number, openSpots: number): QualityRead => {+ const score = eeat({ author: ada, used: none, visual: { images, own: 0, openSpots } });+ return {+ ...read(null),+ eeat: score,+ todos: qualityTodos({+ eeat: score,+ author: ada,+ hasAuthors: true,+ used: none,+ visual: { images, own: 0, openSpots },+ }),+ };+ };+ onConfirmImages.mockReset();+ onAddImage.mockReset();+ await render(quality(2, 0));+ const row = () =>+ [...container.querySelectorAll('[aria-label="Your to-dos"] li')].find((li) =>+ li.textContent?.startsWith('Show your own image'),+ )!;+ expect(row().textContent).toContain(+ "Are any of the page's 2 images your own (screenshots or photos you took), not stock? Confirm them",+ );+ await act(async () => row().querySelector('button')!.click());+ expect(onConfirmImages).toHaveBeenCalled();+ await render(quality(0, 1));+ expect(row().textContent).toContain(+ 'A screenshot or photo you took, where the margin suggests one',+ );+ await act(async () => row().querySelector('button')!.click());+ expect(onAddImage).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.tsxindex 338cca4f4..d802511a4 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@@ -112,6 +112,8 @@ export function QualityTab({onKeep,onAddSource,onRemove,+ onConfirmImages,+ onAddImage,onConfirmAuthor,}: {quality: QualityRead;@@ -131,6 +133,10 @@ export function QualityTab({onConfirmAuthor?: (what: 'real' | 'profile', on: boolean) => void;/** Takes a claim's sentence out of the page (CE-045). */onRemove?: (claim: ClaimMark) => void;+ /** Opens Confirm: the page's images, each to confirm as the person's own (CE-049). */+ onConfirmImages?: () => void;+ /** Opens the first open visual proof spot's Add image (CE-049). */+ onAddImage?: () => void;}) {const t = useTranslations('contentEditor.editor.quality');const tSite = useTranslations('audit.siteTrust.checks');@@ -203,6 +209,8 @@ export function QualityTab({onPickAuthor={onPickAuthor}onAddInput={onAddInput}onAddSource={onAddSource}+ onConfirmImages={onConfirmImages}+ onAddImage={onAddImage}onConfirm={onConfirmAuthor}/>))}@@ -387,6 +395,19 @@ export function useTodoCopy() {detail: todo.done ? t('brandFacts.done') : t('brandFacts.detail'),};}+ // An image the person took themself (CE-049).+ if (todo.id === 'visualProof') {+ const count = todo.count ?? 0;+ return {+ title: t('visualProof.title'),+ next: t('visualProof.next'),+ detail: todo.done+ ? t('visualProof.done')+ : todo.action === 'confirmImage'+ ? t('visualProof.detail.confirm', { count })+ : t('visualProof.detail.add'),+ };+ }// What only the person can give (Brief › Your input, CE-048).if (todo.id === 'experience' || todo.id === 'originalData' || todo.id === 'expertQuote') {return {@@ -440,6 +461,8 @@ function TodoRow({onPickAuthor,onAddInput,onAddSource,+ onConfirmImages,+ onAddImage,onConfirm,}: {todo: QualityTodo;@@ -449,6 +472,8 @@ function TodoRow({onAddInput?: () => void;/** A proof to-do's Add proof link: its claim selected, the link dialog open (CE-049). */onAddSource?: (claim: ClaimMark) => void;+ onConfirmImages?: () => void;+ onAddImage?: () => void;onConfirm?: (what: 'real' | 'profile', on: boolean) => void;}) {const t = useTranslations('contentEditor.editor.quality');@@ -553,6 +578,18 @@ function TodoRow({{t('addProof')}</Button>)+ ) : todo.action === 'confirmImage' ? (+ onConfirmImages && (+ <Button variant="outline" size="sm" className="h-7 shrink-0" onClick={onConfirmImages}>+ {t('confirmImage')}+ </Button>+ )+ ) : todo.action === 'addImage' ? (+ onAddImage && (+ <Button variant="outline" size="sm" className="h-7 shrink-0" onClick={onAddImage}>+ {t('addImage')}+ </Button>+ )) : todo.action === 'reviewBrandFacts' ? (quality.brandFactsPath && (<Linkdiff --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.tsxindex 0f12579b0..2d9358ce6 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@@ -136,6 +136,8 @@ export function EditorSidePanel({onKeepSource,onAddSource,onRemoveClaim,+ onConfirmImages,+ onAddImage,}: {draft: ContentDraft;/** The brand's business type as the editor holds it (Quality CE-056). */@@ -199,6 +201,9 @@ export function EditorSidePanel({onAddSource?: (claim: ClaimMark) => void;/** Takes a claim's sentence out of the page: Quality's Remove (CE-045). */onRemoveClaim?: (claim: ClaimMark) => void;+ /** Quality's visual proof (CE-049): Confirm the page's images, or Add image at a spot. */+ onConfirmImages?: () => void;+ onAddImage?: () => void;}) {const t = useTranslations('contentEditor.editor.panel');const tEditor = useTranslations('contentEditor.editor');@@ -448,6 +453,8 @@ export function EditorSidePanel({onKeep={onKeepSource}onAddSource={onAddSource}onRemove={onRemoveClaim}+ onConfirmImages={onConfirmImages}+ onAddImage={onAddImage}/></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.tsxindex 34d707eaa..d2fadb21f 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@@ -23,6 +23,8 @@ const keepDraftSource = vi.fn();const confirmDraftAuthor = vi.fn();const checkDraftClaims = vi.fn();const readDraftPage = vi.fn();+const getOwnImages = vi.fn();+const confirmOwnImage = vi.fn();const getBrandFacts = vi.fn();const checkDraftLinks = vi.fn();const getSiteTrust = vi.fn();@@ -95,6 +97,8 @@ vi.mock('@/lib/actions/content-drafts', () => ({confirmDraftAuthor: (...args: unknown[]) => confirmDraftAuthor(...args),checkDraftClaims: (...args: unknown[]) => checkDraftClaims(...args),readDraftPage: (...args: unknown[]) => readDraftPage(...args),+ getOwnImages: (...args: unknown[]) => getOwnImages(...args),+ confirmOwnImage: (...args: unknown[]) => confirmOwnImage(...args),checkDraftLinks: (...args: unknown[]) => checkDraftLinks(...args),}));vi.mock('next/navigation', () => ({ useParams: () => ({ draftId: 'd1' }) }));@@ -297,6 +301,8 @@ beforeEach(() => {confirmDraftAuthor.mockReset().mockResolvedValue(undefined);checkDraftClaims.mockReset().mockResolvedValue({ blocks: [], pending: 0, limited: false });readDraftPage.mockReset().mockResolvedValue({ error: 'off' });+ getOwnImages.mockReset().mockResolvedValue([]);+ confirmOwnImage.mockReset().mockResolvedValue('ok');getBrandFacts.mockReset().mockResolvedValue({facts: [],pages: [],@@ -2484,6 +2490,7 @@ describe('the side panel', () => {});afterEach(() => {delete process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE;+ vi.useRealTimers();});it('shows nothing of Quality until its first phase is live', async () => {@@ -2608,6 +2615,7 @@ describe('the side panel', () => {it("asks for Your input in its second phase, and Add opens it at Brief's top (CE-048)", async () => {process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '2';+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });getContentAuthors.mockResolvedValue({authors: [],brands: [{ id: 'b1', name: 'Acme' }],@@ -2618,6 +2626,8 @@ describe('the side panel', () => {getContentDraft.mockResolvedValue(readable);window.innerWidth = 1440;await renderPage();+ // In phase 2 E-E-A-T waits for the page's read (its visual proof), after the save.+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));expect(getDraftInputs).toHaveBeenCalledWith(readable.id);const chip = [...container.querySelectorAll<HTMLButtonElement>('header button')].find((b) =>b.textContent?.startsWith('Quality'),@@ -3125,6 +3135,138 @@ describe('the side panel', () => {expect(container.querySelector('.ProseMirror [data-proof-spot]')).not.toBeNull();});+ it("confirms the page's own image from Quality, and counts it as visual proof (CE-049, part d)", async () => {+ process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '2';+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });+ getContentAuthors.mockResolvedValue({+ authors: [],+ brands: [{ id: 'b1', name: 'Acme' }],+ me: { id: 'u1', role: 'admin' },+ });+ getDraftInputs.mockResolvedValue({ experience: '', data: [], ansvisorData: [], quotes: [] });+ getContentDraft.mockResolvedValue(+ draft({+ bodyHtml: `<h1>Pipeline forecasting</h1><p>${said} It is easy to set up for any team.</p><img src="https://cdn.acme.com/run.png" alt="A forecast run">`,+ }),+ );+ window.innerWidth = 1440;+ await renderPage();+ // The image's page is saved as the editor writes it; the page's read+ // (here off) comes a few seconds after that save.+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));+ const chip = [...container.querySelectorAll<HTMLButtonElement>('header button')].find((b) =>+ b.textContent?.startsWith('Quality'),+ )!;+ await act(async () => chip.click());+ const row = () =>+ [...panel()!.querySelectorAll('[aria-label="Your to-dos"] li')].find((li) =>+ li.textContent?.startsWith('Show your own image'),+ )!;+ expect(row().textContent).toContain("Is the page's image your own");+ await act(async () =>+ [...row().querySelectorAll('button')].find((b) => b.textContent === 'Confirm')!.click(),+ );+ const box = document.querySelector<HTMLButtonElement>('[role="dialog"] [role="checkbox"]')!;+ await act(async () => box.click());+ expect(confirmOwnImage).toHaveBeenCalledWith('d1', 'https://cdn.acme.com/run.png');+ expect(box.getAttribute('aria-checked')).toBe('true');+ expect(row().textContent).toContain('The page shows your own image');+ });++ it('takes a confirm back when the draft keeps 50 already (CE-049, part d)', async () => {+ process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '2';+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });+ getContentAuthors.mockResolvedValue({+ authors: [],+ brands: [{ id: 'b1', name: 'Acme' }],+ me: { id: 'u1', role: 'admin' },+ });+ confirmOwnImage.mockResolvedValue('full');+ getContentDraft.mockResolvedValue(+ draft({+ bodyHtml: `<h1>Pipeline forecasting</h1><p>${said} It is easy to set up for any team.</p><img src="https://cdn.acme.com/run.png" alt="A forecast run">`,+ }),+ );+ window.innerWidth = 1440;+ await renderPage();+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));+ const chip = [...container.querySelectorAll<HTMLButtonElement>('header button')].find((b) =>+ b.textContent?.startsWith('Quality'),+ )!;+ await act(async () => chip.click());+ const row = [...panel()!.querySelectorAll('[aria-label="Your to-dos"] li')].find((li) =>+ li.textContent?.startsWith('Show your own image'),+ )!;+ await act(async () =>+ [...row.querySelectorAll('button')].find((b) => b.textContent === 'Confirm')!.click(),+ );+ const box = document.querySelector<HTMLButtonElement>('[role="dialog"] [role="checkbox"]')!;+ await act(async () => box.click());+ expect(toast.error).toHaveBeenCalledWith('This page keeps 50 confirmed images already.');+ expect(box.getAttribute('aria-checked')).toBe('false');+ });++ 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'] });+ vi.spyOn(console, 'error').mockImplementation(() => {});+ try {+ getContentAuthors.mockResolvedValue({+ authors: [],+ brands: [{ id: 'b1', name: 'Acme' }],+ me: { id: 'u1', role: 'admin' },+ });+ getDraftInputs.mockResolvedValue({+ experience: '',+ data: [],+ ansvisorData: [],+ quotes: [],+ });+ // The own images' call fails (the network, a deploy).+ getOwnImages.mockRejectedValue(new Error('offline'));+ let pageIn: (value: unknown) => void = () => {};+ readDraftPage.mockReturnValue(new Promise((resolve) => (pageIn = resolve)));+ getContentDraft.mockResolvedValue(+ draft({+ bodyHtml: `<h1>Pipeline forecasting</h1><p>${said} It is easy to set up for any team.</p><img src="https://cdn.acme.com/run.png" alt="A forecast run">`,+ }),+ );+ window.innerWidth = 1440;+ await renderPage();+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));+ // The claims are in; the page's read isn't: no score on Trust and Readability alone.+ expect(checkDraftClaims).toHaveBeenCalled();+ expect(readDraftPage).toHaveBeenCalled();+ const chip = () =>+ [...container.querySelectorAll<HTMLButtonElement>('header button')].find((b) =>+ b.textContent?.startsWith('Quality'),+ );+ expect(chip()?.textContent).toBe('Quality · reading…');+ await act(async () =>+ pageIn({+ spots: [],+ proofs: [],+ regulated: null,+ pending: false,+ limited: false,+ paused: false,+ }),+ );+ // In once, with the confirms made so far (none): it scores.+ expect(chip()?.textContent).toMatch(/^Quality \d+ · (Strong|Can improve|Needs work)$/);+ expect(console.error).toHaveBeenCalledWith(+ 'Failed to read the own images:',+ expect.any(Error),+ );+ } finally {+ vi.mocked(console.error).mockRestore();+ vi.useRealTimers();+ }+ });+it('takes the claim’s sentence out on Remove', 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.tsindex 1154fdcbf..ef3e0c7d3 100644--- a/web/src/lib/actions/content-drafts.test.ts+++ b/web/src/lib/actions/content-drafts.test.ts@@ -24,6 +24,8 @@ let list: Record<string, unknown>[];// Database functions called, and what the next one returns.let rpcCalls: [string, unknown][];let rpcResult: { data: unknown; error: { message: string } | null };+// What an upsert answers (an own image's confirm).+let upsertError: { code: string; message: string } | null;vi.mock('@/lib/action-center/assignees', () => ({ readAssignees: vi.fn(async () => new Map()) }));vi.mock('@/lib/supabase/admin', () => ({ supabaseAdmin: {} }));@@ -70,6 +72,14 @@ vi.mock('@/lib/supabase/server', () => ({},update: (value: unknown) => ((call.op = 'update'), (call.value = value), chain),insert: (value: unknown) => ((call.op = 'insert'), (call.value = value), chain),+ upsert: async (value: unknown, options: unknown) => {+ call.op = 'upsert';+ call.value = { value, options };+ return { error: upsertError };+ },+ // A read awaited as it is: the list.+ then: (resolve: (value: unknown) => void) =>+ resolve(call.op === 'select' ? { data: list, error: null } : result()),maybeSingle: async () => result(),single: async () => result(),};@@ -96,6 +106,8 @@ const {confirmDraftAuthor,setContentDraftPageType,unmarkContentDraftReady,+ confirmOwnImage,+ getOwnImages,} = await import('./content-drafts');const { bodyHash } = await import('@/lib/content/editor');@@ -105,6 +117,7 @@ beforeEach(() => {updates = [];row = null;list = [];+ upsertError = null;rpcCalls = [];rpcResult = { data: 'v-new', error: null };completeDraftTasks.mockReset().mockResolvedValue(0);@@ -350,6 +363,28 @@ describe('setContentDraftAuthor', () => {});});+describe('own images (Quality CE-049, 00270)', () => {+ const SRC = 'https://cdn.example/run.png';++ it("reads the draft's confirmed images, none when they can't be read", async () => {+ list = [{ src: SRC }];+ expect(await getOwnImages(DRAFT)).toEqual([SRC]);+ expect(calls[0].filters).toEqual([['eq', 'draft_id', DRAFT]]);+ expect(await getOwnImages('d1')).toEqual([]);+ });++ it('confirms one as the member, now, once; says when the draft keeps 50', async () => {+ expect(await confirmOwnImage(DRAFT, SRC)).toBe('ok');+ const { value, options } = calls[0].value as { value: unknown; options: unknown };+ // When is the database's now, the time its policy checks against.+ expect(value).toEqual({ draft_id: DRAFT, src: SRC, confirmed_by: 'u1' });+ expect(options).toEqual({ onConflict: 'draft_id,src', ignoreDuplicates: true });+ upsertError = { code: '23514', message: 'A draft keeps 50 confirmed images at most' };+ expect(await confirmOwnImage(DRAFT, SRC)).toBe('full');+ await expect(confirmOwnImage(DRAFT, 'data:image/png;base64,x')).rejects.toThrow('invalid');+ });+});+describe('confirmDraftAuthor (00271)', () => {it('ticks or unticks the author the site names, or their profile; the database stamps who and when', async () => {updated = { id: DRAFT };diff --git a/web/src/lib/actions/content-drafts.ts b/web/src/lib/actions/content-drafts.tsindex 40864965b..5dffce759 100644--- a/web/src/lib/actions/content-drafts.ts+++ b/web/src/lib/actions/content-drafts.ts@@ -2405,3 +2405,60 @@ export async function readDraftPage(return { error: 'failed' };}}++/** The cap trigger's check violation: the draft keeps 50 confirmed images (00270). */+const OWN_IMAGES_FULL = '23514';++/** An image's address as the page and the database keep it (00270: 8–2048 characters, http(s)). */+const ownImageSrc = z+ .string()+ .min(8)+ .max(2048)+ .regex(/^https?:\/\//);++/**+ * The page's images a member confirmed are their own, not stock (Quality+ * CE-049, 00270): E-E-A-T's visual proof. Fails soft: none, when they+ * can't be read.+ */+export async function getOwnImages(id: string): Promise<string[]> {+ if (!draftId.safeParse(id).success) return [];+ try {+ const supabase = await createClient();+ const { data, error } = await supabase+ .from('content_draft_own_images')+ .select('src')+ .eq('draft_id', id);+ if (error) throw new Error(error.message);+ return (data ?? []).map((row) => row.src);+ } catch (err) {+ console.error('Failed to read the own images:', err);+ return [];+ }+}++/**+ * Confirms an image on the page is the member's own (00270): their+ * statement, kept with who made it, as themself and now. Confirmed already+ * is fine; 'full' when the draft keeps 50.+ */+export async function confirmOwnImage(id: string, src: string): Promise<'ok' | 'full'> {+ if (!draftId.safeParse(id).success || !ownImageSrc.safeParse(src).success) {+ throw new Error('invalid');+ }+ const supabase = await createClient();+ const {+ data: { user },+ } = await supabase.auth.getUser();+ if (!user) throw new Error('not_found');+ const { error } = await supabase+ .from('content_draft_own_images')+ // When: the database's now (its default), the time its policy checks against.+ .upsert(+ { draft_id: id, src, confirmed_by: user.id },+ { onConflict: 'draft_id,src', ignoreDuplicates: true },+ );+ if (error?.code === OWN_IMAGES_FULL) return 'full';+ if (error) throw new Error(error.message);+ return 'ok';+}diff --git a/web/src/lib/content/page-read.test.ts b/web/src/lib/content/page-read.test.tsindex b079a67df..d7ecb25f1 100644--- a/web/src/lib/content/page-read.test.ts+++ b/web/src/lib/content/page-read.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest';-import { proofsOnPage, type ProofAsk } from './page-read';+import { pageImages, proofsOnPage, type ProofAsk } from './page-read';import { trustBlocks } from './quality-checks';/** The page read's proof asks on the page as it is now (Quality spec §4b, CE-049). */@@ -78,3 +78,19 @@ describe('proofsOnPage', () => {).toBe(false);});});++describe('pageImages', () => {+ it("lists the page's images by their address, once each, in its order", () => {+ expect(+ pageImages(+ '<p>Intro</p><img src="https://cdn.example/a.png" alt="A run"><p><img src="data:image/png;base64,xx"></p>' ++ '<img src="https://cdn.example/b.jpg"><img src="https://cdn.example/a.png" alt="again">' ++ // As the database takes an own image's address: lower-case http(s), 2048 at most.+ `<img src="HTTP://cdn.example/c.png"><img src="https://cdn.example/${'x'.repeat(2048)}.png">`,+ ),+ ).toEqual([+ { src: 'https://cdn.example/a.png', alt: 'A run' },+ { src: 'https://cdn.example/b.jpg', alt: '' },+ ]);+ });+});diff --git a/web/src/lib/content/page-read.ts b/web/src/lib/content/page-read.tsindex 358e541b6..c8e482f32 100644--- a/web/src/lib/content/page-read.ts+++ b/web/src/lib/content/page-read.ts@@ -92,3 +92,21 @@ export function proofsOnPage(blocks: TrustBlock[], proofs: readonly ProofAsk[]):);});}++/**+ * The page's images, in its order, each once by its address (an http(s)+ * one, as the page keeps it): what the person may confirm is their own.+ */+export function pageImages(html: string): { src: string; alt: string }[] {+ const doc = new DOMParser().parseFromString(html, 'text/html');+ const seen = new Set<string>();+ return [...doc.querySelectorAll('img[src]')].flatMap((img) => {+ const src = img.getAttribute('src')!.trim();+ // As the database takes an own image's address (00270): http(s), 8–2048 characters.+ if (!/^https?:\/\//.test(src) || src.length < 8 || src.length > 2048 || seen.has(src)) {+ return [];+ }+ seen.add(src);+ return [{ src, alt: img.getAttribute('alt')?.trim() ?? '' }];+ });+}diff --git a/web/src/lib/content/quality-checks.test.ts b/web/src/lib/content/quality-checks.test.tsindex 2db15c3fa..c33fda26d 100644--- a/web/src/lib/content/quality-checks.test.ts+++ b/web/src/lib/content/quality-checks.test.ts@@ -48,6 +48,19 @@ describe('eeat (Phase 1: the author)', () => {expect(scoreGain(result, ['byline'])).toBe(60);});+ it("counts the person's own image as visual proof, and none with images or spots unconfirmed (CE-049)", () => {+ const visual = (images: number, own: number, openSpots: number) =>+ eeat({ author: author(), visual: { images, own, openSpots } }).checks.find(+ (c) => c.id === 'visualProof',+ );+ expect(visual(2, 1, 0)).toEqual({ id: 'visualProof', points: 10, max: 10 });+ expect(visual(2, 0, 0)).toEqual({ id: 'visualProof', points: 0, max: 10 });+ expect(visual(0, 0, 1)).toEqual({ id: 'visualProof', points: 0, max: 10 });+ // No image and nothing suggested: the check is left out.+ expect(visual(0, 0, 0)).toBeUndefined();+ expect(eeat({ author: author() }).checks.find((c) => c.id === 'visualProof')).toBeUndefined();+ });+it('counts the author the site names once the person confirms them, the profile with them', () => {expect(eeat({ author: null, confirmed: { real: true, profile: false } }).score).toBe(60);expect(eeat({ author: null, confirmed: { real: true, profile: true } }).score).toBe(100);diff --git a/web/src/lib/content/quality-checks.ts b/web/src/lib/content/quality-checks.tsindex 4ce97d266..2717e4634 100644--- a/web/src/lib/content/quality-checks.ts+++ b/web/src/lib/content/quality-checks.ts@@ -146,9 +146,17 @@ export function authorProfile(author: ContentAuthor | null): { bio: boolean; linexport function eeat({author,used = null,+ visual = null,confirmed = null,}: {author: ContentAuthor | null;+ /**+ * Phase 2 (CE-049): the page's images, how many of them the person+ * confirmed are their own (not stock), and the visual proof spots still+ * open. Own ones are visual proof; images or spots with none confirmed+ * count none; a page with neither leaves the check out. Left out before.+ */+ visual?: { images: number; own: number; openSpots: number } | null;/*** With no author picked, what the person confirmed of the one their site* names (00271): a real person (the byline's points), and their profile@@ -177,6 +185,16 @@ export function eeat({},]: []),+ // Own images are among the page's: images or open spots bring the check in.+ ...(visual && (visual.images > 0 || visual.openSpots > 0)+ ? [+ {+ id: 'visualProof' as const,+ points: visual.own > 0 ? EEAT_WEIGHTS.visualProof : 0,+ max: EEAT_WEIGHTS.visualProof,+ },+ ]+ : []),{id: 'byline',points: author || confirmed?.real ? EEAT_WEIGHTS.byline : 0,diff --git a/web/src/lib/content/quality-todos.test.ts b/web/src/lib/content/quality-todos.test.tsindex 7b8d168ba..85a157ae8 100644--- a/web/src/lib/content/quality-todos.test.ts+++ b/web/src/lib/content/quality-todos.test.ts@@ -307,6 +307,40 @@ describe('qualityTodos', () => {]);});+ it("asks to confirm the page's own image, or to add one where a spot is open (CE-049)", () => {+ const none = { experience: false, data: false, quote: false };+ const visualTodo = (images: number, own: number, openSpots: number) =>+ qualityTodos({+ eeat: eeat({ author: author(), used: none, visual: { images, own, openSpots } }),+ author: author(),+ hasAuthors: true,+ used: none,+ visual: { images, own, openSpots },+ }).find((t) => t.id === 'visualProof');+ expect(visualTodo(2, 0, 0)).toMatchObject({+ done: false,+ action: 'confirmImage',+ count: 2,+ score: 'eeat',+ });+ expect(visualTodo(2, 0, 0)!.gain).toBeGreaterThan(0);+ expect(visualTodo(0, 0, 1)).toMatchObject({ done: false, action: 'addImage' });+ expect(visualTodo(2, 1, 0)).toMatchObject({ done: true, action: null, gain: 0 });+ expect(visualTodo(0, 0, 0)).toBeUndefined();+ // Your input not read: visual proof still counts, so its to-do is still listed.+ const unread = qualityTodos({+ eeat: eeat({ author: author(), visual: { images: 2, own: 0, openSpots: 0 } }),+ author: author(),+ hasAuthors: true,+ used: null,+ visual: { images: 2, own: 0, openSpots: 0 },+ });+ expect(unread.find((t) => t.id === 'visualProof')).toMatchObject({+ done: false,+ action: 'confirmImage',+ });+ });+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.tsindex 85cc7d6ac..4e7683734 100644--- a/web/src/lib/content/quality-todos.ts+++ b/web/src/lib/content/quality-todos.ts@@ -28,6 +28,7 @@ export type QualityTodoId =| 'authorProfile'| 'experience'| 'originalData'+ | 'visualProof'| 'expertQuote'| 'proof'| 'brandFacts';@@ -44,6 +45,8 @@ export type QualityTodoAction =| 'editAuthor'| 'addInput'| 'addProof'+ | 'confirmImage'+ | 'addImage'| 'reviewBrandFacts';export interface QualityTodo {@@ -91,6 +94,7 @@ export function qualityTodos({trust = null,brandFacts = null,proofs = null,+ visual = null,confirmed = null,}: {eeat: Score<EeatCheckId> | null;@@ -120,6 +124,11 @@ export function qualityTodos({* session: done ones stay listed, checked.*/proofs?: { asks: readonly PageProof[]; had: ReadonlySet<string> } | null;+ /**+ * Phase 2 (CE-049): the page's images, how many are confirmed the+ * person's own, and the visual proof spots open (as eeat takes them).+ */+ visual?: { images: number; own: number; openSpots: number } | 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[] {@@ -213,6 +222,12 @@ export function qualityTodos({score: 'eeat',action: 'addInput',},+ ] satisfies QualityTodo[])+ : []),+ // Not Your input's: listed in its place when that can't be read too.+ ...visualTodo(eeat, visual),+ ...(used+ ? ([{id: 'expertQuote',done: used.quote,@@ -247,3 +262,27 @@ function shortHash(text: string): string {*/export const proofKey = (ask: { claim: string; block: string }) =>`proof:${squeeze(ask.claim)}:${shortHash(squeeze(ask.block))}`;++/**+ * Visual proof (CE-049): an image the person took themself. Images on the+ * page none of them confirmed: Confirm (only the person can tell their own+ * from stock); none, with a spot open: Add image there. Checked once one+ * is confirmed; none when the page has neither.+ */+function visualTodo(+ eeat: Score<EeatCheckId>,+ visual: { images: number; own: number; openSpots: number } | null,+): QualityTodo[] {+ if (!visual || (visual.images === 0 && visual.openSpots === 0)) return [];+ const done = visual.own > 0;+ return [+ {+ id: 'visualProof',+ done,+ gain: scoreGain(eeat, ['visualProof']),+ score: 'eeat',+ action: done ? null : visual.images > 0 ? 'confirmImage' : 'addImage',+ count: visual.images - visual.own,+ },+ ];+}diff --git a/web/src/types/supabase.ts b/web/src/types/supabase.tsindex 4f1690bc5..22e44c67d 100644--- a/web/src/types/supabase.ts+++ b/web/src/types/supabase.ts@@ -1386,6 +1386,42 @@ export type Database = {},]}+ content_draft_own_images: {+ Row: {+ confirmed_at: string+ confirmed_by: string | null+ draft_id: string+ src: string+ }+ Insert: {+ confirmed_at?: string+ confirmed_by?: string | null+ draft_id: string+ src: string+ }+ Update: {+ confirmed_at?: string+ confirmed_by?: string | null+ draft_id?: string+ src?: string+ }+ Relationships: [+ {+ foreignKeyName: "content_draft_own_images_draft_id_fkey"+ columns: ["draft_id"]+ isOneToOne: false+ referencedRelation: "content_drafts"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "content_draft_own_images_confirmed_by_fkey"+ columns: ["confirmed_by"]+ isOneToOne: false+ referencedRelation: "profiles"+ referencedColumns: ["id"]+ },+ ]+ }content_draft_ready_log: {Row: {created_at: string