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): score E-E-A-T from the page's author in Instructions › Quality (CE-039) (#1414)
Cihanc5be63920afa
diff --git a/web/messages/en.json b/web/messages/en.jsonindex b34131908..077e33aef 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -4106,6 +4106,8 @@"quality": {"scores": "Quality scores","names": {+ "eeat": "E-E-A-T",+ "trust": "Trust","readability": "Readability"},"bands": {@@ -4115,9 +4117,14 @@},"estimate": "Ansvisor estimates based on Google's published quality signals. Not a Google score.","tooShort": "Write a few paragraphs: Readability is read from the page as you write.",+ "tooShortShort": "Too short yet",+ "notScored": "Not scored yet",+ "pickAuthor": "Pick author",+ "addAuthor": "Add author",+ "editAuthor": "Edit author","notThisLanguage": "Readability isn't read for this language yet.","suggestionsLabel": "What would raise it",- "nothingToRaise": "Nothing to raise here: the page reads well.",+ "nothingToRaise": "Nothing to raise here for now: every live check has its points.","gain": "+{gain, number} {score}","band": "{score, number}, {band}","show": "Show",@@ -4129,6 +4136,27 @@"fernandezHuerta": "Fernández-Huerta"},"checks": {+ "byline": {+ "line": "The page is by {byline}, not a person",+ "detail": "Pick the person who wrote it: a named author with a short bio and profile links shows who stands behind the page."+ },+ "authorProfile": {+ "line": {+ "both": "{name} has no short bio or profile links",+ "bio": "{name} has no short bio",+ "links": "{name} has no profile links"+ },+ "detail": {+ "both": "Add them in Settings › Authors: two sentences on what they know, and a LinkedIn or other profile link.",+ "bio": "Add a short bio in Settings › Authors: two sentences on what they know.",+ "links": "Add a LinkedIn or other profile link in Settings › Authors."+ },+ "askOthers": {+ "both": "{member, select, yes {{name}, whoever added them or an admin can add a short bio and a profile link in Settings › Authors.} other {Whoever added {name} or an admin can add a short bio and a profile link in Settings › Authors.}}",+ "bio": "{member, select, yes {{name}, whoever added them or an admin can add a short bio in Settings › Authors.} other {Whoever added {name} or an admin can add a short bio in Settings › Authors.}}",+ "links": "{member, select, yes {{name}, whoever added them or an admin can add a profile link in Settings › Authors.} other {Whoever added {name} or an admin can add a profile link in Settings › Authors.}}"+ }+ },"avgSentence": {"line": "Sentences average {words, number} words","detail": "Aim for 15–20 words: shorter sentences read faster, and AI answers quote them whole.",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_author-menu.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_author-menu.tsxindex 9d1d9fdb4..1180c0c92 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_author-menu.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_author-menu.tsx@@ -37,19 +37,24 @@ export function AuthorMenu({authors,authorId,onPick,+ open,+ onOpenChange,}: {brandId: string;brandName: string;authors: ContentAuthor[];authorId: string | null;onPick: (authorId: string | null) => void;+ /** Open from outside too: Quality's Pick author. */+ open?: boolean;+ onOpenChange?: (open: boolean) => void;}) {const t = useTranslations('contentEditor.editor.author');const author = authors.find((a) => a.id === authorId) ?? null;const name = author?.name ?? t('organization', { brand: brandName });return (- <DropdownMenu>+ <DropdownMenu open={open} onOpenChange={(next) => onOpenChange?.(next)}><DropdownMenuTriggeraria-label={t('change', { name })}title={t('hint')}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 133c92e6c..916401332 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@@ -40,7 +40,7 @@ import {import { getContentAuthors } from '@/lib/actions/content-authors';import { stopAgentRun } from '@/lib/content/agent-runs-client';import { agentWriteRequest, useRuleDescriber } from '@/lib/content/agent-write';-import { authorInitials, type AuthorsRead } from '@/lib/content/authors';+import { authorInitials, canEditAuthor, type AuthorsRead } from '@/lib/content/authors';import {AGENT_POLL_MS,CONTENT_LIBRARY_PATH,@@ -74,6 +74,7 @@ import { PAGE_READ_DELAY_MS, draftTitleFromDoc, safeLinkHref } from '@/lib/conteimport { JsonLd } from '@/lib/content/json-ld-node';import { detectPageType } from '@/lib/content/page-types';import { BAND_CLASSES, qualityAverage, qualityBand, qualityPhase } from '@/lib/content/quality';+import { eeat } from '@/lib/content/quality-checks';import { readability } from '@/lib/content/readability';import { aiTracesFound, fanoutsToUse, lengthWarns, openRulesForAgent } from '@/lib/content/rules';import { saveBlob } from '@/lib/download';@@ -100,6 +101,7 @@ import { HistoryMenu } from './_history-menu';import { HtmlBlock, copyToClipboard } from './_html-block';import { OwnCopies, ownCopyHtml } from './_own-copies';import { PageInfoStrip, pageInfoKey } from './_page-info';+import type { QualityRead } from './_quality-tab';import { PageTypeMenu } from './_page-type-menu';import type { AgentRewrite } from './_brief-tab';import { ruleStatusDetail, type AgentFix, type PageRewrite } from './_rules-tab';@@ -416,7 +418,6 @@ export function DraftEditor({() => (qualityOn ? readability(pageHtml, language) : null),[qualityOn, pageHtml, language],);- const qualityScore = qualityAverage([readable?.score ?? null]);// Who the page is by (CE-038): page metadata, shown in the header and in a// Page info strip outside the page; with Quality's first phase.@@ -441,6 +442,26 @@ export function DraftEditor({const brandName =authorsRead?.brands.find((b) => b.id === draft.brandId)?.name ?? storeBrandName ?? '';const pageAuthor = authorsRead?.authors.find((a) => a.id === authorId) ?? null;+ // E-E-A-T from the author (CE-039): with Readability, the scores and the+ // header chip's average. Trust waits for a check that can read the page.+ const eeatScore = useMemo(+ () => (qualityOn && authorsRead ? eeat({ author: pageAuthor }) : null),+ [qualityOn, authorsRead, pageAuthor],+ );+ const qualityScore = qualityAverage([eeatScore?.score ?? null, readable?.score ?? null]);+ const quality: QualityRead | null = qualityOn+ ? {+ readability: readable,+ eeat: eeatScore,+ trust: null,+ author: pageAuthor,+ canEdit: !!pageAuthor && !!authorsRead && canEditAuthor(pageAuthor, authorsRead.me),+ hasAuthors: (authorsRead?.authors.length ?? 0) > 0,+ brandName,+ }+ : null;+ // Quality's Pick author opens the header's menu.+ const [authorMenuOpen, setAuthorMenuOpen] = useState(false);const byline = authorsRead? [t('author.by', {@@ -1452,6 +1473,8 @@ export function DraftEditor({authors={authorsRead.authors}authorId={authorId}onPick={(next) => void pickAuthor(next)}+ open={authorMenuOpen}+ onOpenChange={setAuthorMenuOpen}/>)}<DraftMethodBadge method={draft.method} />@@ -1663,8 +1686,10 @@ export function DraftEditor({}onBriefRebuilding={onBriefRebuilding}briefBlocked={agentBusy && !briefRebuilding ? t('suggestions.agentBusy') : null}- readability={readable}+ quality={quality}+ qualityScore={qualityScore}onShowInPage={showInPage}+ onPickAuthor={() => setAuthorMenuOpen(true)}/>) : (<EditorPanelRail onOpen={openPanelTab} />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 bb355cf87..46ef68aaa 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@@ -3,10 +3,20 @@ 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 { eeat } from '@/lib/content/quality-checks';+import type { ContentAuthor } from '@/lib/content/authors';import type { Readability } from '@/lib/content/readability';-import { QualityTab } from './_quality-tab';-/** Instructions › Quality (Quality spec §3, CE-039): the score, its label, what would raise it. */+vi.mock('@/i18n/navigation', () => ({+ Link: ({ href, ...props }: { href: string } & Record<string, unknown>) => (+ <a href={href} {...props} />+ ),+}));++const { QualityTab } = await import('./_quality-tab');+type QualityRead = import('./_quality-tab').QualityRead;++/** Instructions › Quality (Quality spec §3, CE-039): the scores, their label, what would raise them. */(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =true;@@ -33,15 +43,48 @@ const result: Readability = {],};+const ada: ContentAuthor = {+ id: 'a1',+ name: 'Ada Lovelace',+ title: null,+ bio: 'Writes about forecasting.',+ photoUrl: null,+ sameAs: ['https://www.linkedin.com/in/ada'],+ userId: null,+ createdBy: null,+ defaultFor: [],+ pages: null,+};++/** The page's quality with this author (or the team byline) and Readability. */+function read(+ readability: Readability | null,+ author: ContentAuthor | null = ada,+ hasAuthors = true,+ canEdit = true,+): QualityRead {+ return {+ readability,+ eeat: eeat({ author }),+ trust: null,+ author,+ canEdit,+ hasAuthors,+ brandName: 'Acme',+ };+}+let container: HTMLDivElement;let root: Root;const onShow = vi.fn();+const onPickAuthor = vi.fn();-async function render(readability: Readability | null) {+async function render(quality: QualityRead | Readability | null) {+ const q = quality && 'eeat' in quality ? quality : read(quality as Readability | null);await act(async () => {root.render(<NextIntlClientProvider locale="en" messages={messages}>- <QualityTab readability={readability} onShow={onShow} />+ <QualityTab quality={q} onShow={onShow} onPickAuthor={onPickAuthor} /></NextIntlClientProvider>,);});@@ -49,15 +92,19 @@ async function render(readability: Readability | null) {beforeEach(() => {onShow.mockReset();+ onPickAuthor.mockReset();container = document.createElement('div');root = createRoot(container);});afterEach(() => act(() => root.unmount()));describe('QualityTab', () => {- it('shows the score with its band, labelled an Ansvisor estimate', async () => {+ it('shows the three scores with their bands, labelled an Ansvisor estimate', async () => {await render(result);const scores = container.querySelector('[aria-label="Quality scores"]')!;+ expect(scores.textContent).toContain('E-E-A-T100Strong');+ // No Trust check is live for a page without agent claims: no fake points.+ expect(scores.textContent).toContain('TrustNot scored yet');expect(scores.textContent).toContain('Readability71Can improve');expect(scores.textContent).toContain("Ansvisor estimates based on Google's published quality signals. Not a Google score.",@@ -96,7 +143,65 @@ describe('QualityTab', () => {score: 100,checks: result.checks.map((c) => ({ ...c, points: c.max })),});- expect(container.textContent).toContain('Nothing to raise here: the page reads well.');+ expect(container.textContent).toContain('Nothing to raise here for now');+ });++ it('asks for a real author when the page is by the team, and opens the menu', async () => {+ await render(read(result, null));+ const scores = container.querySelector('[aria-label="Quality scores"]')!;+ expect(scores.textContent).toContain('E-E-A-T0Needs work');+ const first = container.querySelector('li')!;+ expect(first.textContent).toBe(+ '+60 E-E-A-TThe page is by Acme Team, not a personPick the person who wrote it: a named author with a short bio and profile links shows who stands behind the page.Pick author',+ );+ await act(async () => first.querySelector('button')!.click());+ expect(onPickAuthor).toHaveBeenCalled();+ });++ it("asks to complete the author's profile in Settings › Authors", async () => {+ await render(read(result, { ...ada, bio: null, sameAs: [] }));+ const row = [...container.querySelectorAll('li')].find((li) =>+ li.textContent?.includes('Ada Lovelace'),+ )!;+ expect(row.textContent).toContain('+40 E-E-A-TAda Lovelace has no short bio or profile links');+ expect(row.querySelector('a')!.getAttribute('href')).toBe('/dashboard/settings/authors');+ });++ it("says who can complete the profile when the reader can't edit the author", async () => {+ await render(read(result, { ...ada, bio: null }, true, false));+ const row = [...container.querySelectorAll('li')].find((li) =>+ li.textContent?.includes('Ada Lovelace'),+ )!;+ expect(row.textContent).toContain('Ada Lovelace has no short bio');+ expect(row.textContent).toContain(+ 'Whoever added Ada Lovelace or an admin can add a short bio in Settings › Authors.',+ );+ expect(row.querySelector('a')).toBeNull();+ expect(row.querySelector('button')).toBeNull();+ });++ it('names the author among who can when they are a member', async () => {+ await render(read(result, { ...ada, sameAs: [], userId: 'u2' }, true, false));+ const row = [...container.querySelectorAll('li')].find((li) =>+ li.textContent?.includes('Ada Lovelace'),+ )!;+ expect(row.textContent).toContain(+ 'Ada Lovelace, whoever added them or an admin can add a profile link in Settings › Authors.',+ );+ expect(row.querySelector('a')).toBeNull();+ });++ it('sends to Settings › Authors when the workspace has no author yet', async () => {+ await render(read(result, null, false));+ const row = container.querySelector('li')!;+ expect(row.querySelector('a')!.textContent).toBe('Add author');+ expect(row.querySelector('a')!.getAttribute('href')).toBe('/dashboard/settings/authors');+ });++ it('says only that a short page is too short, with nothing else to raise', async () => {+ await render(read({ score: null, checks: [], words: 12 }));+ expect(container.textContent).toContain('Write a few paragraphs');+ expect(container.textContent).not.toContain('Nothing to raise');});it('says when the page’s language isn’t read yet, not that it is too short', async () => {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 1ff0cc5b0..a0c6a2f2f 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@@ -1,8 +1,16 @@'use client';import { useTranslations } from 'next-intl';-import { Button } from '@/components/ui/button';+import { Link } from '@/i18n/navigation';+import { Button, buttonVariants } from '@/components/ui/button';+import type { ContentAuthor } from '@/lib/content/authors';import { BAND_CLASSES, qualityBand } from '@/lib/content/quality';+import {+ authorProfile,+ scoreGain,+ type EeatCheckId,+ type Score,+} from '@/lib/content/quality-checks';import {readabilityGain,SECTION_WORDS,@@ -10,99 +18,234 @@ import {type ReadabilityCheck,} from '@/lib/content/readability';import { cn } from '@/lib/utils';+import { MANAGE_AUTHORS_PATH } from './_author-menu';++/** What Quality reads from the draft and its author, for the segment and the header. */+export interface QualityRead {+ /** The page's Readability as written, or null before it is read. */+ readability: Readability | null;+ /** E-E-A-T from the author, or null before the authors are read. */+ eeat: Score<EeatCheckId> | null;+ /** Trust, or null while none of its checks is live for the page. */+ trust: Score | null;+ /** The page's author, or null for the organization byline. */+ author: ContentAuthor | null;+ /** Whether the member reading may edit that author in Settings › Authors. */+ canEdit: boolean;+ /** Whether the workspace has an author to pick (Settings › Authors). */+ hasAuthors: boolean;+ brandName: string;+}++type ScoreName = 'eeat' | 'trust' | 'readability';++interface Suggestion {+ key: string;+ score: ScoreName;+ gain: number;+ line: string;+ detail: string;+ action:+ | { kind: 'show'; text: string }+ | { kind: 'pickAuthor' }+ | { kind: 'manageAuthors'; label: 'addAuthor' | 'editAuthor' }+ | { kind: 'none' };+}/**- * Instructions › Quality (Quality spec §3, CE-039): the scores read from the- * draft, each labelled an Ansvisor estimate, then what would raise them, the- * biggest gain first. Phase 1 reads Readability; E-E-A-T and Trust join as- * their checks go live.+ * Instructions › Quality (Quality spec §3, CE-039): the three scores read+ * from the draft and its author, each labelled an Ansvisor estimate, then+ * what would raise them, the biggest gain first. A score shows once one of+ * its checks is live for the page.*/export function QualityTab({- readability,+ quality,onShow,+ onPickAuthor,}: {- /** The draft's Readability as written, or null before it is read. */- readability: Readability | null;+ quality: QualityRead;/** Scrolls the draft to a passage and marks it. */onShow: (text: string) => void;+ /** Opens the header's author menu. */+ onPickAuthor: () => void;}) {const t = useTranslations('contentEditor.editor.quality');- const score = readability?.score ?? null;- const suggestions = (readability?.checks ?? [])- .map((check) => ({ check, gain: readabilityGain(readability!, check.id) }))- .filter(({ gain }) => gain > 0)+ const tAuthor = useTranslations('contentEditor.editor.author');+ const { readability, eeat, trust } = quality;+ const scores: { name: ScoreName; score: number | null; empty: string }[] = [+ { name: 'eeat', score: eeat?.score ?? null, empty: t('notScored') },+ { name: 'trust', score: trust?.score ?? null, empty: t('notScored') },+ { name: 'readability', score: readability?.score ?? null, empty: t('tooShortShort') },+ ];+ const suggestions = [+ ...readabilitySuggestions(t, readability),+ ...eeatSuggestions(t, quality, tAuthor('organization', { brand: quality.brandName })),+ ]+ .filter((s) => s.gain > 0).sort((a, b) => b.gain - a.gain);return (<div className="space-y-4 text-sm"><section aria-label={t('scores')} className="space-y-2">- {score === null ? (+ <div className="grid grid-cols-3 gap-2">+ {scores.map(({ name, score, empty }) => (+ <div key={name} className="min-w-0 rounded-xl border bg-card px-2.5 py-2">+ <p className="truncate text-xs text-muted-foreground">{t(`names.${name}`)}</p>+ {score === null ? (+ <p className="mt-0.5 text-xs text-muted-foreground">{empty}</p>+ ) : (+ <p className="mt-0.5 flex flex-wrap items-center gap-x-1.5 gap-y-0.5">+ <span className="text-xl font-semibold tabular-nums">{score}</span>+ <span+ className={cn(+ 'rounded-full border px-1.5 text-[10.5px] font-medium',+ BAND_CLASSES[qualityBand(score)],+ )}+ >+ {t(`bands.${qualityBand(score)}`)}+ </span>+ </p>+ )}+ </div>+ ))}+ </div>+ <p className="text-xs text-muted-foreground">{t('estimate')}</p>+ {readability?.score === null && (<p className="rounded-xl border border-dashed px-3 py-2.5 text-xs text-muted-foreground">{t(readability?.unscored === 'language' ? 'notThisLanguage' : 'tooShort')}</p>- ) : (- <div className="flex flex-wrap gap-2">- <div className="min-w-[8.5rem] rounded-xl border bg-card px-3 py-2">- <p className="text-xs text-muted-foreground">{t('names.readability')}</p>- <p className="mt-0.5 flex items-center gap-2">- <span className="text-xl font-semibold tabular-nums">{score}</span>- <span- className={cn(- 'rounded-full border px-2 text-[11px] font-medium',- BAND_CLASSES[qualityBand(score)],- )}- >- {t(`bands.${qualityBand(score)}`)}- </span>- </p>- </div>- </div>)}- <p className="text-xs text-muted-foreground">{t('estimate')}</p></section>- {score !== null && (- <section aria-label={t('suggestionsLabel')} className="space-y-2">- <h4 className="text-xs font-medium text-muted-foreground">{t('suggestionsLabel')}</h4>- {suggestions.length === 0 ? (+ <section aria-label={t('suggestionsLabel')} className="space-y-2">+ <h4 className="text-xs font-medium text-muted-foreground">{t('suggestionsLabel')}</h4>+ {suggestions.length === 0 ? (+ // A page too short to read says so above.+ readability?.score !== null && (<p className="text-xs text-muted-foreground">{t('nothingToRaise')}</p>- ) : (- <ul className="space-y-2">- {suggestions.map(({ check, gain }) => (- <li- key={check.id}- className="flex items-start gap-2.5 rounded-xl border px-3 py-2.5"- >- <span className="mt-0.5 shrink-0 rounded-md bg-emerald-50 px-1.5 text-[11px] font-medium text-emerald-700 tabular-nums dark:bg-emerald-950 dark:text-emerald-300">- {t('gain', { gain, score: t('names.readability') })}- </span>- <div className="min-w-0 flex-1">- <p className="font-medium [overflow-wrap:anywhere]">{line(t, check)}</p>- <p className="text-xs text-muted-foreground">{detail(t, check)}</p>- </div>- {check.at && (- <Button- variant="outline"- size="sm"- className="h-7 shrink-0"- onClick={() => onShow(check.at!)}- >- {t('show')}- </Button>- )}- </li>- ))}- </ul>- )}- </section>- )}+ )+ ) : (+ <ul className="space-y-2">+ {suggestions.map((s) => (+ <li key={s.key} className="flex items-start gap-2.5 rounded-xl border px-3 py-2.5">+ <span className="mt-0.5 shrink-0 rounded-md bg-emerald-50 px-1.5 text-[11px] font-medium text-emerald-700 tabular-nums dark:bg-emerald-950 dark:text-emerald-300">+ {t('gain', { gain: s.gain, score: t(`names.${s.score}`) })}+ </span>+ <div className="min-w-0 flex-1">+ <p className="font-medium [overflow-wrap:anywhere]">{s.line}</p>+ <p className="text-xs text-muted-foreground">{s.detail}</p>+ </div>+ <SuggestionAction action={s.action} onShow={onShow} onPickAuthor={onPickAuthor} />+ </li>+ ))}+ </ul>+ )}+ </section></div>);}+/** A suggestion's one button. */+function SuggestionAction({+ action,+ onShow,+ onPickAuthor,+}: {+ action: Suggestion['action'];+ onShow: (text: string) => void;+ onPickAuthor: () => void;+}) {+ const t = useTranslations('contentEditor.editor.quality');+ switch (action.kind) {+ case 'show':+ return (+ <Button+ variant="outline"+ size="sm"+ className="h-7 shrink-0"+ onClick={() => onShow(action.text)}+ >+ {t('show')}+ </Button>+ );+ case 'pickAuthor':+ return (+ <Button variant="outline" size="sm" className="h-7 shrink-0" onClick={onPickAuthor}>+ {t('pickAuthor')}+ </Button>+ );+ case 'manageAuthors':+ return (+ <Link+ href={MANAGE_AUTHORS_PATH}+ className={cn(buttonVariants({ variant: 'outline', size: 'sm' }), 'h-7 shrink-0')}+ >+ {t(action.label)}+ </Link>+ );+ case 'none':+ return null;+ }+}+type T = ReturnType<typeof useTranslations<'contentEditor.editor.quality'>>;-/** A check's one line: what the draft does now. */+function readabilitySuggestions(t: T, readability: Readability | null): Suggestion[] {+ if (!readability || readability.score === null) return [];+ return readability.checks.map(+ (check): Suggestion => ({+ key: `readability:${check.id}`,+ score: 'readability',+ gain: readabilityGain(readability, check.id),+ line: line(t, check),+ detail: detail(t, check),+ action: check.at ? { kind: 'show', text: check.at } : { kind: 'none' },+ }),+ );+}++/**+ * E-E-A-T's: with no person on the page, picking one is the fix (its gain is+ * the byline's: what the author's profile adds depends on them), or adding+ * one when the workspace has none; with one, completing their profile. Only+ * whoever added the author, the author themself or an admin can, so anyone+ * else is told who to ask instead of being sent where they can't edit.+ */+function eeatSuggestions(t: T, quality: QualityRead, teamByline: string): Suggestion[] {+ const { eeat, author, canEdit, hasAuthors } = quality;+ if (!eeat || eeat.score === null) return [];+ if (!author) {+ return [+ {+ key: 'eeat:byline',+ score: 'eeat',+ gain: scoreGain(eeat, ['byline']),+ line: t('checks.byline.line', { byline: teamByline }),+ detail: t('checks.byline.detail'),+ action: hasAuthors ? { kind: 'pickAuthor' } : { kind: 'manageAuthors', label: 'addAuthor' },+ },+ ];+ }+ const { bio, links } = authorProfile(author);+ const missing = !bio && !links ? 'both' : !bio ? 'bio' : 'links';+ return [+ {+ key: 'eeat:authorProfile',+ score: 'eeat',+ gain: scoreGain(eeat, ['authorBio']),+ line: t(`checks.authorProfile.line.${missing}`, { name: author.name }),+ detail: canEdit+ ? t(`checks.authorProfile.detail.${missing}`)+ : t(`checks.authorProfile.askOthers.${missing}`, {+ name: author.name,+ member: author.userId ? 'yes' : 'no',+ }),+ action: canEdit ? { kind: 'manageAuthors', label: 'editAuthor' } : { kind: 'none' },+ },+ ];+}++/** A Readability check's one line: what the draft does now. */function line(t: T, check: ReadabilityCheck): string {switch (check.id) {case 'avgSentence':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.tsxindex 435712308..1861fb178 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@@ -7,12 +7,11 @@ import { isPageType, type ContentDraft } from '@/lib/content/drafts';import { buildSourceGroups, includedCounts, type DraftSourceKind } from '@/lib/content/sources';import { formatNumber } from '@/lib/format';import { BAND_CLASSES, qualityBand, qualityPhase } from '@/lib/content/quality';-import type { Readability } from '@/lib/content/readability';import { cn } from '@/lib/utils';import { BriefTab, type AgentRewrite } from './_brief-tab';import { DataNote, UsesYourData } from './_data-note';import { ImpactTab } from './_impact-tab';-import { QualityTab } from './_quality-tab';+import { QualityTab, type QualityRead } from './_quality-tab';import { RulesTab, type AgentFix, type PageRewrite } from './_rules-tab';import { SourcesTab } from './_sources-tab';import { useBriefRebuild, type PageNow } from './_use-brief-rebuild';@@ -119,8 +118,10 @@ export function EditorSidePanel({onSourceShown,onBriefRebuilding,briefBlocked = null,- readability = null,+ quality = null,+ qualityScore = null,onShowInPage,+ onPickAuthor,}: {draft: ContentDraft;/** The draft's title, page and type as written now: Sources and Brief read them. */@@ -154,10 +155,14 @@ export function EditorSidePanel({onBriefRebuilding?: (rebuilding: boolean) => void;/** Why the brief's Run Agent waits (another agent run from this page), or null. */briefBlocked?: string | null;- /** The draft's Readability as written, for Quality (CE-036/039). */- readability?: Readability | null;+ /** What Quality reads from the draft and its author (CE-036/039), with Quality on. */+ quality?: QualityRead | null;+ /** The scores' average, as the header's chip shows it. */+ qualityScore?: number | null;/** Scrolls the draft to a passage and marks it: Quality's Show. */onShowInPage?: (text: string) => void;+ /** Opens the header's author menu: Quality's Pick author. */+ onPickAuthor?: () => void;}) {const t = useTranslations('contentEditor.editor.panel');const tEditor = useTranslations('contentEditor.editor');@@ -182,7 +187,6 @@ export function EditorSidePanel({const rulesOpen = Math.max(0, rules.total - rules.met);// Quality shows once its first phase is live (NEXT_PUBLIC_CONTENT_QUALITY_PHASE).const segments = SEGMENTS.filter((value) => value !== 'quality' || qualityPhase() >= 1);- const qualityScore = readability?.score ?? null;// The sources the agent writes from, as the Sources tab keeps them (v1.1// CE-032/034): counted under each Run Agent and on the tab, so turning one@@ -355,9 +359,13 @@ export function EditorSidePanel({/></div>)}- {opened.has('quality') && (+ {opened.has('quality') && quality && (<div hidden={segment !== 'quality'}>- <QualityTab readability={readability} onShow={(text) => onShowInPage?.(text)} />+ <QualityTab+ quality={quality}+ onShow={(text) => onShowInPage?.(text)}+ onPickAuthor={() => onPickAuthor?.()}+ /></div>)}{opened.has('rules') && (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 c04de76dc..c33480d10 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@@ -2358,6 +2358,27 @@ describe('the side panel', () => {);});+ it("scores E-E-A-T from the author, and Quality's Pick author opens the menu", async () => {+ process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '1';+ getContentDraft.mockResolvedValue(draft({ authorId: null }));+ window.innerWidth = 1440;+ await renderPage();+ await act(async () =>+ [...container.querySelectorAll<HTMLButtonElement>('header button')]+ .find((b) => b.textContent?.startsWith('Quality'))!+ .click(),+ );+ const scores = panel()!.querySelector('[aria-label="Quality scores"]')!;+ expect(scores.textContent).toContain('E-E-A-T0Needs work');+ expect(scores.textContent).toContain('TrustNot scored yet');++ const pick = [...panel()!.querySelectorAll<HTMLButtonElement>('button')].find(+ (b) => b.textContent === 'Pick author',+ )!;+ await act(async () => pick.click());+ expect(document.querySelectorAll('[role="menuitemradio"]').length).toBe(2);+ });+it('sets the organization byline, and goes back when that fails', async () => {process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '1';getContentDraft.mockResolvedValue(draft({ authorId: 'a1' }));diff --git a/web/src/components/settings/authors-section.tsx b/web/src/components/settings/authors-section.tsxindex 7d1c94119..bc3340f7c 100644--- a/web/src/components/settings/authors-section.tsx+++ b/web/src/components/settings/authors-section.tsx@@ -34,6 +34,7 @@ import {} from '@/lib/actions/content-authors';import {authorInitials,+ canEditAuthor,MAX_LINK_LENGTH,MAX_PROFILES,type AuthorInput,@@ -80,8 +81,7 @@ export function AuthorsSection() {}, [load]);const me = read?.me.id;- const canEdit = (author: ContentAuthor) =>- !!read && (author.userId === me || author.createdBy === me || read.me.role === 'admin');+ const canEdit = (author: ContentAuthor) => !!read && canEditAuthor(author, read.me);const canSetDefaults = read?.me.role === 'admin' || read?.me.role === 'manager';const defaultOf = (brandId: string) =>picking[brandId] ??diff --git a/web/src/lib/content/authors.test.ts b/web/src/lib/content/authors.test.tsnew file mode 100644index 000000000..8fd74108e--- /dev/null+++ b/web/src/lib/content/authors.test.ts@@ -0,0 +1,32 @@+import { describe, expect, it } from 'vitest';+import { canEditAuthor, type ContentAuthor } from './authors';++/** Who may edit an author: the same rule as content_authors' update policy. */++const ada: ContentAuthor = {+ id: 'a1',+ name: 'Ada Lovelace',+ title: null,+ bio: null,+ photoUrl: null,+ sameAs: [],+ userId: 'u-ada',+ createdBy: 'u-bob',+ defaultFor: [],+ pages: null,+};++describe('canEditAuthor', () => {+ it('lets whoever added the author, the author themself and admins edit it', () => {+ expect(canEditAuthor(ada, { id: 'u-bob', role: 'analyst' })).toBe(true);+ expect(canEditAuthor(ada, { id: 'u-ada', role: 'analyst' })).toBe(true);+ expect(canEditAuthor(ada, { id: 'u-cal', role: 'admin' })).toBe(true);+ });++ it('keeps other members out, managers included', () => {+ expect(canEditAuthor(ada, { id: 'u-cal', role: 'manager' })).toBe(false);+ expect(+ canEditAuthor({ ...ada, userId: null, createdBy: null }, { id: 'u-cal', role: 'analyst' }),+ ).toBe(false);+ });+});diff --git a/web/src/lib/content/authors.ts b/web/src/lib/content/authors.tsindex 3ee506f15..439afa27e 100644--- a/web/src/lib/content/authors.ts+++ b/web/src/lib/content/authors.ts@@ -40,6 +40,14 @@ export function authorInitials(name: string): string {.join('');}+/**+ * Whether the member reading may edit an author: whoever added it, the+ * author themself or an admin, as the table's update policy says.+ */+export function canEditAuthor(author: ContentAuthor, me: AuthorsRead['me']): boolean {+ return author.userId === me.id || author.createdBy === me.id || me.role === 'admin';+}+/** The most profile links an author keeps (00256). */export const MAX_PROFILES = 10;/** The longest profile link; the table checks it too, with https (content_author_links_ok). */diff --git a/web/src/lib/content/quality-checks.test.ts b/web/src/lib/content/quality-checks.test.tsnew file mode 100644index 000000000..f3189b70f--- /dev/null+++ b/web/src/lib/content/quality-checks.test.ts@@ -0,0 +1,44 @@+import { describe, expect, it } from 'vitest';+import type { ContentAuthor } from './authors';+import { EEAT_WEIGHTS, authorProfile, eeat, scoreGain } from './quality-checks';++const author = (over: Partial<ContentAuthor> = {}): ContentAuthor => ({+ id: 'a1',+ name: 'Ada Lovelace',+ title: 'Head of Content',+ bio: 'Writes about forecasting.',+ photoUrl: null,+ sameAs: ['https://www.linkedin.com/in/ada'],+ userId: null,+ createdBy: null,+ defaultFor: [],+ pages: null,+ ...over,+});++describe('eeat (Phase 1: the author)', () => {+ it('gives a real author with a bio and profile links every live point', () => {+ const result = eeat({ author: author() });+ expect(result.score).toBe(100);+ // Schema waits for Before you publish's JSON-LD, dates for the live page.+ expect(result.checks).toEqual([+ { id: 'byline', points: EEAT_WEIGHTS.byline, max: EEAT_WEIGHTS.byline },+ { id: 'authorBio', points: EEAT_WEIGHTS.authorBio, max: EEAT_WEIGHTS.authorBio },+ ]);+ });++ it('gives the organization byline none: it is no person', () => {+ const result = eeat({ author: null });+ expect(result.score).toBe(0);+ expect(scoreGain(result, ['byline'])).toBe(60);+ });++ it('gives half the profile points for a bio or links alone', () => {+ // byline 15 + bio 5 of 25.+ expect(eeat({ author: author({ sameAs: [] }) }).score).toBe(80);+ const bare = eeat({ author: author({ bio: ' ', sameAs: [] }) });+ expect(bare.score).toBe(60);+ expect(scoreGain(bare, ['authorBio'])).toBe(40);+ expect(authorProfile(author({ bio: ' ' }))).toEqual({ bio: false, links: true });+ });+});diff --git a/web/src/lib/content/quality-checks.ts b/web/src/lib/content/quality-checks.tsnew file mode 100644index 000000000..7d7d82d9a--- /dev/null+++ b/web/src/lib/content/quality-checks.ts@@ -0,0 +1,74 @@+import type { ContentAuthor } from './authors';++/**+ * E-E-A-T and Trust (Content Editor Quality spec §2.1, §2.2): checks read+ * from the page's facts, each worth its points. Only the checks live in the+ * current phase count; the score is the share of their points, out of 100,+ * and a score with no live check isn't given at all (no fake points).+ */++export interface ScoreCheck<Id extends string = string> {+ id: Id;+ points: number;+ max: number;+}++export interface Score<Id extends string = string> {+ /** 0–100, or null when no check of it is live for this page yet. */+ score: number | null;+ checks: ScoreCheck<Id>[];+}++/** E-E-A-T's checks and points (blog defaults); Phase 1 reads the author's. */+export const EEAT_WEIGHTS = {+ experience: 20,+ originalData: 15,+ byline: 15,+ authorBio: 10,+ visualProof: 10,+ whoHowWhy: 10,+ dates: 10,+ authorSchema: 10,+} as const;+export type EeatCheckId = keyof typeof EEAT_WEIGHTS;++function scoreOf<Id extends string>(checks: ScoreCheck<Id>[]): Score<Id> {+ const max = checks.reduce((sum, c) => sum + c.max, 0);+ if (max === 0) return { score: null, checks };+ const points = checks.reduce((sum, c) => sum + c.points, 0);+ return { score: Math.round((points / max) * 100), checks };+}++/**+ * The score's rise if the checks named came out in full: the gain chip of a+ * suggestion. Zero when they already have their points.+ */+export function scoreGain<Id extends string>(result: Score<Id>, ids: Id[]): number {+ if (result.score === null) return 0;+ const raised = result.checks.map((c) => (ids.includes(c.id) ? { ...c, points: c.max } : c));+ return (scoreOf(raised).score ?? 0) - result.score;+}++/** What an author's profile has: a short bio, and profile links (Person schema's sameAs). */+export function authorProfile(author: ContentAuthor | null): { bio: boolean; links: boolean } {+ return { bio: !!author?.bio?.trim(), links: (author?.sameAs.length ?? 0) > 0 };+}++/**+ * E-E-A-T from the page's author (CE-038): a real person, with a short bio+ * and profile links. The organization byline is no person. Author schema+ * joins when Before you publish writes the page's JSON-LD (CE-041), dates+ * when the live page is read (CE-042); experience, data, proof and+ * who/how/why are Phase 2.+ */+export function eeat({ author }: { author: ContentAuthor | null }): Score<EeatCheckId> {+ const { bio, links } = authorProfile(author);+ return scoreOf<EeatCheckId>([+ { id: 'byline', points: author ? EEAT_WEIGHTS.byline : 0, max: EEAT_WEIGHTS.byline },+ {+ id: 'authorBio',+ points: author ? (EEAT_WEIGHTS.authorBio * ((bio ? 1 : 0) + (links ? 1 : 0))) / 2 : 0,+ max: EEAT_WEIGHTS.authorBio,+ },+ ]);+}