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
fix(content): show the brand's cited pages as an Overview, not an overlap warning (#1320)
Cihan8da6780d09d3
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 3ae5e0be3..1657db859 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -3102,8 +3102,7 @@"cards": {"create": { "title": "Create", "hint": "New pages AI needs" },"optimize": { "title": "Optimize", "hint": "Pages losing ground" },- "protect": { "title": "Protect", "hint": "Top pages · edit with care" },- "overlaps": { "title": "Overlaps", "hint": "Pages competing for the same prompts" }+ "protect": { "title": "Protect", "hint": "Top pages · edit with care" }},"results": {"label": "From AI visits · {days} full days to yesterday (UTC):",@@ -3131,7 +3130,7 @@"none": "No page reads as losing ground yet: tracking began {since}, so the {days} days before aren't tracked to compare with.","partial": "The {days} days before are tracked only since {since}: pages are compared per tracked answer."},- "ranked": "Ranked by impact · overlaps checked",+ "ranked": "Ranked by impact","filtered": "Filtered · click it again to clear","columns": {"page": "Page",@@ -3141,14 +3140,11 @@"start": "Start"},"newPage": "New page",- "overlap": "⚠ Overlap",- "overlapHint": "{count, plural, one {# other page of yours is} other {# other pages of yours are}} cited for the same prompts","actions": { "create": "Create", "optimize": "Optimize", "protect": "Protect" },"sources": {"opportunity": "Opportunity","citations": "Citations",- "protect": "Protect",- "overlap": "Overlap"+ "protect": "Protect"},"why": {"competitors": "{names} cited · you aren't",@@ -3156,8 +3152,7 @@"opportunity": "{count, plural, =0 {A page AI needs} one {Answers # prompt AI asks} other {Answers # prompts AI asks}}","citationsDown": "Citation rate −{pct}%","on": "on {platforms}",- "top": "Top page · {citations, plural, one {{citationsText} citation} other {{citationsText} citations}} · {visits, plural, one {{visitsText} AI visit} other {{visitsText} AI visits}}",- "overlap": "Competes with {count, plural, one {# of your pages} other {# of your pages}} for the same prompts"+ "top": "Top page · {citations, plural, one {{citationsText} citation} other {{citationsText} citations}} · {visits, plural, one {{visitsText} AI visit} other {{visitsText} AI visits}}"},"who": { "you": "You", "agent": "Agent", "team": "Teammate" },"start": { "create": "Create", "optimize": "Optimize", "protect": "View" },@@ -3333,15 +3328,13 @@}},"overlap": {- "label": "Overlap check",- "checking": "Checking your pages that answer the same prompts…",- "failed": "Couldn't check for overlapping pages.",+ "label": "Overview",+ "checking": "Reading your pages AI cites for these prompts…",+ "failed": "Couldn't read your pages cited for these prompts.","retry": "Try again",- "none": "No existing page answers these prompts",+ "none": "None of your pages is cited for these prompts yet","noPrompts": "No tracked prompts to check this against yet",- "safe": "Safe to create",- "covered": "An existing page already answers these prompts",- "partial": "{count, plural, one {# existing page answers} other {# existing pages answer}} some of these prompts",+ "cited": "{count, plural, one {# of your pages is} other {# of your pages are}} cited for these prompts","columns": {"page": "Page","prompts": "Same prompts",@@ -3349,7 +3342,6 @@"google": "Google pos."},"promptsValue": "{count} of {total}",- "recommended": "Recommended","options": {"optimizeGiven": {"title": "Optimize {page}",@@ -3361,21 +3353,8 @@"reasonRanked": "It already answers {count} of {total} prompts, is cited {citations}× and ranks #{position} on Google"},"createNew": {- "title": "Create a new page instead",- "reason": "Write a new page for these prompts"- },- "createAnyway": {- "title": "Create a new page anyway",- "reason": "Risk: two pages compete for the same prompts"- },- "createLinked": {- "title": "Create a new page, link {page} to it",- "titleMany": "Create a new page, link these pages to it",- "reason": "One clear page for these prompts"- },- "addSection": {- "title": "Add a section to {page}",- "reason": "A smaller change than a new page"+ "title": "Create a new page",+ "reason": "Another page of yours for AI to cite"}}}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-table.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-table.tsxindex 3be00d380..8b68d5ae3 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-table.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-table.tsx@@ -78,14 +78,6 @@ export function PlanTable({<span className="truncate" title={row.page ?? undefined}>{row.page ? pagePath(row.page) : t('newPage')}</span>- {row.overlaps > 0 && (- <span- className="shrink-0 font-medium text-amber-700 dark:text-amber-400"- title={t('overlapHint', { count: row.overlaps })}- >- {t('overlap')}- </span>- )}</p></TableCell><TableCell>@@ -180,7 +172,5 @@ function WhyText({ why }: { why: PlanWhy }) {})}</span>);- case 'overlap':- return <span>{t('overlap', { count: why.pages })}</span>;}}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.test.tsxindex e93b209cf..505ad9888 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.test.tsx@@ -47,7 +47,6 @@ const page = (path: string, over: Partial<PlanPage> = {}): PlanPage => ({citations: { cur: 2, prev: 2 },platformsDown: [],aiVisits: 0,- overlaps: 0,...over,});const opportunity: PlanOpportunity = {@@ -73,7 +72,6 @@ const PLAN = {title: 'Espresso guide',citations: { cur: 12, prev: 10 },aiVisits: 42,- overlaps: 1,}),],answers: { cur: 100, prev: 100 },@@ -151,7 +149,8 @@ describe('the Content plan', () => {expect(button('Create').textContent).toBe('Create1New pages AI needs');expect(button('Optimize').textContent).toBe('Optimize1Pages losing ground');expect(button('Protect').textContent).toBe('Protect1Top pages · edit with care');- expect(button('Overlaps').textContent).toBe('Overlaps1Pages competing for the same prompts');+ // Pages cited for the same prompts are no warning: no Overlaps card.+ expect(button('Overlaps')).toBeUndefined();expect(rowTexts()).toEqual([[@@ -165,7 +164,7 @@ describe('the Content plan', () => {'Citation rate −70% on ChatGPT and PerplexityCitations',],[- 'Espresso guideHow-to guide/guides/espresso⚠ Overlap',+ 'Espresso guideHow-to guide/guides/espresso','Protect','Top page · 12 citations · 42 AI visitsProtect',],@@ -175,12 +174,12 @@ describe('the Content plan', () => {it('filters the list by a card, and clears it on a second click', async () => {await renderPage();- await act(async () => button('Overlaps').click());- expect(button('Overlaps').getAttribute('aria-pressed')).toBe('true');+ await act(async () => button('Protect').click());+ expect(button('Protect').getAttribute('aria-pressed')).toBe('true');expect(rowTexts().map((r) => r[1])).toEqual(['Protect']);expect(container.textContent).toContain('Filtered · click it again to clear');- await act(async () => button('Overlaps').click());+ await act(async () => button('Protect').click());expect(rowTexts()).toHaveLength(3);});@@ -336,7 +335,7 @@ describe('the Content plan', () => {expect(guide().getAttribute('aria-pressed')).toBe('true');expect(rowTexts().map((r) => r[0])).toEqual(['Coffee subscriptionsHow-to guide/guides/coffee-subscriptions',- 'Espresso guideHow-to guide/guides/espresso⚠ Overlap',+ 'Espresso guideHow-to guide/guides/espresso',]);await act(async () => guide().click());expect(rowTexts()).toHaveLength(3);@@ -365,7 +364,7 @@ describe('the Content plan', () => {'section[aria-labelledby="plan-mix-title"] li button',)!;await act(async () => guide().click());- await act(async () => button('Overlaps').click());+ await act(async () => button('Protect').click());expect(rowTexts()).toHaveLength(1);// The 7 days' mix has no guide: the list isn't filtered by it.@@ -376,15 +375,15 @@ describe('the Content plan', () => {],});await act(async () => button('Last 7 days').click());- await act(async () => button('Overlaps').click());+ await act(async () => button('Protect').click());expect(container.textContent).not.toContain('Filtered');expect(rowTexts()).toHaveLength(3);- await act(async () => button('Overlaps').click());+ await act(async () => button('Protect').click());brandState.activeBrandId = 'brand-2';brandState.brands.push({ id: 'brand-2', siteType: 'b2b' });await renderPage();- expect(button('Overlaps').getAttribute('aria-pressed')).toBe('false');+ expect(button('Protect').getAttribute('aria-pressed')).toBe('false');brandState.brands.pop();});diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsxindex 6fd801579..c2009946a 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsx@@ -41,17 +41,16 @@ type InsightsRead = {data: Awaited<ReturnType<typeof getContentPlanInsights>>;};-/** Each card's color, as its action's tag: Create blue, Optimize amber, Protect green, Overlaps red. */+/** Each card's color, as its action's tag: Create blue, Optimize amber, Protect green. */const CARD_DOT: Record<PlanCard, string> = {create: 'bg-blue-600 dark:bg-blue-400',optimize: 'bg-amber-600 dark:bg-amber-400',protect: 'bg-green-600 dark:bg-green-400',- overlaps: 'bg-red-600 dark:bg-red-400',};/*** The Content plan (Content Editor CE-014, spec v2 §4): what to create,- * optimize or protect next, for the last 7, 30 or 90 days. Four cards count+ * optimize or protect next, for the last 7, 30 or 90 days. Three cards count* the work and filter the list, as a row of the page-type mix does; the list* ranks it, and each row starts it in New content (Start for an opportunity,* an existing page read to optimize) or opens the draft already being@@ -224,7 +223,7 @@ export default function ContentPlanPage() {onSent={() => setAttempt((n) => n + 1)}/>- <div className="grid grid-cols-2 gap-3 lg:grid-cols-4">+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-3">{PLAN_CARDS.map((value) => (<buttonkey={value}diff --git a/web/src/components/content/new-content-dialog.test.tsx b/web/src/components/content/new-content-dialog.test.tsxindex b6b8da245..c3aba6224 100644--- a/web/src/components/content/new-content-dialog.test.tsx+++ b/web/src/components/content/new-content-dialog.test.tsx@@ -313,8 +313,7 @@ describe('New content', () => {expect(document.body.textContent).toContain('Optimize: Pricing');});- it('starts an opportunity for an existing page on that page, whatever the check recommends', async () => {- // The check would recommend a new page: no page of the brand answers the prompts.+ it('starts an opportunity for an existing page on that page, whatever else is cited', async () => {getContentOverlap.mockResolvedValue({ totalPrompts: 2, pages: [] });await render('b2b', {kind: 'opportunity',@@ -323,8 +322,10 @@ describe('New content', () => {});await act(async () => {});expect(document.body.textContent).toContain('Optimize: Pricing');- // Nothing overlaps, and Start still shows the draft optimizes the plan's page.- expect(document.body.textContent).toContain('No existing page answers these prompts');+ // Nothing else cited, and Start still shows the draft optimizes the plan's page.+ expect(document.body.textContent).toContain(+ 'None of your pages is cited for these prompts yet',+ );expect(radio('Optimize /pricing').getAttribute('aria-checked')).toBe('true');await click(button('Open editor'));expect(createContentDraft.mock.calls[0][1]).toMatchObject({@@ -344,7 +345,7 @@ describe('New content', () => {});await act(async () => {});- await click(radio('Create a new page instead'));+ await click(radio('Create a new page'));expect(document.body.textContent).toContain('Create: CRM for real estate teams');expect(radio('Optimize /pricing').getAttribute('aria-checked')).toBe('false');await click(button('Open editor'));@@ -354,7 +355,7 @@ describe('New content', () => {});});- it('offers the plan’s page beside the check’s options, to come back to', async () => {+ it('offers the plan’s page beside a new page and the page cited most, to come back to', async () => {getContentOverlap.mockResolvedValue({totalPrompts: 4,pages: [@@ -377,9 +378,9 @@ describe('New content', () => {const given = radio('Optimize /pricing');expect(given.textContent).toContain('The page your Content plan picked');expect(given.getAttribute('aria-checked')).toBe('true');- expect(radio('Create a new page, link /blog/crm-guide to it')).toBeDefined();+ expect(radio('Create a new page').getAttribute('aria-checked')).toBe('false');- await click(radio('Add a section to /blog/crm-guide'));+ await click(radio('Optimize /blog/crm-guide instead'));expect(radio('Optimize /pricing').getAttribute('aria-checked')).toBe('false');await click(radio('Optimize /pricing'));expect(radio('Optimize /pricing').getAttribute('aria-checked')).toBe('true');@@ -390,7 +391,7 @@ describe('New content', () => {});});- it('offers no second option for the plan’s page when the check names it too', async () => {+ it('offers the plan’s page once when it is also the page cited most', async () => {getContentOverlap.mockResolvedValue({totalPrompts: 4,pages: [@@ -410,8 +411,10 @@ describe('New content', () => {});await act(async () => {});- expect(document.body.textContent).not.toContain('The page your Content plan picked');- expect(radio('Optimize /pricing instead').getAttribute('aria-checked')).toBe('true');+ // Offered once, as the plan's page.+ expect(radio('Optimize /pricing').textContent).toContain('The page your Content plan picked');+ expect(radio('Optimize /pricing').getAttribute('aria-checked')).toBe('true');+ expect(radio('Optimize /pricing instead')).toBeUndefined();});it('leaves an opportunity no longer open to pick', async () => {@@ -481,7 +484,7 @@ describe('New content', () => {});});- describe('the overlap check', () => {+ describe('the Overview', () => {const GUIDE = {url: 'https://acme.example/guides/espresso-machines-for-beginners/',title: 'Espresso machines for beginners',@@ -489,7 +492,7 @@ describe('New content', () => {citations: 4,gscPosition: 3.5,};- /** Starts a new page from the first opportunity and waits for the check. */+ /** Starts a new page from the first opportunity and waits for the Overview. */async function startFromOpportunity() {await render();await click(button('Pick a content opportunity'));@@ -505,27 +508,37 @@ describe('New content', () => {r.textContent?.startsWith(name),)!;- it('says a new page is safe when no page of the brand answers its prompts', async () => {+ it('says when none of the brand’s pages is cited for the prompts, with nothing to choose', async () => {await startFromOpportunity();expect(getContentOverlap).toHaveBeenCalledWith('b1', { kind: 'opportunity', id: 'o1' });- expect(document.body.textContent).toContain('No existing page answers these prompts');- expect(document.body.textContent).toContain('Safe to create');+ expect(document.body.textContent).toContain('Overview');+ expect(document.body.textContent).toContain(+ 'None of your pages is cited for these prompts yet',+ );+ expect(document.body.textContent).not.toContain('Safe to create');+ expect(overlapOption('Create a new page')).toBeUndefined();});- it('recommends optimizing a page that already answers most of the prompts', async () => {+ it('keeps Create chosen, and offers the page cited most without recommending it', async () => {getContentOverlap.mockResolvedValue({ totalPrompts: 4, pages: [GUIDE] });await startFromOpportunity();- expect(document.body.textContent).toContain('An existing page already answers these prompts');+ // Information, not a warning: no amber box, no recommendation.+ expect(document.body.textContent).toContain('1 of your pages is cited for these prompts');expect(document.body.textContent).toContain('3 of 4');expect(document.body.textContent).toContain('#4');+ expect(document.querySelector('[role="dialog"] .text-amber-700')).toBeNull();+ expect(document.body.textContent).not.toContain('Recommended');+ expect(overlapOption('Create a new page').getAttribute('aria-checked')).toBe('true');+ expect(document.body.textContent).toContain('Create: Northwind vs HubSpot');const optimize = overlapOption('Optimize /guides/espresso-machines-for-beginners instead');- expect(optimize.getAttribute('aria-checked')).toBe('true');- expect(optimize.textContent).toContain('Recommended');+ expect(optimize.getAttribute('aria-checked')).toBe('false');expect(optimize.textContent).toContain('It already answers 3 of 4 prompts, is cited 4× and ranks #4 on Google',);- // The draft becomes that page's: its title, and the type its address shows.++ // Picked, the draft becomes that page's: its title, and the type its address shows.+ await click(optimize);expect(document.body.textContent).toContain('Optimize: Espresso machines for beginners');expect(checkedType()).toBe('How-to guide');expect(document.body.textContent).toContain('Picked from the page.');@@ -555,6 +568,7 @@ describe('New content', () => {it('starts an existing page with its title when its live text can’t be read', async () => {getContentOverlap.mockResolvedValue({ totalPrompts: 4, pages: [GUIDE] });await startFromOpportunity();+ await click(overlapOption('Optimize /guides/espresso-machines-for-beginners instead'));await click(button('Open editor'));expect(toast.warning).toHaveBeenCalledWith("Couldn't read /guides/espresso-machines-for-beginners: the draft starts with its title.",@@ -566,10 +580,11 @@ describe('New content', () => {});});- it('goes back to the new page when creating one anyway', async () => {+ it('goes back to the new page after picking an existing one', async () => {getContentOverlap.mockResolvedValue({ totalPrompts: 4, pages: [GUIDE] });await startFromOpportunity();- await click(overlapOption('Create a new page anyway'));+ await click(overlapOption('Optimize /guides/espresso-machines-for-beginners instead'));+ await click(overlapOption('Create a new page'));expect(document.body.textContent).toContain('Create: Northwind vs HubSpot');expect(checkedType()).toBe('Comparison');await click(button('Open editor'));@@ -581,38 +596,20 @@ describe('New content', () => {});});- it('recommends a new page linked from pages that answer only some prompts', async () => {- getContentOverlap.mockResolvedValue({- totalPrompts: 4,- pages: [- {- ...GUIDE,- url: 'https://acme.example/blog/grinders',- promptsInCommon: 1,- gscPosition: null,- },- ],- });- await startFromOpportunity();- expect(document.body.textContent).toContain('1 existing page answers some of these prompts');- expect(document.body.textContent).toContain('—');- expect(- overlapOption('Create a new page, link /blog/grinders to it').getAttribute('aria-checked'),- ).toBe('true');- expect(overlapOption('Add a section to /blog/grinders')).toBeDefined();- expect(document.body.textContent).toContain('Create: Northwind vs HubSpot');- });-- it('lets the page start when the check fails, and tries again', async () => {+ it('lets the page start when the read fails, and tries again', async () => {vi.spyOn(console, 'error').mockImplementation(() => {});getContentOverlap.mockRejectedValueOnce(new Error('down'));await startFromOpportunity();- expect(document.body.textContent).toContain("Couldn't check for overlapping pages.");+ expect(document.body.textContent).toContain(+ "Couldn't read your pages cited for these prompts.",+ );expect(button('Open editor')!.disabled).toBe(false);await click(button('Try again'));await act(async () => {});expect(getContentOverlap).toHaveBeenCalledTimes(2);- expect(document.body.textContent).toContain('Safe to create');+ expect(document.body.textContent).toContain(+ 'None of your pages is cited for these prompts yet',+ );});});diff --git a/web/src/components/content/new-content-dialog.tsx b/web/src/components/content/new-content-dialog.tsxindex 0cf0110bc..58dbb1eee 100644--- a/web/src/components/content/new-content-dialog.tsx+++ b/web/src/components/content/new-content-dialog.tsx@@ -3,7 +3,7 @@import { useEffect, useRef, useState } from 'react';import { useTranslations } from 'next-intl';import { toast } from 'sonner';-import { AlertTriangle, ArrowLeft, Check, FileText, Loader2, X } from 'lucide-react';+import { ArrowLeft, FileText, Loader2, X } from 'lucide-react';import { useRouter } from '@/i18n/navigation';import { Button } from '@/components/ui/button';import {@@ -53,7 +53,6 @@ import {} from '@/lib/content/drafts';import { DOCUMENT_ACCEPT, readDocumentFile } from '@/lib/content/import-document';import {- adviseOverlap,overlapOptions,pagePath,samePage,@@ -112,7 +111,7 @@ interface StartChoice {picked: boolean;/** The page type for a new page, to go back to from optimizing an existing one. */newPageType: { pageType: PageType; detectedFrom: DetectedFrom; picked: boolean };- /** The overlap check's pick: write the new page, or optimize an existing one. */+ /** The Overview's pick: write the new page, or optimize an existing one. */choice: OverlapChoice;/** The page the Content plan named for this opportunity, offered beside the check's options. */givenPage?: OverlapPage;@@ -130,7 +129,7 @@ export type DialogPreset =type Who = 'me' | 'agent' | 'team';const WHO: Who[] = ['me', 'agent', 'team'];-/** The overlap check for one source: null while it runs. */+/** The Overview's read for one source: null while it runs. */interface OverlapRead {key: string;overlap: ContentOverlap | null;@@ -212,8 +211,6 @@ export function NewContentDialog({// From the Content plan: Start for its opportunity once the options are in// (one no longer open is left to pick), or its page read to optimize.const presetApplied = useRef(false);- // The plan named the page to optimize: the overlap check doesn't replace it.- const choiceGiven = useRef(false);useEffect(() => {if (!open || !preset || presetApplied.current) return;if (preset.kind === 'page') {@@ -251,9 +248,10 @@ export function NewContentDialog({// eslint-disable-next-line react-hooks/exhaustive-deps -- once per opening}, [open, preset, options]);- // Start checks the pages that already answer a new page's prompts. Content- // brought to optimize has no prompts to check. A page type picked in Start- // keeps the same source, so the check runs once per source.+ // Start reads the brand's pages AI already cites for a new page's prompts+ // (the Overview). Content brought to optimize has no prompts to read for. A+ // page type picked in Start keeps the same source, so it reads once per+ // source.const startSource = start?.source;const overlapKey = startSource && startSource.kind !== 'content' ? sourceKey(startSource) : null;useEffect(() => {@@ -264,24 +262,18 @@ export function NewContentDialog({.then((overlap) => {if (cancelled) return;setOverlapRead({ key, overlap, failed: false });- // The recommended option is picked first, unless the plan named the page.- const recommended = adviseOverlap(overlap).options[0];- if (recommended && !choiceGiven.current) {- setStart((s) => (s ? withChoice(s, recommended.choice, siteType) : s));- }}).catch((err) => {- console.error('Failed to check for overlapping pages:', err);+ console.error('Failed to read the pages cited for these prompts:', err);if (!cancelled) setOverlapRead({ key, overlap: null, failed: true });});return () => {cancelled = true;};- }, [brandId, startSource, siteType, overlapAttempt]);+ }, [brandId, startSource, overlapAttempt]);const reset = () => {presetApplied.current = false;- choiceGiven.current = false;setMethod('create');setKind('opportunity');setPicked(null);@@ -387,7 +379,7 @@ export function NewContentDialog({/*** Start for a new page from what was picked: its title, and the page type* it reads as. With a page (an opportunity for an existing page, from the- * plan), Start optimizes that page, and the overlap check leaves it chosen.+ * plan), Start optimizes that page, and it stays chosen.*/const startFrom = (item: PickerItem, from: SourceKind, page?: OverlapPage) => {const title = item.pageTitle ?? item.label;@@ -406,7 +398,6 @@ export function NewContentDialog({choice: { kind: 'create' },givenPage: page,};- choiceGiven.current = !!page;setStart(page ? withChoice(next, { kind: 'optimize', page }, siteType) : next);};@@ -943,8 +934,9 @@ function withChoice(start: StartChoice, choice: OverlapChoice, siteType: SiteTyp}/**- * Start's overlap check (CE-015): the brand's pages AI already cites for these- * prompts, and what to do about them, the recommended option first.+ * Start's Overview (CE-015): the brand's pages AI already cites for these+ * prompts, as information, and the choice between a new page and one of+ * them. The action the person picked stays chosen.*/function OverlapCheck({read,@@ -961,10 +953,10 @@ function OverlapCheck({}) {const t = useTranslations('contentEditor.newContent.overlap');const overlap = read?.overlap ?? null;- const advice = overlap ? adviseOverlap(overlap) : null;const shown = overlap?.pages.slice(0, 3) ?? [];const top = overlap?.pages[0];- const options = advice ? overlapOptions(advice, given) : [];+ const options = overlap ? overlapOptions(overlap, given) : [];+ const nothingCited = !overlap || overlap.totalPrompts === 0 || overlap.pages.length === 0;const isChosen = (option: OverlapOption) =>option.choice.kind === choice.kind &&(option.choice.kind === 'create' ||@@ -998,24 +990,6 @@ function OverlapCheck({title: t('options.createNew.title'),reason: t('options.createNew.reason'),};- case 'createAnyway':- return {- title: t('options.createAnyway.title'),- reason: t('options.createAnyway.reason'),- };- case 'createLinked':- return {- title:- (overlap?.pages.length ?? 0) > 1- ? t('options.createLinked.titleMany')- : t('options.createLinked.title', { page }),- reason: t('options.createLinked.reason'),- };- case 'addSection':- return {- title: t('options.addSection.title', { page }),- reason: t('options.addSection.reason'),- };}};@@ -1045,11 +1019,6 @@ function OverlapCheck({<span className="min-w-0"><span className="flex flex-wrap items-center gap-1.5 text-sm font-medium">{text.title}- {option.recommended && (- <span className="rounded-md bg-muted px-1.5 text-[10.5px] font-medium text-muted-foreground">- {t('recommended')}- </span>- )}</span><span className="block text-xs text-muted-foreground">{text.reason}</span></span>@@ -1067,68 +1036,60 @@ function OverlapCheck({<Loader2 className="h-3.5 w-3.5 animate-spin" />{t('checking')}</p>- ) : read.failed || !advice || !overlap ? (+ ) : read.failed || !overlap ? (<p className="flex items-center gap-2 text-xs text-muted-foreground">{t('failed')}<button type="button" className="font-medium underline" onClick={onRetry}>{t('retry')}</button></p>- ) : advice.verdict === 'none' ? (- <>- <div className="flex items-center justify-between gap-3 rounded-lg border px-3 py-2.5 text-sm">- <span>{overlap.totalPrompts ? t('none') : t('noPrompts')}</span>- {overlap.totalPrompts > 0 && (- <span className="flex shrink-0 items-center gap-1 text-xs font-medium text-emerald-600 dark:text-emerald-400">- <Check className="h-3.5 w-3.5" />- {t('safe')}- </span>- )}- </div>- {optionGroup}- </>) : (<>- <div className="rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2.5 text-sm">- <p className="flex items-center gap-1.5 font-medium text-amber-700 dark:text-amber-400">- <AlertTriangle className="h-3.5 w-3.5 shrink-0" />- {advice.verdict === 'covered'- ? t('covered')- : t('partial', { count: overlap.pages.length })}- </p>- <table className="mt-2 w-full table-fixed text-xs">- <thead className="text-[11px] tracking-wide whitespace-nowrap text-muted-foreground uppercase">- <tr>- <th className="py-1 text-left font-medium">{t('columns.page')}</th>- <th className="w-28 py-1 pl-3 text-right font-medium">{t('columns.prompts')}</th>- <th className="w-28 py-1 pl-3 text-right font-medium">- {t('columns.citations')}- </th>- <th className="w-24 py-1 pl-3 text-right font-medium">{t('columns.google')}</th>- </tr>- </thead>- <tbody>- {shown.map((page) => (- <tr key={page.url} className="border-t border-amber-500/20">- <td className="truncate py-1.5 pr-2" title={page.url}>- {pagePath(page.url)}- </td>- <td className="py-1.5 pl-3 text-right tabular-nums">- {t('promptsValue', {- count: page.promptsInCommon,- total: overlap.totalPrompts,- })}- </td>- <td className="py-1.5 pl-3 text-right tabular-nums">- {formatNumber(page.citations)}- </td>- <td className="py-1.5 pl-3 text-right tabular-nums">- {page.gscPosition == null ? '—' : `#${Math.round(page.gscPosition)}`}- </td>- </tr>- ))}- </tbody>- </table>+ <div className="rounded-lg border px-3 py-2.5 text-sm">+ {nothingCited ? (+ <p>{overlap.totalPrompts ? t('none') : t('noPrompts')}</p>+ ) : (+ <>+ <p className="font-medium">{t('cited', { count: overlap.pages.length })}</p>+ <table className="mt-2 w-full table-fixed text-xs">+ <thead className="text-[11px] tracking-wide whitespace-nowrap text-muted-foreground uppercase">+ <tr>+ <th className="py-1 text-left font-medium">{t('columns.page')}</th>+ <th className="w-28 py-1 pl-3 text-right font-medium">+ {t('columns.prompts')}+ </th>+ <th className="w-28 py-1 pl-3 text-right font-medium">+ {t('columns.citations')}+ </th>+ <th className="w-24 py-1 pl-3 text-right font-medium">+ {t('columns.google')}+ </th>+ </tr>+ </thead>+ <tbody>+ {shown.map((page) => (+ <tr key={page.url} className="border-t">+ <td className="truncate py-1.5 pr-2" title={page.url}>+ {pagePath(page.url)}+ </td>+ <td className="py-1.5 pl-3 text-right tabular-nums">+ {t('promptsValue', {+ count: page.promptsInCommon,+ total: overlap.totalPrompts,+ })}+ </td>+ <td className="py-1.5 pl-3 text-right tabular-nums">+ {formatNumber(page.citations)}+ </td>+ <td className="py-1.5 pl-3 text-right tabular-nums">+ {page.gscPosition == null ? '—' : `#${Math.round(page.gscPosition)}`}+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </>+ )}</div>{optionGroup}</>diff --git a/web/src/lib/actions/content-plan.test.ts b/web/src/lib/actions/content-plan.test.tsindex 4ea3766ea..2ddebcad2 100644--- a/web/src/lib/actions/content-plan.test.ts+++ b/web/src/lib/actions/content-plan.test.ts@@ -61,6 +61,7 @@ describe('getContentPlan', () => {citations: { cur: 4, prev: 9 },platformsDown: ['chatgpt-web'],aiVisits: 12,+ // Still in the RPC (00220); the plan no longer reads it.overlaps: 1,},],@@ -102,7 +103,6 @@ describe('getContentPlan', () => {citations: { cur: 4, prev: 9 },platformsDown: ['chatgpt-web'],aiVisits: 12,- overlaps: 1,},],answers: { cur: 120, prev: 140 },diff --git a/web/src/lib/actions/content-plan.ts b/web/src/lib/actions/content-plan.tsindex 6f198f12c..8f56e43b7 100644--- a/web/src/lib/actions/content-plan.ts+++ b/web/src/lib/actions/content-plan.ts@@ -97,7 +97,6 @@ export async function getContentPlan(citations: { cur: Number(p.citations?.cur ?? 0), prev: Number(p.citations?.prev ?? 0) },platformsDown: Array.isArray(p.platformsDown) ? p.platformsDown : [],aiVisits: Number(p.aiVisits ?? 0),- overlaps: Number(p.overlaps ?? 0),}));const opportunities = (opportunitiesRes.data ?? []).map((o): PlanOpportunity => {diff --git a/web/src/lib/content/overlap.test.ts b/web/src/lib/content/overlap.test.tsindex 1ffab5dae..578d10728 100644--- a/web/src/lib/content/overlap.test.ts+++ b/web/src/lib/content/overlap.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';import type { OverlapPage } from './drafts';-import { adviseOverlap, overlapOptions, pagePath, samePage } from './overlap';+import { overlapOptions, pagePath, samePage } from './overlap';const page = (over: Partial<OverlapPage> = {}): OverlapPage => ({url: 'https://acme.example/guides/espresso',@@ -11,65 +11,45 @@ const page = (over: Partial<OverlapPage> = {}): OverlapPage => ({...over,});-describe('adviseOverlap', () => {- it('finds nothing to weigh with no page, or no prompts to check', () => {- expect(adviseOverlap({ totalPrompts: 4, pages: [] })).toEqual({ verdict: 'none', options: [] });- expect(adviseOverlap({ totalPrompts: 0, pages: [page()] }).verdict).toBe('none');- });-- it('recommends optimizing a page that already answers half the prompts or more', () => {- const top = page({ promptsInCommon: 2 });- expect(- adviseOverlap({ totalPrompts: 4, pages: [top, page({ url: 'https://acme.example/b' })] }),- ).toEqual({- verdict: 'covered',- options: [- { key: 'optimizeInstead', choice: { kind: 'optimize', page: top }, recommended: true },- { key: 'createAnyway', choice: { kind: 'create' }, recommended: false },- ],- });- });-- it('recommends a new page when the pages answer fewer, with a section as the smaller change', () => {- const top = page({ promptsInCommon: 1 });- expect(adviseOverlap({ totalPrompts: 3, pages: [top] })).toEqual({- verdict: 'partial',- options: [- { key: 'createLinked', choice: { kind: 'create' }, recommended: true },- { key: 'addSection', choice: { kind: 'optimize', page: top }, recommended: false },- ],- });- });-});-describe('overlapOptions', () => {const top = page({ promptsInCommon: 1 });- const advice = adviseOverlap({ totalPrompts: 3, pages: [top] });+ const given = page({ url: 'https://acme.example/pricing', promptsInCommon: 0 });- it('offers the advice alone without a page from the plan, or when it offers that page', () => {- expect(overlapOptions(advice, null)).toBe(advice.options);- expect(overlapOptions(advice, page({ url: 'https://www.acme.example/Guides/espresso/' }))).toBe(- advice.options,- );+ it('offers no choice when a new page is the only one', () => {+ expect(overlapOptions({ totalPrompts: 4, pages: [] }, null)).toEqual([]);+ // Pages, but no prompts to read them against.+ expect(overlapOptions({ totalPrompts: 0, pages: [top] }, null)).toEqual([]);});- it('offers the plan’s page and a new page when nothing overlaps', () => {- const given = page({ url: 'https://acme.example/pricing', promptsInCommon: 0 });- const none = adviseOverlap({ totalPrompts: 2, pages: [] });- expect(overlapOptions(none, given)).toEqual([- { key: 'optimizeGiven', choice: { kind: 'optimize', page: given }, recommended: false },- { key: 'createNew', choice: { kind: 'create' }, recommended: false },- ]);- // With no page from the plan, nothing to choose.- expect(overlapOptions(none, null)).toEqual([]);+ it('offers a new page and the page cited for most of the prompts, recommending neither', () => {+ // However many of the prompts the page answers: more pages cited is no loss.+ for (const promptsInCommon of [1, 3]) {+ const cited = page({ promptsInCommon });+ expect(overlapOptions({ totalPrompts: 3, pages: [cited] }, null)).toEqual([+ { key: 'createNew', choice: { kind: 'create' } },+ { key: 'optimizeInstead', choice: { kind: 'optimize', page: cited } },+ ]);+ }});- it('offers the page the plan named first when the advice offers another', () => {- const given = page({ url: 'https://acme.example/pricing', promptsInCommon: 0 });- expect(overlapOptions(advice, given)).toEqual([- { key: 'optimizeGiven', choice: { kind: 'optimize', page: given }, recommended: false },- ...advice.options,+ it('offers the plan’s page first, then a new page, then the page cited most when it is another', () => {+ expect(overlapOptions({ totalPrompts: 3, pages: [top] }, given)).toEqual([+ { key: 'optimizeGiven', choice: { kind: 'optimize', page: given } },+ { key: 'createNew', choice: { kind: 'create' } },+ { key: 'optimizeInstead', choice: { kind: 'optimize', page: top } },]);+ // Nothing cited: the plan's page and a new page.+ expect(overlapOptions({ totalPrompts: 2, pages: [] }, given)).toEqual([+ { key: 'optimizeGiven', choice: { kind: 'optimize', page: given } },+ { key: 'createNew', choice: { kind: 'create' } },+ ]);+ // The plan's page is the one cited most (by address): offered once.+ expect(+ overlapOptions(+ { totalPrompts: 3, pages: [top] },+ page({ url: 'https://www.acme.example/Guides/espresso/' }),+ ).map((o) => o.key),+ ).toEqual(['optimizeGiven', 'createNew']);});});diff --git a/web/src/lib/content/overlap.ts b/web/src/lib/content/overlap.tsindex ea0a822b8..60d9b9152 100644--- a/web/src/lib/content/overlap.ts+++ b/web/src/lib/content/overlap.ts@@ -2,87 +2,40 @@ import type { ContentOverlap, OverlapPage } from './drafts';import { pageKey } from './sources';/**- * Start's overlap check (Content Editor CE-015, spec §5): what to recommend- * when the brand's own pages already answer a new page's prompts.- *- * * none: safe to create.- * * covered: the top page answers at least half the prompts. Optimize it- * instead; a new page would compete with it for the same prompts.- * * partial: the pages answer fewer. Create the page and link them to it,- * so the prompts get one clear page, or add a section to the top one.+ * Start's Overview (Content Editor CE-015, spec §5): the brand's own pages AI+ * already cites for a new page's prompts, shown as information. More of the+ * brand's pages cited for the same prompts is no loss (AI answers aren't a+ * ranking), so Start recommends nothing: it keeps the action the person+ * picked and offers the other one.*/-/** The share of the prompts a page answers for Start to recommend optimizing it. */-export const COVERS_SHARE = 0.5;-/** What Open editor does: write a new page, or optimize an existing one. */export type OverlapChoice = { kind: 'create' } | { kind: 'optimize'; page: OverlapPage };-export type OverlapOptionKey =- | 'optimizeGiven'- | 'createNew'- | 'optimizeInstead'- | 'createAnyway'- | 'createLinked'- | 'addSection';+export type OverlapOptionKey = 'optimizeGiven' | 'createNew' | 'optimizeInstead';export interface OverlapOption {key: OverlapOptionKey;choice: OverlapChoice;- recommended: boolean;-}--export interface OverlapAdvice {- verdict: 'none' | 'covered' | 'partial';- /** The recommended option first; empty when nothing overlaps. */- options: OverlapOption[];-}--export function adviseOverlap(overlap: ContentOverlap): OverlapAdvice {- const top = overlap.pages[0];- if (!top || overlap.totalPrompts === 0) return { verdict: 'none', options: [] };- const optimizeTop: OverlapChoice = { kind: 'optimize', page: top };- if (top.promptsInCommon / overlap.totalPrompts >= COVERS_SHARE) {- return {- verdict: 'covered',- options: [- { key: 'optimizeInstead', choice: optimizeTop, recommended: true },- { key: 'createAnyway', choice: { kind: 'create' }, recommended: false },- ],- };- }- return {- verdict: 'partial',- options: [- { key: 'createLinked', choice: { kind: 'create' }, recommended: true },- { key: 'addSection', choice: optimizeTop, recommended: false },- ],- };}/**- * The options Start offers: the advice's, after the page the Content plan- * named when the advice doesn't offer that page, so a person who picks- * another option can come back to it. With nothing overlapping, the plan's- * page and a new page: Start shows which one the draft will be, and lets- * the person switch.+ * The choices Start offers: the page the Content plan named, when there is+ * one; a new page; and the page cited for most of these prompts, when it is+ * another. None when a new page is the only one.*/-export function overlapOptions(advice: OverlapAdvice, given: OverlapPage | null): OverlapOption[] {- if (!given) return advice.options;- if (advice.options.length === 0) {- return [- { key: 'optimizeGiven', choice: { kind: 'optimize', page: given }, recommended: false },- { key: 'createNew', choice: { kind: 'create' }, recommended: false },- ];+export function overlapOptions(+ overlap: ContentOverlap,+ given: OverlapPage | null,+): OverlapOption[] {+ const top = overlap.totalPrompts > 0 ? overlap.pages[0] : undefined;+ const options: OverlapOption[] = [];+ if (given) options.push({ key: 'optimizeGiven', choice: { kind: 'optimize', page: given } });+ options.push({ key: 'createNew', choice: { kind: 'create' } });+ if (top && !(given && samePage(top.url, given.url))) {+ options.push({ key: 'optimizeInstead', choice: { kind: 'optimize', page: top } });}- const offered = advice.options.some(- (o) => o.choice.kind === 'optimize' && samePage(o.choice.page.url, given.url),- );- if (offered) return advice.options;- return [- { key: 'optimizeGiven', choice: { kind: 'optimize', page: given }, recommended: false },- ...advice.options,- ];+ return options.length > 1 ? options : [];}/** Two addresses of one page (pageKey), or the same text when either isn't an address. */diff --git a/web/src/lib/content/plan.test.ts b/web/src/lib/content/plan.test.tsindex de259847a..875885925 100644--- a/web/src/lib/content/plan.test.ts+++ b/web/src/lib/content/plan.test.ts@@ -1,7 +1,6 @@import { describe, expect, it } from 'vitest';import {MAX_ROWS,- OVERLAP_SCORE,buildPlan,citationsDownScore,protectScore,@@ -24,7 +23,6 @@ const page = (path: string, over: Partial<PlanPage> = {}): PlanPage => ({citations: { cur: 2, prev: 2 },platformsDown: [],aiVisits: 0,- overlaps: 0,...over,});const opportunity = (id: string, over: Partial<PlanOpportunity> = {}): PlanOpportunity => ({@@ -74,7 +72,7 @@ describe('buildPlan', () => {draft: null,}),]);- expect(counts).toEqual({ create: 1, optimize: 0, protect: 0, overlaps: 0 });+ expect(counts).toEqual({ create: 1, optimize: 0, protect: 0 });});it('optimizes a page losing citations, by how much it lost, with the platforms citing it less', () => {@@ -127,7 +125,7 @@ describe('buildPlan', () => {it('keeps one row for a page an opportunity targets, with the period’s signal when it is losing', () => {const { rows } = plan(- [page('/guides/espresso/', { citations: { cur: 2, prev: 8 }, overlaps: 2 })],+ [page('/guides/espresso/', { citations: { cur: 2, prev: 8 } })],[opportunity('o1', {title: 'Expand the espresso guide',@@ -145,7 +143,6 @@ describe('buildPlan', () => {opportunityId: 'o1',source: 'citations',why: { kind: 'citationsDown', pct: 75 },- overlaps: 2,score: citationsDownScore(75, 6),});});@@ -177,17 +174,13 @@ describe('buildPlan', () => {expect(rows[0]).toMatchObject({ action: 'protect', page: 'https://acme.example/pricing' });});- it('lists a top page past the five protected when it competes with another', () => {+ it('leaves a top page past the five protected off the list', () => {const pages = [5, 6, 7, 8, 9, 30].map((cur, i) =>- page(`/p${i}`, { citations: { cur, prev: cur }, overlaps: i === 0 ? 2 : 0 }),+ page(`/p${i}`, { citations: { cur, prev: cur } }),);const { rows, counts } = plan(pages);expect(counts.protect).toBe(5);- expect(rows.find((r) => r.title === 'p0')).toMatchObject({- action: 'optimize',- why: { kind: 'overlap', pages: 2 },- score: OVERLAP_SCORE,- });+ expect(rows.find((r) => r.title === 'p0')).toBeUndefined();});it('counts every row, and each card lists its own first rows', () => {@@ -196,30 +189,24 @@ describe('buildPlan', () => {);const pages = [page('/top', { citations: { cur: 30, prev: 30 } }),- page('/blog/a', { overlaps: 1 }),+ page('/guides/losing', { citations: { cur: 2, prev: 8 } }),];const { rows, counts } = plan(pages, opportunities);- expect(counts).toEqual({ create: 60, optimize: 1, protect: 1, overlaps: 1 });+ expect(counts).toEqual({ create: 60, optimize: 1, protect: 1 });expect(rowsFor(rows, null)).toHaveLength(MAX_ROWS);// Below the 50 opportunities on score, and still shown on their cards.expect(rowsFor(rows, 'protect').map((r) => r.title)).toEqual(['top']);- expect(rowsFor(rows, 'overlaps').map((r) => r.title)).toEqual(['blog/a']);+ expect(rowsFor(rows, 'optimize').map((r) => r.title)).toEqual(['guides/losing']);});- it('lists a page that only competes with others, and counts every page competing', () => {+ it('lists no page only because other pages of the brand are cited for its prompts', () => {+ // A steady page under the top-page bar: nothing to do, whatever else is cited.const { rows, counts } = plan([- page('/blog/espresso-basics', { overlaps: 1 }),- page('/guides/espresso', { citations: { cur: 12, prev: 10 }, overlaps: 1 }),- ]);- // The work comes before protecting.- expect(rows.map((r) => [r.action, r.why.kind])).toEqual([- ['optimize', 'overlap'],- ['protect', 'top'],+ page('/blog/espresso-basics'),+ page('/guides/espresso', { citations: { cur: 12, prev: 10 } }),]);- expect(counts.overlaps).toBe(2);- expect(rowsFor(rows, 'overlaps')).toHaveLength(2);- expect(rowsFor(rows, 'protect')).toHaveLength(1);- expect(rowsFor(rows, null)).toHaveLength(2);+ expect(rows.map((r) => [r.action, r.why.kind])).toEqual([['protect', 'top']]);+ expect(counts).toEqual({ create: 0, optimize: 0, protect: 1 });});it('finds the draft being written for an opportunity or a page', () => {diff --git a/web/src/lib/content/plan.ts b/web/src/lib/content/plan.tsindex 65febba6c..b4f9749a6 100644--- a/web/src/lib/content/plan.ts+++ b/web/src/lib/content/plan.ts@@ -3,8 +3,10 @@* what to create, optimize or protect next, built from the brand's open* Content Opportunities (new pages AI needs, pages to improve; tasks sent* from the Action Center become opportunities too) and its own pages as AI- * cites them (content_plan_pages, 00220): pages losing citations, the top- * pages, and pages competing for the same prompts. A page loses ground when+ * cites them (content_plan_pages, 00220): pages losing citations and the+ * top pages. More of the brand's pages cited for the same prompts is no+ * loss (AI answers aren't a ranking), so that is not a reason to list a+ * page. A page loses ground when* it is cited less per tracked answer than in the period before, so a week* with fewer runs, or prompts added or removed, moves no page.*/@@ -18,8 +20,8 @@ export const PLAN_PERIODS = [7, 30, 90] as const;export type PlanPeriod = (typeof PLAN_PERIODS)[number];export type PlanAction = 'create' | 'optimize' | 'protect';-/** The cards over the list, each a filter: the actions, and the pages competing. */-export const PLAN_CARDS = ['create', 'optimize', 'protect', 'overlaps'] as const;+/** The cards over the list, each a filter by its action. */+export const PLAN_CARDS = ['create', 'optimize', 'protect'] as const;export type PlanCard = (typeof PLAN_CARDS)[number];/** The brand's tracked answers in each period: what makes their citations comparable. */@@ -46,8 +48,6 @@ export interface PlanPage {/** Platform keys citing it at a lower rate than before, the biggest drop first. */platformsDown: string[];aiVisits: number;- /** The brand's other pages cited for two or more of the same prompts. */- overlaps: number;}/** An open opportunity for one of the brand's own pages. */@@ -81,8 +81,7 @@ export type PlanWhy =| { kind: 'competitors'; names: string[]; visibility: number | null }| { kind: 'opportunity'; prompts: number }| { kind: 'citationsDown'; pct: number; platforms: string[] }- | { kind: 'top'; citations: number; aiVisits: number }- | { kind: 'overlap'; pages: number };+ | { kind: 'top'; citations: number; aiVisits: number };export interface PlanRow {key: string;@@ -92,9 +91,7 @@ export interface PlanRow {page: string | null;pageType: PageType | null;why: PlanWhy;- source: 'opportunity' | 'citations' | 'protect' | 'overlap';- /** The brand's other pages competing with this one. */- overlaps: number;+ source: 'opportunity' | 'citations' | 'protect';score: number;opportunityId: string | null;draft: PlanDraft | null;@@ -116,13 +113,12 @@ export const MAX_ROWS = 50;* opportunity keeps its own score; a page losing citations ranks by how much* it lost, the citations more than the share (40 + a fifth of the drop in* percent + up to 40 for the citations lost), so 200 → 118 outranks 3 → 0;- * a page only competing with others, 45; a top page by how much it is cited- * (20 + citations, at most 60), so protecting comes after the work to do.+ * a top page by how much it is cited (20 + citations, at most 60), so+ * protecting comes after the work to do.*/export function citationsDownScore(pct: number, lost: number): number {return Math.min(100, 40 + Math.round(pct / 5) + Math.min(40, lost));}-export const OVERLAP_SCORE = 45;export function protectScore(citations: number): number {return Math.min(60, 20 + citations);}@@ -191,7 +187,6 @@ export function buildPlan({? { kind: 'competitors', names: o.competitorsCited, visibility: o.visibility }: { kind: 'opportunity', prompts: o.prompts },source: drop ? 'citations' : 'opportunity',- overlaps: page?.overlaps ?? 0,score: drop? Math.max(o.score, citationsDownScore(drop.pct, drop.lost)): Math.round(o.score),@@ -209,7 +204,6 @@ export function buildPlan({title,page: page.page,pageType: typeOf(title, page.page),- overlaps: page.overlaps,opportunityId: null,draft: draftFor(null, page.page),};@@ -232,31 +226,10 @@ export function buildPlan({source: 'protect',score: protectScore(page.citations.cur),});- } else if (page.overlaps > 0) {- rows.push({- ...base,- key: `page:${key}`,- action: 'optimize',- why: { kind: 'overlap', pages: page.overlaps },- source: 'overlap',- score: OVERLAP_SCORE,- });}}protect.sort((a, b) => b.score - a.score || a.title.localeCompare(b.title));rows.push(...protect.slice(0, MAX_PROTECT));- // A top page past the five protected still gets its row when it competes.- for (const row of protect.slice(MAX_PROTECT)) {- if (row.overlaps > 0) {- rows.push({- ...row,- action: 'optimize',- why: { kind: 'overlap', pages: row.overlaps },- source: 'overlap',- score: OVERLAP_SCORE,- });- }- }rows.sort((a, b) => b.score - a.score || a.title.localeCompare(b.title));return {@@ -265,15 +238,14 @@ export function buildPlan({create: rows.filter((r) => r.action === 'create').length,optimize: rows.filter((r) => r.action === 'optimize').length,protect: rows.filter((r) => r.action === 'protect').length,- overlaps: rows.filter((r) => r.overlaps > 0).length,},};}/**- * The rows a card shows, the first MAX_ROWS: its action's, or the pages- * competing; all without a card. A page type (the mix's filter) narrows them- * before the cut, so its rows are never cut off by others.+ * The rows a card shows, the first MAX_ROWS: its action's; all without a+ * card. A page type (the mix's filter) narrows them before the cut, so its+ * rows are never cut off by others.*/export function rowsFor(rows: PlanRow[],@@ -281,11 +253,7 @@ export function rowsFor(pageType: PageType | null = null,): PlanRow[] {return rows- .filter(- (r) =>- (!card || (card === 'overlaps' ? r.overlaps > 0 : r.action === card)) &&- (!pageType || r.pageType === pageType),- )+ .filter((r) => (!card || r.action === card) && (!pageType || r.pageType === pageType)).slice(0, MAX_ROWS);}