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.

fix(content): draw the Plan's mix bars to one scale, and open the page in its final layout (#1319)

Cihanc305eb5e46d9
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-insights.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-insights.tsx
index 7a3f63ec9..d9896d627 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-insights.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-insights.tsx
@@ -51,10 +51,42 @@ export function AiResultsStrip({ results, days }: { results: PlanResults; days:
);
}
+/** The two shares as two bars on one scale: AI's light above, the brand's dark below. */
+function MixBars({
+ aiShare,
+ yourShare,
+ scale,
+}: {
+ aiShare: number;
+ yourShare: number;
+ scale: number;
+}) {
+ const width = (share: number) => `${Math.min(100, (share / scale) * 100)}%`;
+ return (
+ <span aria-hidden className="flex flex-col gap-1">
+ <span className="h-1.5 overflow-hidden rounded-full bg-muted">
+ <span
+ data-bar="ai"
+ className="block h-full rounded-full bg-muted-foreground/40"
+ style={{ width: width(aiShare) }}
+ />
+ </span>
+ <span className="h-1.5 overflow-hidden rounded-full bg-muted">
+ <span
+ data-bar="yours"
+ className="block h-full rounded-full bg-foreground"
+ style={{ width: width(yourShare) }}
+ />
+ </span>
+ </span>
+ );
+}
+
/**
* "What AI cites in your topics" (CE-014): per page type, the share of AI
* citations (light bar) and the type's share of the brand's own cited pages
- * (dark bar), two mixes of 100 each, with a gap flagged in amber. A row
+ * (dark bar), two mixes of 100 each drawn to one scale, with a gap flagged
+ * in amber. A row
* filters the priority list to its type; clicking it again clears it.
*/
export function PageTypeMix({
@@ -71,8 +103,9 @@ export function PageTypeMix({
}) {
const t = useTranslations('contentEditor.plan.mix');
const tTypes = useTranslations('contentEditor.pageTypes');
- // The most cited type fills the track; the others are drawn to its scale.
- const scale = Math.max(1, ...rows.map((r) => r.aiShare));
+ // The largest share, AI's or the brand's, fills the track; the others are
+ // drawn to its scale, so neither bar runs past it.
+ const scale = Math.max(1, ...rows.map((r) => Math.max(r.aiShare, r.yourShare)));
return (
<section aria-labelledby="plan-mix-title" className="space-y-2">
@@ -82,7 +115,7 @@ export function PageTypeMix({
</h2>
<span className="flex items-center gap-3 text-xs text-muted-foreground">
<span className="flex items-center gap-1.5">
- <span aria-hidden className="h-2 w-2 rounded-sm bg-muted-foreground/30" />
+ <span aria-hidden className="h-2 w-2 rounded-sm bg-muted-foreground/40" />
{t('aiShare')}
</span>
<span className="flex items-center gap-1.5">
@@ -107,16 +140,7 @@ export function PageTypeMix({
)}
>
<span className="truncate">{tTypes(row.pageType)}</span>
- <span aria-hidden className="relative h-2 rounded-full bg-muted">
- <span
- className="absolute inset-y-0 left-0 rounded-full bg-muted-foreground/30"
- style={{ width: `${(row.aiShare / scale) * 100}%` }}
- />
- <span
- className="absolute inset-y-0 left-0 rounded-full bg-foreground"
- style={{ width: `${(row.yourShare / scale) * 100}%` }}
- />
- </span>
+ <MixBars aiShare={row.aiShare} yourShare={row.yourShare} scale={scale} />
<span className="text-right text-xs tabular-nums text-muted-foreground">
{t('shares', { ai: row.aiShare, yours: row.yourShare })}
{/* On a phone the gap goes under the shares. */}
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.tsx
index 7de40af17..00b8d91da 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
@@ -278,6 +278,36 @@ describe('the Content plan', () => {
);
});
+ it('draws both shares to the larger one’s scale, never past the track', async () => {
+ await renderPage();
+ const widths = (bar: 'ai' | 'yours') =>
+ [
+ ...container.querySelectorAll<HTMLElement>(
+ `section[aria-labelledby="plan-mix-title"] [data-bar="${bar}"]`,
+ ),
+ ].map((el) => Math.round(parseFloat(el.style.width)));
+ // Guides 67% · 33%, blog posts 33% · 67%: the brand's 67% fills the track as AI's does.
+ expect(widths('ai')).toEqual([100, 49]);
+ expect(widths('yours')).toEqual([49, 100]);
+ });
+
+ it('opens in its final layout: one spinner until the list and the sections are both in', async () => {
+ let insightsIn: (value: typeof INSIGHTS) => void = () => {};
+ getContentPlanInsights.mockReturnValue(
+ new Promise<typeof INSIGHTS>((resolve) => (insightsIn = resolve)),
+ );
+ await renderPage();
+ // The list is read, but it waits for the sections above it.
+ expect(rowTexts()).toEqual([]);
+ expect(container.querySelector('[aria-busy="true"]')).not.toBeNull();
+ expect(container.querySelector('section[aria-labelledby="plan-mix-title"]')).toBeNull();
+
+ await act(async () => insightsIn(INSIGHTS));
+ expect(rowTexts()).toHaveLength(3);
+ expect(container.querySelector('section[aria-labelledby="plan-mix-title"]')).not.toBeNull();
+ expect(container.querySelector('[aria-busy="true"]')).toBeNull();
+ });
+
it('filters the list by a page type, and clears it on a second click', async () => {
await renderPage();
const guide = () =>
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsx
index d6589f951..6fd801579 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsx
@@ -126,8 +126,12 @@ export default function ContentPlanPage() {
() => (current?.data ? buildPlan({ ...current.data, siteType }) : null),
[current, siteType],
);
- const shown =
- insights?.brandId === activeBrandId && insights.days === days ? insights.data : null;
+ const insightsRead = insights?.brandId === activeBrandId && insights.days === days;
+ const shown = insightsRead ? insights.data : null;
+ // One spinner until both reads are in, so the page opens in its final
+ // layout rather than the list first and the sections above it after. A
+ // list that failed says so at once.
+ const loading = !current?.failed && !(current && insightsRead);
const mix = useMemo(
() => (shown ? pageTypeMix(shown.citations, siteType, shown.totalCitations) : null),
[shown, siteType],
@@ -245,65 +249,75 @@ export default function ContentPlanPage() {
))}
</div>
- {shown && current && <AiResultsStrip results={shown.results} days={current.days} />}
- {mix && (
- <PageTypeMix
- rows={mix.rows}
- covered={mix.covered}
- selected={typeFilter}
- onSelect={setMixType}
- />
- )}
-
- <div className="space-y-2">
- <div className="flex flex-wrap items-baseline justify-between gap-2">
- <h2 className="text-sm font-medium">{t('listTitle')}</h2>
- <p className="text-xs text-muted-foreground">{filtered ? t('filtered') : t('ranked')}</p>
+ {loading ? (
+ <div className="flex items-center justify-center py-16" aria-busy="true">
+ <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
</div>
- {current?.data && earlier !== 'full' && earlier !== null && (
- <p className="text-xs text-muted-foreground">
- {t(earlier === 'none' ? 'earlier.none' : 'earlier.partial', {
- days: current.days,
- since: current.data.tracking.trackedSince
- ? format.dateTime(new Date(`${current.data.tracking.trackedSince}T00:00:00Z`), {
- month: 'short',
- day: 'numeric',
- timeZone: 'UTC',
- })
- : '—',
- })}
- </p>
- )}
- <Card className="py-0">
- <CardContent className="px-0">
- {current?.failed ? (
- <div className="flex flex-col items-center gap-3 px-6 py-12 text-center">
- <p className="text-sm text-muted-foreground">{t('loadError')}</p>
- <Button
- variant="outline"
- size="sm"
- onClick={() => {
- setRead(null);
- setAttempt((n) => n + 1);
- }}
- >
- {t('retry')}
- </Button>
- </div>
- ) : !plan ? (
- <div className="flex items-center justify-center py-12" aria-busy="true">
- <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
- </div>
- ) : rows.length === 0 ? (
- <p className="px-6 py-12 text-center text-sm text-muted-foreground">
- {filtered ? t('emptyFiltered') : t('empty')}
+ ) : (
+ <>
+ {shown && current && <AiResultsStrip results={shown.results} days={current.days} />}
+ {mix && (
+ <PageTypeMix
+ rows={mix.rows}
+ covered={mix.covered}
+ selected={typeFilter}
+ onSelect={setMixType}
+ />
+ )}
+
+ <div className="space-y-2">
+ <div className="flex flex-wrap items-baseline justify-between gap-2">
+ <h2 className="text-sm font-medium">{t('listTitle')}</h2>
+ <p className="text-xs text-muted-foreground">
+ {filtered ? t('filtered') : t('ranked')}
+ </p>
+ </div>
+ {current?.data && earlier !== 'full' && earlier !== null && (
+ <p className="text-xs text-muted-foreground">
+ {t(earlier === 'none' ? 'earlier.none' : 'earlier.partial', {
+ days: current.days,
+ since: current.data.tracking.trackedSince
+ ? format.dateTime(new Date(`${current.data.tracking.trackedSince}T00:00:00Z`), {
+ month: 'short',
+ day: 'numeric',
+ timeZone: 'UTC',
+ })
+ : '—',
+ })}
</p>
- ) : (
- <PlanTable rows={rows} days={current?.days ?? 30} onStart={startRow} />
)}
- </CardContent>
- </Card>
- </div>
+ <Card className="py-0">
+ <CardContent className="px-0">
+ {current?.failed ? (
+ <div className="flex flex-col items-center gap-3 px-6 py-12 text-center">
+ <p className="text-sm text-muted-foreground">{t('loadError')}</p>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => {
+ setRead(null);
+ setAttempt((n) => n + 1);
+ }}
+ >
+ {t('retry')}
+ </Button>
+ </div>
+ ) : !plan ? (
+ <div className="flex items-center justify-center py-12" aria-busy="true">
+ <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
+ </div>
+ ) : rows.length === 0 ? (
+ <p className="px-6 py-12 text-center text-sm text-muted-foreground">
+ {filtered ? t('emptyFiltered') : t('empty')}
+ </p>
+ ) : (
+ <PlanTable rows={rows} days={current?.days ?? 30} onStart={startRow} />
+ )}
+ </CardContent>
+ </Card>
+ </div>
+ </>
+ )}
</div>
);
}