Skip to content

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

feat(action-center): detect platform and citation gaps (#826)

Gökhan Geyik24baee60dea3
diff --git a/server/src/config/action-engine.js b/server/src/config/action-engine.js
index 25f58d084..58e9a4d47 100644
--- a/server/src/config/action-engine.js
+++ b/server/src/config/action-engine.js
@@ -84,6 +84,35 @@ export const ENGINE_THRESHOLDS = Object.freeze({
* signal is worth an action: one prompt is an anecdote. */
uncitedMinPrompts: 3,
+ /**
+ * A platform gap worth naming.
+ *
+ * Platforms differ for everyone: the spread between a brand's best and
+ * worst averages 12 points across live brands, so a gap alone is the
+ * normal state. Twenty is comfortably above that average, and the floor
+ * on the best platform is what makes the gap mean "achievable here,
+ * absent there" rather than "weak everywhere". Together they report
+ * about one brand in five.
+ */
+ platformGapPoints: 20,
+ platformBestFloor: 25,
+ /** A platform needs this many tracked prompts before its rate is a rate,
+ * and this many platforms must qualify before a comparison is one. */
+ platformMinPrompts: 10,
+ platformMinCompared: 3,
+
+ /**
+ * A citation gap worth naming.
+ *
+ * A competitor leads two thirds of brands on citations in any given week,
+ * so being behind is not the signal — being behind by a multiple is. The
+ * absolute floor keeps the multiple off small numbers, where twice as
+ * many citations can mean four against two. Reports about one brand in
+ * four.
+ */
+ citationGapMultiple: 2,
+ citationGapMinAbsolute: 20,
+
/** Site Audit score below this is a problem; an audit older than this is
* not evidence about the page as it stands today. */
auditLowScore: 50,
diff --git a/server/src/lib/action-center/generate.js b/server/src/lib/action-center/generate.js
index 2eff0db02..e028911f9 100644
--- a/server/src/lib/action-center/generate.js
+++ b/server/src/lib/action-center/generate.js
@@ -65,6 +65,14 @@ const ACTION_RULES = [
signalKinds: ['page_opportunity'],
taskKeys: ['review_pages', 'coverage_gaps', 'optimize_content', 'validate'],
},
+ // Growth's second definition: the brand ranks somewhere, so the content can
+ // rank — it is the engine, not the material, that differs.
+ {
+ kind: 'expand_platform_visibility',
+ category: 'growth',
+ signalKinds: ['platform_gap'],
+ taskKeys: ['compare_platforms', 'coverage_gaps', 'optimize_content', 'validate'],
+ },
{
kind: 'convert_mentions',
category: 'growth',
@@ -77,6 +85,15 @@ const ACTION_RULES = [
signalKinds: ['audit_low_score'],
taskKeys: ['review_audits', 'fix_issues', 'revalidate'],
},
+ // Compete's second definition. Distinct from close_competitor_gap, which is
+ // about visibility: this one is about who gets cited, and the work is
+ // earning references rather than ranking answers.
+ {
+ kind: 'close_citation_gap',
+ category: 'compete',
+ signalKinds: ['competitor_citation_gap'],
+ taskKeys: ['compare_citations', 'identify_sources', 'strengthen_sources', 'validate'],
+ },
{
kind: 'close_competitor_gap',
category: 'compete',
@@ -102,6 +119,25 @@ function buildPayload(rule, signals) {
}
break;
}
+ case 'expand_platform_visibility': {
+ const gap = (byKind.get('platform_gap') ?? [])[0];
+ if (gap) {
+ payload.platform = gap.payload?.platform;
+ payload.bestPlatform = gap.payload?.bestPlatform;
+ payload.dropFrom = gap.previous_value;
+ payload.dropTo = gap.current_value;
+ }
+ break;
+ }
+ case 'close_citation_gap': {
+ const gap = (byKind.get('competitor_citation_gap') ?? [])[0];
+ if (gap) {
+ payload.competitorNames = gap.payload?.competitorName ? [gap.payload.competitorName] : [];
+ payload.citationCount = gap.current_value;
+ payload.competitorCitations = gap.payload?.competitorCitations;
+ }
+ break;
+ }
case 'protect_visibility': {
const slip = (byKind.get('visibility_slipping') ?? [])[0];
if (slip) {
diff --git a/server/src/lib/signals/gap-detectors.test.js b/server/src/lib/signals/gap-detectors.test.js
new file mode 100644
index 000000000..e4b78b5ed
--- /dev/null
+++ b/server/src/lib/signals/gap-detectors.test.js
@@ -0,0 +1,103 @@
+import { describe, expect, it, vi } from 'vitest';
+
+// record.js reaches the admin client at import time, whose config hard-exits
+// without SUPABASE_* env (as in CI). The classifiers under test touch none of
+// it — they are arithmetic over numbers the caller already fetched.
+vi.mock('../../config/supabase.js', () => ({ default: { rpc: vi.fn(), from: vi.fn() } }));
+vi.mock('../logger.js', () => ({
+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
+}));
+vi.mock('../pulse/metrics.js', () => ({ computePulseMetrics: vi.fn() }));
+
+import { classifyCitationGap, classifyPlatformGap } from './record.js';
+import { ENGINE_THRESHOLDS } from '../../config/action-engine.js';
+
+const { detection } = ENGINE_THRESHOLDS;
+
+const rate = (platform, value) => ({ platform, rate: value });
+
+describe('classifyPlatformGap', () => {
+ /**
+ * The pair that makes a gap mean something: proven somewhere, absent
+ * elsewhere. Either half alone is not a finding.
+ */
+ it('reports a gap when the brand ranks well on one engine and poorly on another', () => {
+ const gap = classifyPlatformGap([
+ rate('a', detection.platformBestFloor + 20),
+ rate('b', detection.platformBestFloor + 10),
+ rate('c', detection.platformBestFloor - 10),
+ ]);
+
+ expect(gap).toMatchObject({ points: 30 });
+ expect(gap.best.platform).toBe('a');
+ expect(gap.worst.platform).toBe('c');
+ });
+
+ /**
+ * Platforms differ for everyone — the average spread is 12 points — so a
+ * gap under the threshold is the normal state rather than news.
+ */
+ it('says nothing about a spread narrower than platforms normally differ', () => {
+ const narrow = detection.platformGapPoints - 1;
+ expect(
+ classifyPlatformGap([rate('a', 50), rate('b', 50 - narrow / 2), rate('c', 50 - narrow)]),
+ ).toBeNull();
+ });
+
+ /**
+ * Without the floor, a brand weak on every engine would be told it has a
+ * platform opportunity. It has a visibility problem, which is a different
+ * signal and a different action.
+ */
+ it('does not call it an opportunity when the brand ranks nowhere', () => {
+ const below = detection.platformBestFloor - 1;
+ expect(classifyPlatformGap([rate('a', below), rate('b', below / 2), rate('c', 0)])).toBeNull();
+ });
+
+ it('needs enough platforms to be comparing at all', () => {
+ const rates = Array.from({ length: detection.platformMinCompared - 1 }, (_, i) =>
+ rate(`p${i}`, i === 0 ? 60 : 0),
+ );
+ expect(classifyPlatformGap(rates)).toBeNull();
+ });
+
+ it('finds the extremes whatever order they arrive in', () => {
+ const gap = classifyPlatformGap([rate('low', 5), rate('high', 60), rate('mid', 30)]);
+ expect(gap.best.platform).toBe('high');
+ expect(gap.worst.platform).toBe('low');
+ });
+});
+
+describe('classifyCitationGap', () => {
+ it('reports a competitor cited by a multiple, with a real body of citations', () => {
+ expect(classifyCitationGap({ brandCitations: 40, leaderCitations: 120 })).toEqual({
+ absoluteGap: 80,
+ });
+ });
+
+ /**
+ * A competitor leads two thirds of brands in any given week. Being behind
+ * is the ordinary state; being behind by a multiple is the finding.
+ */
+ it('says nothing when the competitor is merely ahead', () => {
+ expect(classifyCitationGap({ brandCitations: 100, leaderCitations: 140 })).toBeNull();
+ });
+
+ /**
+ * Without the absolute floor, "twice as many" can mean four against two —
+ * arithmetic on numbers too small to act on.
+ */
+ it('ignores a large multiple over small numbers', () => {
+ expect(classifyCitationGap({ brandCitations: 2, leaderCitations: 8 })).toBeNull();
+ });
+
+ it('reports a brand cited nowhere when a competitor is cited widely', () => {
+ expect(classifyCitationGap({ brandCitations: 0, leaderCitations: 60 })).toEqual({
+ absoluteGap: 60,
+ });
+ });
+
+ it('says nothing when the brand is ahead', () => {
+ expect(classifyCitationGap({ brandCitations: 200, leaderCitations: 50 })).toBeNull();
+ });
+});
diff --git a/server/src/lib/signals/record.js b/server/src/lib/signals/record.js
index 58b6b6519..00f03431f 100644
--- a/server/src/lib/signals/record.js
+++ b/server/src/lib/signals/record.js
@@ -60,6 +60,18 @@ const KIND_META = {
kpiKeys: ['ai_visibility'],
persistent: true,
},
+ platform_gap: {
+ category: 'visibility',
+ impact: 'medium',
+ kpiKeys: ['ai_visibility'],
+ persistent: true,
+ },
+ competitor_citation_gap: {
+ category: 'competitor',
+ impact: 'medium',
+ kpiKeys: ['citations', 'share_of_voice'],
+ persistent: true,
+ },
prompt_gain: {
category: 'visibility',
impact: 'medium',
@@ -293,6 +305,147 @@ async function pageOpportunityCandidates(brandId) {
* Detect and record signals for one brand. Best-effort by contract: callers
* fire-and-forget, and a failure here must never affect the tracking run.
*/
+/**
+ * Whether a set of per-platform visibility rates describes a gap worth acting on.
+ *
+ * Platforms differ for everyone — the spread between a brand's best and worst
+ * averages 12 points across live brands — so a gap alone is the normal state,
+ * not news. Two conditions make it actionable together: the brand already
+ * ranks well somewhere, which proves the content can rank, and it is
+ * materially absent somewhere else. Without the first half a brand that is
+ * weak everywhere would be told it has a platform opportunity, which is not
+ * what the number means.
+ *
+ * Returns null when there is nothing to report.
+ */
+export function classifyPlatformGap(rates) {
+ if (rates.length < detection.platformMinCompared) return null;
+
+ const sorted = [...rates].sort((a, b) => b.rate - a.rate);
+ const best = sorted[0];
+ const worst = sorted[sorted.length - 1];
+ const points = Math.round((best.rate - worst.rate) * 10) / 10;
+
+ if (best.rate < detection.platformBestFloor) return null;
+ if (points < detection.platformGapPoints) return null;
+ return { best, worst, points };
+}
+
+/**
+ * Whether a competitor's citation lead is structural rather than a week's
+ * variance.
+ *
+ * A competitor leads two thirds of brands on citations in any given week, so
+ * "behind" is not the signal. Behind by a multiple is: it says the gap will
+ * not close on its own, and that there is a body of citations to go after.
+ * The absolute floor keeps the multiple honest — twice as many can mean four
+ * against two, which is not a finding.
+ */
+export function classifyCitationGap({ brandCitations, leaderCitations }) {
+ const absoluteGap = leaderCitations - brandCitations;
+ if (absoluteGap < detection.citationGapMinAbsolute) return null;
+ if (leaderCitations < brandCitations * detection.citationGapMultiple) return null;
+ return { absoluteGap };
+}
+
+/**
+ * A platform the brand ranks poorly on, when it ranks well on another.
+ *
+ * Platforms differ for everyone — the average spread between a brand's best
+ * and worst platform is 12 points across live brands — so a gap on its own is
+ * the normal state, not news. What makes it actionable is the pair: visibility
+ * already proven achievable somewhere, and materially absent somewhere else.
+ * Without the "proven" half a brand that is weak everywhere would be told it
+ * has a platform opportunity, which is not what the number means.
+ *
+ * One signal per brand, naming the weakest platform. A brand behind on three
+ * engines has one condition to work on, not three rows.
+ */
+async function platformGapCandidates(brandId) {
+ const { data, error } = await supabaseAdmin
+ .from('insights_prompt_daily')
+ .select('model_used, prompt_id, has_mention, has_citation')
+ .eq('brand_id', brandId)
+ .gte('day', new Date(Date.now() - detection.windowDays * DAY_MS).toISOString().slice(0, 10))
+ .limit(20000);
+ if (error) throw new Error(error.message);
+
+ const byPlatform = new Map();
+ for (const row of data ?? []) {
+ const entry = byPlatform.get(row.model_used) ?? { tracked: new Set(), visible: new Set() };
+ entry.tracked.add(row.prompt_id);
+ if (row.has_mention || row.has_citation) entry.visible.add(row.prompt_id);
+ byPlatform.set(row.model_used, entry);
+ }
+
+ const rates = [...byPlatform.entries()]
+ .filter(([, e]) => e.tracked.size >= detection.platformMinPrompts)
+ .map(([platform, e]) => ({
+ platform,
+ rate: Math.round((e.visible.size / e.tracked.size) * 1000) / 10,
+ }));
+ if (rates.length < detection.platformMinCompared) return [];
+
+ const gap = classifyPlatformGap(rates);
+ if (!gap) return [];
+ const { best, worst } = gap;
+
+ return [
+ {
+ kind: 'platform_gap',
+ dedupKey: `platform_gap:${worst.platform}`,
+ source: ['ai_results'],
+ payload: { platform: worst.platform, bestPlatform: best.platform, bestRate: best.rate },
+ previousValue: best.rate,
+ currentValue: worst.rate,
+ changeValue: -gap.points,
+ },
+ ];
+}
+
+/**
+ * A competitor cited far more often than the brand.
+ *
+ * Being behind on citations is ordinary — a competitor leads two thirds of
+ * brands in any given week — so "behind" is not the signal. Being behind by a
+ * multiple is: it says the gap is structural rather than a week's variance,
+ * and that there is a body of citations to go after rather than a handful.
+ * The absolute floor keeps it off brands where the multiple is arithmetic on
+ * tiny numbers.
+ */
+async function competitorCitationGapCandidates(brandId, now) {
+ const from = new Date(now.getTime() - detection.windowDays * DAY_MS);
+ const { data, error } = await supabaseAdmin.rpc('ai_visibility_aggregates', {
+ p_brand_id: brandId,
+ p_date_from: from.toISOString(),
+ p_date_to: now.toISOString(),
+ });
+ if (error) throw new Error(error.message);
+
+ const brandCitations = Number(data?.citation_answers ?? 0);
+ const leader = (data?.by_competitor ?? []).reduce(
+ (top, c) => (Number(c.citation_answers ?? 0) > Number(top?.citation_answers ?? -1) ? c : top),
+ null,
+ );
+ if (!leader) return [];
+
+ const leaderCitations = Number(leader.citation_answers ?? 0);
+ const gap = classifyCitationGap({ brandCitations, leaderCitations });
+ if (!gap) return [];
+
+ return [
+ {
+ kind: 'competitor_citation_gap',
+ dedupKey: `competitor_citation_gap:${leader.competitor_id}`,
+ source: ['ai_results'],
+ payload: { competitorName: leader.name, competitorCitations: leaderCitations },
+ previousValue: leaderCitations,
+ currentValue: brandCitations,
+ changeValue: -gap.absoluteGap,
+ },
+ ];
+}
+
export async function recordSignalsForBrand(brandId, { now = new Date() } = {}) {
const metrics = await computePulseMetrics(brandId, {
windowDays: detection.windowDays,
@@ -317,6 +470,8 @@ export async function recordSignalsForBrand(brandId, { now = new Date() } = {})
candidates.push(...(await pageOpportunityCandidates(brandId)));
candidates.push(...(await uncitedMentionCandidates(brandId, now)));
candidates.push(...(await auditCandidates(brandId, now)));
+ candidates.push(...(await platformGapCandidates(brandId)));
+ candidates.push(...(await competitorCitationGapCandidates(brandId, now)));
// Existing rows decide insert vs update vs reopen. A brand's signal set is
// small (tens), so reading it whole is cheaper than being clever.
diff --git a/web/messages/en.json b/web/messages/en.json
index 0653b37ec..f71645727 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -274,13 +274,14 @@
"crossed": "Crossed",
"uncited": "Uncited",
"issue": "Issue",
- "slipping": "Slipping"
+ "slipping": "Slipping",
+ "gap": "Gap"
},
"affected": {
"prompts": "{count, plural, one {1 prompt} other {# prompts}}",
"urls": "{count, plural, one {1 URL} other {# URLs}}",
- "platform": "1 platform",
- "competitor": "1 competitor",
+ "platform": "Platform",
+ "competitor": "Competitor",
"allPrompts": "All prompts"
},
"menu": {
@@ -363,6 +364,14 @@
"visibility_slipping": {
"title": "Visibility is slipping",
"description": "You were visible in {from}% of responses, now {to}%."
+ },
+ "platform_gap": {
+ "title": "Weak on {platform}",
+ "description": "You are visible in {bestRate}% of {best} answers, but only {rate}% on {platform}."
+ },
+ "competitor_citation_gap": {
+ "title": "A competitor is cited far more often",
+ "description": "{competitor} was cited in {theirs} answers; you were cited in {ours}."
}
},
"actionCategories": {
@@ -524,6 +533,17 @@
"description": "Visibility is falling from a strong position.",
"descriptionWithDrop": "Visibility slipped from {from}% to {to}% — still strong, but heading down.",
"goal": "Hold the position while it is still there, rather than recovering it later."
+ },
+ "expand_platform_visibility": {
+ "title": "Expand visibility on {platform}",
+ "description": "You reach {bestRate}% of {best} answers but {rate}% on {platform} — the content ranks, this engine does not surface it.",
+ "goal": "Close the gap between your strongest engine and your weakest."
+ },
+ "close_citation_gap": {
+ "title": "Close the citation gap",
+ "description": "A competitor is cited far more often than you are.",
+ "descriptionWithName": "{competitor} was cited in {theirs} answers to your {ours}.",
+ "goal": "Earn citations from the sources answering these prompts."
}
},
"actionTasks": {
@@ -544,7 +564,10 @@
"strengthen_content": "Strengthen your content where they now win",
"diagnose_slip": "Diagnose what changed in the last week",
"review_responses": "Review the AI responses that stopped mentioning you",
- "reinforce_content": "Reinforce the content behind the affected prompts"
+ "reinforce_content": "Reinforce the content behind the affected prompts",
+ "compare_platforms": "Compare how each engine answers the affected prompts",
+ "compare_citations": "Compare which sources cite the competitor and not you",
+ "identify_sources": "Identify the sources worth earning a citation from"
},
"taskStatus": {
"todo": "To Do",
diff --git a/web/src/components/action-center/action-table.tsx b/web/src/components/action-center/action-table.tsx
index c873bcfae..b2a2019a2 100644
--- a/web/src/components/action-center/action-table.tsx
+++ b/web/src/components/action-center/action-table.tsx
@@ -8,6 +8,8 @@ import {
Swords,
Wrench,
ShieldCheck,
+ Layers,
+ Quote,
} from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
@@ -29,6 +31,8 @@ import { cn } from '@/lib/utils';
export const KIND_ICONS: Record<ActionKind, React.ComponentType<{ className?: string }>> = {
recover_visibility: BarChart3,
protect_visibility: ShieldCheck,
+ expand_platform_visibility: Layers,
+ close_citation_gap: Quote,
capture_ai_traffic: MousePointerClick,
convert_mentions: MessageSquare,
fix_low_scores: Wrench,
diff --git a/web/src/components/action-center/signal-table.tsx b/web/src/components/action-center/signal-table.tsx
index e72f0caa3..a09723f6d 100644
--- a/web/src/components/action-center/signal-table.tsx
+++ b/web/src/components/action-center/signal-table.tsx
@@ -19,6 +19,8 @@ import {
Trophy,
Unlink,
X,
+ Layers,
+ Quote,
} from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import {
@@ -50,6 +52,8 @@ import { cn } from '@/lib/utils';
export const SIGNAL_ICONS: Record<SignalKind, React.ComponentType<{ className?: string }>> = {
sharp_drop: TrendingDown,
visibility_slipping: TrendingDown,
+ platform_gap: Layers,
+ competitor_citation_gap: Quote,
prompt_gain: TrendingUp,
new_engine: Sparkles,
lost_citations: Unlink,
diff --git a/web/src/lib/action-center/display.ts b/web/src/lib/action-center/display.ts
index 72ae703b9..f298672ba 100644
--- a/web/src/lib/action-center/display.ts
+++ b/web/src/lib/action-center/display.ts
@@ -9,6 +9,11 @@ import type { ActionItem } from '@/lib/actions/action-center';
type Translator = (key: string, values?: Record<string, string | number>) => string;
+function str(payload: Record<string, unknown>, key: string): string {
+ const value = payload[key];
+ return typeof value === 'string' ? value : '';
+}
+
function num(payload: Record<string, unknown>, key: string): number {
return Number(payload[key] ?? 0);
}
@@ -49,6 +54,29 @@ export function actionTexts(
title: t('capture_ai_traffic.title', { pages: num(p, 'pageCount') }),
description: t('capture_ai_traffic.description'),
};
+ case 'expand_platform_visibility':
+ return {
+ title: t('expand_platform_visibility.title', { platform: str(p, 'platform') }),
+ description: t('expand_platform_visibility.description', {
+ platform: str(p, 'platform'),
+ best: str(p, 'bestPlatform'),
+ bestRate: num(p, 'dropFrom'),
+ rate: num(p, 'dropTo'),
+ }),
+ };
+ case 'close_citation_gap': {
+ const names = Array.isArray(p.competitorNames) ? (p.competitorNames as string[]) : [];
+ return {
+ title: t('close_citation_gap.title'),
+ description: names[0]
+ ? t('close_citation_gap.descriptionWithName', {
+ competitor: names[0],
+ theirs: num(p, 'competitorCitations'),
+ ours: num(p, 'citationCount'),
+ })
+ : t('close_citation_gap.description'),
+ };
+ }
case 'convert_mentions':
return {
title: t('convert_mentions.title'),
@@ -83,6 +111,14 @@ export function actionContextTags(action: ActionItem, t: Translator): string[] {
break;
case 'protect_visibility':
break;
+ case 'expand_platform_visibility':
+ tags.push(str(p, 'platform'));
+ break;
+ case 'close_citation_gap': {
+ const names = Array.isArray(p.competitorNames) ? (p.competitorNames as string[]) : [];
+ if (names[0]) tags.push(names[0]);
+ break;
+ }
case 'capture_ai_traffic':
tags.push(t('tags.pages', { count: num(p, 'pageCount') }));
break;
diff --git a/web/src/lib/action-center/registry.ts b/web/src/lib/action-center/registry.ts
index 20cb0b784..803269de3 100644
--- a/web/src/lib/action-center/registry.ts
+++ b/web/src/lib/action-center/registry.ts
@@ -32,6 +32,8 @@ export type ActionOutcome =
export type ActionKind =
| 'recover_visibility'
| 'protect_visibility'
+ | 'expand_platform_visibility'
+ | 'close_citation_gap'
| 'capture_ai_traffic'
| 'convert_mentions'
| 'fix_low_scores'
@@ -101,6 +103,14 @@ export const ACTION_KINDS: Record<ActionKind, ActionKindMeta> = {
kind: 'protect_visibility',
taskKeys: ['diagnose_slip', 'review_responses', 'reinforce_content', 'validate'],
},
+ expand_platform_visibility: {
+ kind: 'expand_platform_visibility',
+ taskKeys: ['compare_platforms', 'coverage_gaps', 'optimize_content', 'validate'],
+ },
+ close_citation_gap: {
+ kind: 'close_citation_gap',
+ taskKeys: ['compare_citations', 'identify_sources', 'strengthen_sources', 'validate'],
+ },
capture_ai_traffic: {
kind: 'capture_ai_traffic',
taskKeys: ['review_pages', 'coverage_gaps', 'optimize_content', 'validate'],
diff --git a/web/src/lib/signals/display.ts b/web/src/lib/signals/display.ts
index 455bfc42c..3de143e89 100644
--- a/web/src/lib/signals/display.ts
+++ b/web/src/lib/signals/display.ts
@@ -21,6 +21,19 @@ export function signalTexts(signal: Signal, t: Translator): { title: string; des
case 'sharp_drop':
case 'visibility_slipping':
return { from: signal.previousValue ?? 0, to: signal.currentValue ?? 0 };
+ case 'platform_gap':
+ return {
+ platform: str(p, 'platform'),
+ best: str(p, 'bestPlatform'),
+ rate: signal.currentValue ?? 0,
+ bestRate: signal.previousValue ?? 0,
+ };
+ case 'competitor_citation_gap':
+ return {
+ competitor: str(p, 'competitorName'),
+ theirs: signal.previousValue ?? 0,
+ ours: signal.currentValue ?? 0,
+ };
case 'prompt_gain':
return { prompt: str(p, 'promptText'), gain: signal.changeValue ?? 0 };
case 'new_engine':
@@ -71,6 +84,10 @@ export function signalAffected(
case 'sharp_drop':
case 'visibility_slipping':
return { label: t('affected.allPrompts'), detail: null };
+ case 'platform_gap':
+ return { label: t('affected.platform'), detail: str(p, 'platform') };
+ case 'competitor_citation_gap':
+ return { label: t('affected.competitor'), detail: str(p, 'competitorName') };
case 'prompt_gain':
case 'lost_citations':
return { label: t('affected.prompts', { count: 1 }), detail: str(p, 'promptText') };
diff --git a/web/src/lib/signals/registry.ts b/web/src/lib/signals/registry.ts
index 3da3ea8e5..6dc10b0bb 100644
--- a/web/src/lib/signals/registry.ts
+++ b/web/src/lib/signals/registry.ts
@@ -26,6 +26,8 @@ export type SignalStatus = 'new' | 'acknowledged' | 'resolved' | 'dismissed';
export type SignalKind =
| 'sharp_drop'
| 'visibility_slipping'
+ | 'platform_gap'
+ | 'competitor_citation_gap'
| 'prompt_gain'
| 'new_engine'
| 'lost_citations'
@@ -73,6 +75,7 @@ export interface SignalKindMeta {
| 'crossed'
| 'uncited'
| 'slipping'
+ | 'gap'
| 'issue';
/** Whether the change arrow, when change_value is present, is good news. */
positive: boolean;
@@ -81,6 +84,8 @@ export interface SignalKindMeta {
export const SIGNAL_KINDS: Record<SignalKind, SignalKindMeta> = {
sharp_drop: { kind: 'sharp_drop', stateKey: 'dropped', positive: false },
visibility_slipping: { kind: 'visibility_slipping', stateKey: 'slipping', positive: false },
+ platform_gap: { kind: 'platform_gap', stateKey: 'gap', positive: false },
+ competitor_citation_gap: { kind: 'competitor_citation_gap', stateKey: 'gap', positive: false },
prompt_gain: { kind: 'prompt_gain', stateKey: 'gained', positive: true },
new_engine: { kind: 'new_engine', stateKey: 'gained', positive: true },
lost_citations: { kind: 'lost_citations', stateKey: 'lost', positive: false },