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
chore(web): clearer plan and change lines on the Insights cards, and no volume caveat on Prompts (#1113)
Cihanf3cb8973a71d
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 1a3663ac5..e98d86761 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -1733,18 +1733,18 @@"rankOf": "#{rank} of {count} brands","appearedIn": "appeared in {visible} of {active} prompts","trackedPrompts": "Tracked prompts",- "trackedPromptsTip": "Prompts answered in this period. The bar is your plan's prompt locations, shared by all brands and counting only active prompts (paused ones don't count): {used} of {limit} used.",+ "trackedPromptsTip": "Prompts answered in this period. The bar is your plan: {used} of {limit} prompt locations in use, shared by every brand in your workspace. A prompt counts once per location it tracks; paused prompts don't count.","trackedPromptsTipUnlimited": "Prompts answered in this period. Your plan has no prompt location limit.",- "slotsLeft": "{count, plural, one {# slot left} other {# slots left}} · all brands",- "overLimit": "{count, plural, one {# location over your plan} other {# locations over your plan}} · all brands",+ "slotsLeft": "{count, plural, other {# prompts/locations left to add}}",+ "limitReached": "Plan limit reached",+ "overLimit": "{count, plural, other {# over your plan limit}}","unlimited": "{count, plural, one {# active location} other {# active locations}} · Unlimited","quotaLabel": "{used} of {limit} active prompt locations used","mentions": "Mentions",- "mentionsTip": "Times answers named your brand. With Same prompts, the change counts only prompts tracked in both periods.",+ "mentionsTip": "Times answers named your brand. The change is against the previous period.","citations": "Citations",- "citationsTip": "Times answers cited your pages. With Same prompts, the change counts only prompts tracked in both periods.",- "samePrompts": "{count, plural, one {same # prompt} other {same # prompts}}",- "allPrompts": "all prompts",+ "citationsTip": "Times answers cited your pages. The change is against the previous period.",+ "vsPrevious": "vs previous period","netSentiment": "Net sentiment","netSentimentTip": "Positive minus negative share of the answers that name or cite your brand.","sentimentSplit": "{positive} pos · {negative} neg",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.test.tsxnew file mode 100644index 000000000..e54af78c2--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.test.tsx@@ -0,0 +1,111 @@+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { NextIntlClientProvider } from 'next-intl';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import messages from '../../../../../../messages/en.json';+import type { InsightsSummary, TrackedPromptsKpi } from '@/lib/actions/tracking';+import { KpiRows } from './_kpi-cards';++(+ globalThis as typeof globalThis & {+ IS_REACT_ACT_ENVIRONMENT: boolean;+ }+).IS_REACT_ACT_ENVIRONMENT = true;++// Only what the cards read; the rest of the summary doesn't matter here.+const summary = (over: Partial<InsightsSummary> = {}) =>+ ({+ totalResults: 120,+ mentioningResults: 80,+ positionedResults: 60,+ totalMentions: 340,+ mentionsChange: 12,+ totalCitations: 90,+ citationsChange: -4,+ netSentiment: null,+ netSentimentChange: null,+ positiveSentimentPct: null,+ negativeSentimentPct: null,+ avgPosition: null,+ avgPositionChange: null,+ citationRate: null,+ citationRateChange: null,+ ...over,+ }) as unknown as InsightsSummary;++let container: HTMLDivElement;+let root: Root;++function render(trackedPrompts: TrackedPromptsKpi, over: Partial<InsightsSummary> = {}) {+ act(() => {+ root.render(+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">+ <KpiRows+ summary={summary(over)}+ trend={null}+ trackedPrompts={trackedPrompts}+ coverage={null}+ sov={null}+ competitors={null}+ comparison={null}+ series={null}+ onBreakdown={vi.fn()}+ onNavigate={vi.fn()}+ />+ </NextIntlClientProvider>,+ );+ });+}++const plan = (quotaUsed: number, quotaLimit: number): TrackedPromptsKpi => ({+ activeInPeriod: 7,+ quotaUsed,+ quotaLimit,+});++beforeEach(() => {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+});++afterEach(() => {+ act(() => root.unmount());+ container.remove();+});++describe('the Tracked prompts card', () => {+ it('says how many more prompts or locations the plan can take', () => {+ render(plan(47, 50));+ expect(container.textContent).toContain('3 prompts/locations left to add');+ expect(container.textContent).not.toContain('all brands');+ });++ it('formats a large count', () => {+ render(plan(250, 1500));+ expect(container.textContent).toContain('1,250 prompts/locations left to add');+ });++ it('says the limit is reached when the plan is full', () => {+ render(plan(50, 50));+ expect(container.textContent).toContain('Plan limit reached');+ });++ it('says how far over the limit an account is after a downgrade', () => {+ render(plan(52, 50));+ expect(container.textContent).toContain('2 over your plan limit');+ });+});++describe('the Mentions and Citations cards', () => {+ it('say their change is against the previous period', () => {+ render(plan(47, 50));+ expect(container.textContent?.match(/vs previous period/g)).toHaveLength(2);+ expect(container.textContent).not.toMatch(/same \d+ prompts?/);+ });++ it('say nothing of a change they do not have', () => {+ render(plan(47, 50), { mentionsChange: null, citationsChange: null });+ expect(container.textContent).not.toContain('vs previous period');+ });+});diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.tsxindex 272afac9b..0b0992826 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.tsx@@ -259,8 +259,8 @@ interface KpiRowsProps {/*** The Insights KPI cards (VIS-003): today's five on the first row, the new- * rates on the second, as in the v2 mockup. Changes follow "Compare: Same- * prompts"; the values themselves cover every prompt in the window.+ * rates on the second, as in the v2 mockup. Changes are against the previous+ * period; the values themselves cover every prompt in the window.*/export function KpiRows({summary,@@ -301,10 +301,8 @@ export function KpiRows({active: f.number(coverage.activePrompts),}): null;- const basisSub =- comparison?.basis === 'same'- ? t('samePrompts', { count: comparison.samePrompts })- : t('allPrompts');+ // Under a change, what it is against; nothing without one.+ const vsPrevious = (change: number | null) => (change === null ? null : t('vsPrevious'));const quota =trackedPrompts && trackedPrompts.quotaLimit !== -1@@ -315,8 +313,11 @@ export function KpiRows({: !quota? t('unlimited', { count: trackedPrompts.quotaUsed }): quota.used > quota.limit- ? t('overLimit', { count: quota.used - quota.limit })- : t('slotsLeft', { count: quota.limit - quota.used });+ ? // Only after a downgrade or a lowered limit: adding stops at the limit.+ t('overLimit', { count: quota.used - quota.limit })+ : quota.used === quota.limit+ ? t('limitReached')+ : t('slotsLeft', { count: quota.limit - quota.used });const daily = <K extends keyof KpiSeriesDay>(key: K) =>series ? series.map((d) => d[key] as number | null) : null;@@ -382,7 +383,7 @@ export function KpiRows({icon={MessageCircle}value={f.compact(summary.totalMentions)}delta={upIsGood(summary.mentionsChange, { percent: true, locale })}- sub={basisSub}+ sub={vsPrevious(summary.mentionsChange)}spark={daily('mentions')}onClick={() => onBreakdown('mentions')}clickLabel={t('viewBreakdown', { metric: t('mentions') })}@@ -393,7 +394,7 @@ export function KpiRows({icon={Quote}value={f.compact(summary.totalCitations)}delta={upIsGood(summary.citationsChange, { percent: true, locale })}- sub={basisSub}+ sub={vsPrevious(summary.citationsChange)}spark={daily('citations')}onClick={() => onNavigate('/dashboard/citations')}clickLabel={t('openCitations')}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsxindex 60ae88226..619e81c21 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx@@ -1780,10 +1780,6 @@ export default function PromptsPage() {<h1 className="text-2xl font-bold tracking-tight">Prompts</h1><p className="text-muted-foreground text-sm">Manage every tracked prompt and review estimated AI demand- <span className="ml-2 inline-flex items-center gap-1 text-xs text-muted-foreground/70">- <AlertCircle className="h-3 w-3" />- Volumes are estimates, not exact figures- </span></p></div></div>