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(content): show the Content Agent as a card over the page (CE-025, CE-026) (#1395)

Cihan01a52a205b02
diff --git a/web/messages/en.json b/web/messages/en.json
index 3e3b6602a..2e6b0e893 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -3603,6 +3603,16 @@
"failed": "The agent couldn't start. Try again in a moment."
}
},
+ "agentCard": {
+ "waiting": "{count, plural, one {Content Agent has # suggestion for you} other {Content Agent has # suggestions for you}}",
+ "gain": "Rules {met, number} → {after, number} of {total, number}",
+ "review": "Review",
+ "reviewed": "All suggestions reviewed",
+ "reviewedLine": "{accepted, number} accepted · Rules {met, number} of {total, number}{open, plural, =0 {} other { · # still open}}",
+ "more": "+{count, number} more",
+ "run": "Run Agent",
+ "working": "Content Agent is working"
+ },
"rewrite": {
"bar": "Rewritten page",
"ready": "Content Agent rewrote the page to its rules",
@@ -3617,7 +3627,6 @@
"accept": "Accept",
"reject": "Reject",
"undo": "Undo",
- "close": "Close",
"changed": "The page changed after the agent read it. Reject this rewrite and run it again on the page as it is now.",
"changedAfter": "The page changed after the rewrite was put in. To go back, open History.",
"acceptedToast": "Rewrite put in place. History keeps your page as it was.",
@@ -3629,10 +3638,7 @@
"suggestions": {
"bar": "Agent suggestions",
"agent": "Content Agent",
- "suggested": "suggested {count, plural, one {# change} other {# changes}}",
"fromAction": "from Action AC-{no}",
- "decided": "{accepted} accepted · {rejected} rejected",
- "rulesOpen": "{count, plural, one {# rule still open} other {# rules still open}}",
"runMax": "a run makes at most {max} changes: run it again for the rest",
"acceptAll": "Accept all",
"rejectAll": "Reject all",
@@ -3654,8 +3660,6 @@
"notApplied": "{count, plural, one {# suggestion couldn't be applied} other {# suggestions couldn't be applied}}: the page changed there, AI quotes the passage, or a heading would get too long.",
"saveFailed": "Couldn't keep the decision. Try again.",
"htmlBlocked": "Accept or reject the {count, plural, one {# agent suggestion} other {# agent suggestions}} first, then edit as HTML.",
- "fixRules": "Apply rules with Agent",
- "fixing": "Content Agent is working…",
"fixed": "{count, plural, one {Content Agent suggested # change} other {Content Agent suggested # changes}} · review them in the page",
"fixedMax": "Content Agent suggested {count} changes, the most one run makes · review them, then run it again for the rules still open",
"nothingToFix": "Content Agent found nothing it could change without new facts.",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-bar.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-bar.tsx
deleted file mode 100644
index 29d5cb6a9..000000000
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-bar.tsx
+++ /dev/null
@@ -1,139 +0,0 @@
-'use client';
-
-import { useTranslations } from 'next-intl';
-import { Bot, Loader2, X } from 'lucide-react';
-import { Link } from '@/i18n/navigation';
-import { Button } from '@/components/ui/button';
-import { AGENT_RUN_MAX, suggestionCounts, type DraftSuggestion } from '@/lib/content/suggestions';
-
-/**
- * The agent bar over the page (CE-018): while an agent's suggestions are
- * open, who left how many and from which action, with Reject all and Accept
- * all (open ones only); once all are decided, how many were accepted and
- * rejected and how many rules are still open, with Apply rules with
- * Agent for a new batch (a full batch says a run stops there, so run it
- * again). Undo all brings every decided one back to review.
- */
-export function AgentBar({
- suggestions,
- rulesOpen,
- busy,
- onAcceptAll,
- onRejectAll,
- onUndoAll,
- onClose,
- onFixRules,
- fixing,
-}: {
- suggestions: DraftSuggestion[];
- rulesOpen: number;
- busy: boolean;
- onAcceptAll: () => void;
- onRejectAll: () => void;
- onUndoAll: () => void;
- onClose: () => void;
- /** Apply rules with Agent: new suggestions, again for review. */
- onFixRules: () => void;
- fixing: boolean;
-}) {
- const t = useTranslations('contentEditor.editor.suggestions');
- const { open, accepted, rejected } = suggestionCounts(suggestions);
- const action = suggestions.find((s) => s.actionId && s.actionNo !== null);
-
- return (
- <div
- role="region"
- aria-label={t('bar')}
- className="flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b bg-muted/40 px-4 py-1.5 text-[13px]"
- >
- <Bot aria-hidden className="h-4 w-4 shrink-0 text-muted-foreground" />
- {open > 0 ? (
- <span className="min-w-0">
- <span className="font-medium">{t('agent')}</span> {t('suggested', { count: open })}
- {action && (
- <>
- {' · '}
- <Link
- href={`/dashboard/action-center/actions?action=${action.actionId}`}
- className="underline underline-offset-2 hover:no-underline"
- >
- {t('fromAction', { no: action.actionNo! })}
- </Link>
- </>
- )}
- </span>
- ) : (
- <span className="min-w-0">
- <span className="font-medium">{t('decided', { accepted, rejected })}</span>
- {rulesOpen > 0 && (
- <span className="text-muted-foreground">
- {' · '}
- {t('rulesOpen', { count: rulesOpen })}
- {/* A full run's batch may have stopped short of the rules still open
- (an API batch can hold more, and says nothing of a run). */}
- {suggestions.length === AGENT_RUN_MAX && (
- <>
- {' · '}
- {t('runMax', { max: AGENT_RUN_MAX })}
- </>
- )}
- </span>
- )}
- </span>
- )}
- <span className="ml-auto flex shrink-0 items-center gap-1.5">
- {accepted + rejected > 0 && (
- <Button variant="ghost" size="sm" className="h-7" disabled={busy} onClick={onUndoAll}>
- {t('undoAll')}
- </Button>
- )}
- {open > 0 ? (
- <>
- <Button
- variant="outline"
- size="sm"
- className="h-7"
- disabled={busy}
- onClick={onRejectAll}
- >
- {t('rejectAll')}
- </Button>
- <Button
- variant="outline"
- size="sm"
- className="h-7"
- disabled={busy}
- onClick={onAcceptAll}
- >
- {t('acceptAll')}
- </Button>
- </>
- ) : (
- <>
- {rulesOpen > 0 && (
- <Button
- variant="outline"
- size="sm"
- className="h-7"
- disabled={busy || fixing}
- onClick={onFixRules}
- >
- {fixing && <Loader2 className="h-3.5 w-3.5 animate-spin" />}
- {fixing ? t('fixing') : t('fixRules')}
- </Button>
- )}
- <Button
- variant="ghost"
- size="icon-sm"
- aria-label={t('close')}
- title={t('close')}
- onClick={onClose}
- >
- <X className="h-3.5 w-3.5" />
- </Button>
- </>
- )}
- </span>
- </div>
- );
-}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx
new file mode 100644
index 000000000..7954aa355
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx
@@ -0,0 +1,210 @@
+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 { DraftSuggestion } from '@/lib/content/suggestions';
+import { AgentCard, rulesAfter, type CardRules } from './_agent-card';
+
+vi.mock('@/i18n/navigation', () => ({
+ Link: ({ href, children, ...props }: { href: string; children: React.ReactNode }) => (
+ <a href={href} {...props}>
+ {children}
+ </a>
+ ),
+}));
+
+(
+ globalThis as typeof globalThis & {
+ IS_REACT_ACT_ENVIRONMENT: boolean;
+ }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const suggestion = (over: Partial<DraftSuggestion> = {}): DraftSuggestion => ({
+ id: 's1',
+ batchId: 'b1',
+ actionId: null,
+ actionNo: null,
+ kind: 'replace',
+ blockText: 'We delve into forecasting.',
+ beforeText: 'delve into',
+ afterText: 'look at',
+ reason: 'remove an AI trace (rule)',
+ ruleKeys: ['aiTraces'],
+ status: 'open',
+ ...over,
+});
+
+const rules: CardRules = { met: 9, total: 14, open: new Set(['aiTraces', 'summary', 'faq']) };
+
+let container: HTMLDivElement;
+let root: Root;
+const handlers = {
+ onAcceptAll: vi.fn(),
+ onRejectAll: vi.fn(),
+ onUndoAll: vi.fn(),
+ onReview: vi.fn(),
+ onRun: vi.fn(),
+ onClose: vi.fn(),
+ onDecidePage: vi.fn(),
+};
+
+beforeEach(() => {
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+ Object.values(handlers).forEach((fn) => fn.mockReset());
+});
+
+afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+});
+
+async function render(suggestions: DraftSuggestion[], working = false) {
+ await act(async () => {
+ root.render(
+ <NextIntlClientProvider locale="en" messages={messages}>
+ <AgentCard
+ suggestions={suggestions}
+ rules={rules}
+ busy={false}
+ working={working}
+ {...handlers}
+ />
+ </NextIntlClientProvider>,
+ );
+ });
+}
+
+const buttons = () => [...container.querySelectorAll('button')].map((b) => b.textContent);
+const click = (label: string) =>
+ act(async () =>
+ [...container.querySelectorAll('button')].find((b) => b.textContent === label)!.click(),
+ );
+
+describe('rulesAfter', () => {
+ it('counts each open rule an open suggestion meets once', () => {
+ expect(
+ rulesAfter(
+ [
+ suggestion(),
+ suggestion({ id: 's2', ruleKeys: ['aiTraces', 'summary'] }),
+ // Decided, or a rule already met: no gain.
+ suggestion({ id: 's3', ruleKeys: ['faq'], status: 'rejected' }),
+ suggestion({ id: 's4', ruleKeys: ['sentence'] }),
+ ],
+ rules,
+ ),
+ ).toBe(11);
+ expect(rulesAfter([suggestion()], { ...rules, met: 14 })).toBe(14);
+ });
+});
+
+describe('AgentCard', () => {
+ it('says how many suggestions wait, what they change and the rules they gain', async () => {
+ await render([
+ suggestion(),
+ suggestion({ id: 's2', reason: 'add a summary', ruleKeys: ['summary'] }),
+ ]);
+ expect(container.textContent).toContain('Content Agent has 2 suggestions for you');
+ expect(container.textContent).toContain(
+ 'Remove an AI trace (rule) · +1 more · Rules 9 → 11 of 14',
+ );
+ expect(buttons()).toEqual(['Review', 'Reject all', 'Accept all']);
+ await click('Review');
+ expect(handlers.onReview).toHaveBeenCalled();
+ await click('Accept all');
+ expect(handlers.onAcceptAll).toHaveBeenCalled();
+ });
+
+ it('once all are reviewed, says what was accepted and runs the agent again', async () => {
+ await render([
+ suggestion({ status: 'accepted' }),
+ suggestion({ id: 's2', status: 'rejected' }),
+ ]);
+ expect(container.textContent).toContain('All suggestions reviewed');
+ expect(container.textContent).toContain('1 accepted · Rules 9 of 14 · 5 still open');
+ expect(buttons().slice(0, 2)).toEqual(['Undo all', 'Run Agent']);
+ expect(container.querySelector('button[aria-label="Close"]')).not.toBeNull();
+ await click('Run Agent');
+ expect(handlers.onRun).toHaveBeenCalled();
+ });
+
+ it('says it is working, with nothing to press', async () => {
+ await render([], true);
+ const card = container.querySelector('[role="region"]')!;
+ expect(card.getAttribute('aria-busy')).toBe('true');
+ expect(card.textContent).toBe('Content Agent is working');
+ expect(buttons()).toEqual([]);
+ });
+
+ it('shows a page rewritten with its characters, to compare, reject or accept', async () => {
+ const page = suggestion({
+ kind: 'page',
+ beforeHtml: '<h1>Old</h1><p>A much longer page than this one.</p>',
+ afterText: '<h1>New</h1><p>Shorter.</p>',
+ reason: 'cut to the Length',
+ });
+ await render([page]);
+ expect(container.textContent).toContain('Content Agent rewrote the page to its rules');
+ expect(container.textContent).toContain('37 → 12 characters · cut to the Length');
+ expect(buttons()).toEqual(['Compare', 'Reject', 'Accept']);
+ await click('Accept');
+ expect(handlers.onDecidePage).toHaveBeenCalledWith('accepted');
+ });
+
+ it('stops all of its motion with reduced motion, in every state', async () => {
+ for (const [list, working] of [
+ [[suggestion()], false],
+ [[suggestion({ status: 'accepted' })], false],
+ [[], true],
+ ] as const) {
+ await render([...list], working);
+ const moving = [...container.querySelectorAll('[class*="animate-agent"]')];
+ expect(moving.length).toBeGreaterThan(0);
+ expect(
+ moving.every((el) => /motion-reduce:(animate-none|hidden)/.test(el.getAttribute('class')!)),
+ ).toBe(true);
+ }
+ });
+
+ it('undoes a page rewrite rejected, and runs the agent on what is still open', async () => {
+ await render([
+ suggestion({
+ kind: 'page',
+ status: 'rejected',
+ beforeHtml: '<p>Old.</p>',
+ afterText: '<p>New.</p>',
+ }),
+ ]);
+ expect(container.textContent).toContain('Rewrite rejected');
+ await click('Undo');
+ expect(handlers.onDecidePage).toHaveBeenCalledWith('open');
+ });
+
+ it('says why Run Agent waits, in the card, never only on hover', async () => {
+ await act(async () => {
+ root.render(
+ <NextIntlClientProvider locale="en" messages={messages}>
+ <AgentCard
+ suggestions={[suggestion({ status: 'accepted' })]}
+ rules={rules}
+ busy={false}
+ working={false}
+ runBlocked="Content Agent is already working on this page."
+ {...handlers}
+ />
+ </NextIntlClientProvider>,
+ );
+ });
+ const run = [...container.querySelectorAll('button')].find(
+ (b) => b.textContent === 'Run Agent',
+ )!;
+ expect(run.disabled).toBe(true);
+ expect(run.title).toBe('');
+ const reason = container.querySelector(`[id="${run.getAttribute('aria-describedby')}"]`)!;
+ expect(reason.textContent).toBe('Content Agent is already working on this page.');
+ expect(reason.className).toContain('text-amber-700');
+ });
+});
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.tsx
new file mode 100644
index 000000000..a83a0fa1c
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.tsx
@@ -0,0 +1,422 @@
+'use client';
+
+import { useId, useState } from 'react';
+import { useLocale, useTranslations } from 'next-intl';
+import { X } from 'lucide-react';
+import { Link } from '@/i18n/navigation';
+import { Button } from '@/components/ui/button';
+import {
+ AGENT_RUN_MAX,
+ suggestionCounts,
+ type DraftSuggestion,
+ type SuggestionStatus,
+} from '@/lib/content/suggestions';
+import { cn } from '@/lib/utils';
+import { PageCompareDialog, pageCharacters } from './_page-rewrite';
+
+/**
+ * The Content Agent card over the page (Content Editor v1.1, CE-025/026):
+ * one place for what the agent left and what it is doing, in three states.
+ * - waiting: how many suggestions, what they change and the rules they
+ * gain ("Rules 9 → 10 of 14"), with Review, Reject all and Accept all;
+ * a whole page rewritten shows its characters, with Compare;
+ * - all reviewed: how many were accepted and the rules met and still
+ * open, with Undo all and Run Agent;
+ * - working: while the agent runs from the page.
+ * The tile moves a little (a soft ring, a blink, a spark; a sweep and a
+ * breath while working), never a rotating ring, and not at all with reduced
+ * motion. The card wraps on a narrow page: its buttons go under the text.
+ */
+
+/** A ghost button on the card's grey: its hover shows. */
+const GHOST = 'hover:bg-foreground/5 dark:hover:bg-foreground/10';
+
+/** The rules as the card counts them. */
+export interface CardRules {
+ met: number;
+ total: number;
+ /** The keys of the rules on that the page doesn't meet now. */
+ open: Set<string>;
+}
+
+/**
+ * The rules met once the open suggestions are in: each open rule a
+ * suggestion says it meets counts once.
+ */
+export function rulesAfter(suggestions: DraftSuggestion[], rules: CardRules): number {
+ const meets = new Set(
+ suggestions
+ .filter((s) => s.status === 'open')
+ .flatMap((s) => s.ruleKeys)
+ .filter((key) => rules.open.has(key)),
+ );
+ return Math.min(rules.total, rules.met + meets.size);
+}
+
+/** The agent's reason as a sentence: its first letter upper-cased, in the page's locale. */
+function sentence(reason: string, locale: string): string {
+ return reason.charAt(0).toLocaleUpperCase(locale) + reason.slice(1);
+}
+
+/**
+ * The agent: a robot whose eyes blink (or look around while it works) and a
+ * spark by its antenna, slower once all are reviewed.
+ */
+function AgentIcon({ working, slow }: { working: boolean; slow: boolean }) {
+ return (
+ <svg
+ viewBox="0 0 24 24"
+ aria-hidden
+ className="h-[22px] w-[22px] fill-none stroke-current [stroke-linecap:round] [stroke-linejoin:round] [stroke-width:1.8]"
+ >
+ <rect x="4" y="8" width="16" height="11" rx="3.5" />
+ <path d="M12 8V5" />
+ <circle cx="12" cy="4" r="1" className="fill-current" />
+ <g
+ className={cn(
+ '[transform-box:fill-box] [transform-origin:center] motion-reduce:animate-none',
+ working ? 'animate-agent-look' : 'animate-agent-blink',
+ )}
+ >
+ <path d="M9 13v1.5M15 13v1.5" className="[stroke-width:2.2]" />
+ </g>
+ <path d="M2 12.5v2M22 12.5v2" />
+ <path
+ d="M19 2.5l.6 1.6 1.6.6-1.6.6-.6 1.6-.6-1.6-1.6-.6 1.6-.6z"
+ className={cn(
+ 'animate-agent-spark fill-amber-400 stroke-amber-400 [stroke-width:0.8] [transform-box:fill-box] [transform-origin:center] motion-reduce:animate-none dark:fill-amber-500 dark:stroke-amber-500',
+ slow && '[animation-duration:2.4s]',
+ )}
+ />
+ </svg>
+ );
+}
+
+function AgentTile({
+ tone,
+ count,
+}: {
+ tone: 'waiting' | 'done' | 'working';
+ /** The open suggestions, as a badge while there are any. */
+ count: number;
+}) {
+ return (
+ // The title says it all: the tile and its count are for the eye.
+ <span
+ aria-hidden
+ className={cn(
+ 'relative flex h-10 w-10 shrink-0 items-center justify-center overflow-visible rounded-xl',
+ tone === 'done'
+ ? 'bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400'
+ : 'bg-foreground text-background',
+ tone === 'working' && 'animate-agent-breathe motion-reduce:animate-none',
+ )}
+ >
+ {/* A soft ring that grows out of the tile: never one that rotates. */}
+ {tone !== 'working' && (
+ <span
+ aria-hidden
+ className={cn(
+ 'pointer-events-none absolute -inset-1 rounded-[15px] border-2 motion-reduce:hidden',
+ tone === 'done'
+ ? 'animate-agent-ring-slow border-emerald-500/45'
+ : 'animate-agent-ring border-foreground/35',
+ )}
+ />
+ )}
+ {tone === 'working' && (
+ <span
+ aria-hidden
+ className="pointer-events-none absolute inset-0 animate-agent-sweep rounded-xl bg-[linear-gradient(115deg,transparent_30%,color-mix(in_oklab,var(--background)_22%,transparent)_50%,transparent_70%)] bg-[length:250%_100%] motion-reduce:hidden"
+ />
+ )}
+ <AgentIcon working={tone === 'working'} slow={tone === 'done'} />
+ {count > 0 && (
+ <span className="absolute -top-1.5 -right-1.5 flex h-[18px] min-w-[18px] items-center justify-center rounded-full border-2 border-muted bg-amber-700 px-1 text-[11px] font-semibold text-white dark:bg-amber-500 dark:text-amber-950">
+ {count}
+ </span>
+ )}
+ </span>
+ );
+}
+
+/** Three dots that bounce in turn, after "Content Agent is working". */
+function WorkingDots() {
+ return (
+ <span aria-hidden className="ml-1.5 inline-flex gap-[3px] align-middle">
+ {[0, 1, 2].map((i) => (
+ <span
+ key={i}
+ className="h-1 w-1 animate-agent-dot rounded-full bg-foreground opacity-25 motion-reduce:animate-none"
+ style={{ animationDelay: `${i * 0.2}s` }}
+ />
+ ))}
+ </span>
+ );
+}
+
+export function AgentCard({
+ suggestions,
+ rules,
+ busy,
+ working,
+ onAcceptAll,
+ onRejectAll,
+ onUndoAll,
+ onReview,
+ onRun,
+ onClose,
+ onDecidePage,
+ runBlocked = null,
+}: {
+ suggestions: DraftSuggestion[];
+ rules: CardRules;
+ /** A decision is being saved, or the page can't take one now. */
+ busy: boolean;
+ /** The agent is working from this page (Apply rules with Agent). */
+ working: boolean;
+ onAcceptAll: () => void;
+ onRejectAll: () => void;
+ onUndoAll: () => void;
+ /** Scrolls to the first open suggestion and marks it. */
+ onReview: () => void;
+ /** Run Agent once all are reviewed: the open rules, fixed. */
+ onRun: () => void;
+ onClose: () => void;
+ /** A whole page rewritten: accepted, rejected, or open again (Undo). */
+ onDecidePage: (status: SuggestionStatus) => void;
+ /** Why Run Agent can't run now (another agent run, locked passages loading), or null. */
+ runBlocked?: string | null;
+}) {
+ const t = useTranslations('contentEditor.editor.agentCard');
+ const locale = useLocale();
+ const tSuggestions = useTranslations('contentEditor.editor.suggestions');
+ const tRewrite = useTranslations('contentEditor.editor.rewrite');
+ const [comparing, setComparing] = useState(false);
+ const page = suggestions.find((s) => s.kind === 'page') ?? null;
+ const { open, accepted } = suggestionCounts(suggestions);
+ const openOnes = suggestions.filter((s) => s.status === 'open');
+ const action = suggestions.find((s) => s.actionId && s.actionNo !== null);
+ const after = rulesAfter(suggestions, rules);
+ const stillOpen = Math.max(0, rules.total - rules.met);
+ // Run Agent shows once nothing is left to decide; why it can't run is
+ // written in the card, never only on hover (as the Rules card does, CE-028).
+ const runShown = !working && stillOpen > 0 && (page ? page.status !== 'open' : open === 0);
+ const reasonId = useId();
+ const reason = runShown ? runBlocked : null;
+ const tone = working ? 'working' : open > 0 ? 'waiting' : 'done';
+
+ let title: React.ReactNode;
+ let line: React.ReactNode;
+ if (working) {
+ title = (
+ <>
+ {t('working')}
+ <WorkingDots />
+ </>
+ );
+ line = (
+ <span
+ aria-hidden
+ className="mt-2 block h-[3px] w-full overflow-hidden rounded-full bg-border"
+ >
+ {/* Without motion, a faint full line: never a still bar that reads as progress. */}
+ <span className="block h-full w-[30%] animate-agent-slide rounded-full bg-foreground motion-reduce:w-full motion-reduce:animate-none motion-reduce:opacity-30" />
+ </span>
+ );
+ } else if (page) {
+ const { before, after: afterChars } = pageCharacters(page);
+ title =
+ page.status === 'open'
+ ? tRewrite('ready')
+ : page.status === 'accepted'
+ ? tRewrite('accepted')
+ : tRewrite('rejected');
+ line =
+ page.status === 'open' ? (
+ <>
+ {tRewrite('characters', { before, after: afterChars })} · {page.reason}
+ </>
+ ) : page.status === 'accepted' && stillOpen > 0 ? (
+ tRewrite('rulesOpen', { count: stillOpen })
+ ) : null;
+ } else if (open > 0) {
+ title = t('waiting', { count: open });
+ line = (
+ <>
+ {sentence(openOnes[0]?.reason ?? '', locale)}
+ {openOnes.length > 1 && ` · ${t('more', { count: openOnes.length - 1 })}`}
+ {after > rules.met && (
+ <>
+ {' · '}
+ <span className="font-medium text-emerald-700 dark:text-emerald-400">
+ {t('gain', { met: rules.met, after, total: rules.total })}
+ </span>
+ </>
+ )}
+ {action && (
+ <>
+ {' · '}
+ <Link
+ href={`/dashboard/action-center/actions?action=${action.actionId}`}
+ className="underline underline-offset-2 hover:no-underline"
+ >
+ {tSuggestions('fromAction', { no: action.actionNo! })}
+ </Link>
+ </>
+ )}
+ </>
+ );
+ } else {
+ title = t('reviewed');
+ line = (
+ <>
+ {t('reviewedLine', { accepted, met: rules.met, total: rules.total, open: stillOpen })}
+ {/* A full run's batch may have stopped short of the rules still open. */}
+ {stillOpen > 0 && suggestions.length === AGENT_RUN_MAX && (
+ <>
+ {' · '}
+ {tSuggestions('runMax', { max: AGENT_RUN_MAX })}
+ </>
+ )}
+ </>
+ );
+ }
+
+ return (
+ <div
+ role="region"
+ aria-label={page ? tRewrite('bar') : tSuggestions('bar')}
+ aria-busy={working}
+ className="mx-4 mt-3 mb-1 flex flex-wrap items-center gap-x-3.5 gap-y-2.5 rounded-2xl border bg-muted px-3.5 py-3 shadow-xs"
+ >
+ <AgentTile tone={tone} count={working ? 0 : open} />
+ {/* Room for a line of text first: on a narrow page the buttons go under it. */}
+ <span className="min-w-0 flex-1 basis-56">
+ <span className="block text-sm font-semibold [overflow-wrap:anywhere]">{title}</span>
+ {line && (
+ <span className="block text-[12.5px] text-muted-foreground [overflow-wrap:anywhere]">
+ {line}
+ </span>
+ )}
+ {reason && (
+ <span
+ id={reasonId}
+ className="block text-[12.5px] text-amber-700 [overflow-wrap:anywhere] dark:text-amber-400"
+ >
+ {reason}
+ </span>
+ )}
+ </span>
+ {!working && (
+ <span className="ml-auto flex max-w-full flex-wrap items-center justify-end gap-1.5">
+ {page ? (
+ <>
+ <Button
+ variant="ghost"
+ size="sm"
+ className={GHOST}
+ disabled={busy}
+ onClick={() => setComparing(true)}
+ >
+ {tRewrite('compare')}
+ </Button>
+ {page.status === 'open' ? (
+ <>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={busy}
+ onClick={() => onDecidePage('rejected')}
+ >
+ {tRewrite('reject')}
+ </Button>
+ <Button size="sm" disabled={busy} onClick={() => onDecidePage('accepted')}>
+ {tRewrite('accept')}
+ </Button>
+ </>
+ ) : (
+ <>
+ <Button
+ variant="ghost"
+ size="sm"
+ className={GHOST}
+ disabled={busy}
+ onClick={() => onDecidePage('open')}
+ >
+ {tRewrite('undo')}
+ </Button>
+ {stillOpen > 0 && (
+ <Button
+ size="sm"
+ disabled={busy || runBlocked !== null}
+ aria-describedby={reason ? reasonId : undefined}
+ onClick={onRun}
+ >
+ {t('run')}
+ </Button>
+ )}
+ </>
+ )}
+ </>
+ ) : open > 0 ? (
+ <>
+ <Button variant="ghost" size="sm" className={GHOST} onClick={onReview}>
+ {t('review')}
+ </Button>
+ <Button variant="outline" size="sm" disabled={busy} onClick={onRejectAll}>
+ {tSuggestions('rejectAll')}
+ </Button>
+ <Button size="sm" disabled={busy} onClick={onAcceptAll}>
+ {tSuggestions('acceptAll')}
+ </Button>
+ </>
+ ) : (
+ <>
+ <Button
+ variant="ghost"
+ size="sm"
+ className={GHOST}
+ disabled={busy}
+ onClick={onUndoAll}
+ >
+ {tSuggestions('undoAll')}
+ </Button>
+ {stillOpen > 0 && (
+ <Button
+ size="sm"
+ disabled={busy || runBlocked !== null}
+ aria-describedby={reason ? reasonId : undefined}
+ onClick={onRun}
+ >
+ {t('run')}
+ </Button>
+ )}
+ </>
+ )}
+ {open === 0 && (
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ className={GHOST}
+ aria-label={tSuggestions('close')}
+ title={tSuggestions('close')}
+ onClick={onClose}
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ )}
+ </span>
+ )}
+ {page && (
+ <PageCompareDialog
+ suggestion={page}
+ open={comparing}
+ onOpenChange={setComparing}
+ busy={busy}
+ onDecide={onDecidePage}
+ />
+ )}
+ </div>
+ );
+}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
index c98ebff65..32533e9fe 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
@@ -67,7 +67,7 @@ import { detectPageType } from '@/lib/content/page-types';
import { aiTracesFound, fanoutsToUse, lengthWarns, openRulesForAgent } from '@/lib/content/rules';
import { saveBlob } from '@/lib/download';
import { cn } from '@/lib/utils';
-import { AgentBar } from './_agent-bar';
+import { AgentCard } from './_agent-card';
import { DropOverlay, useAttachments } from './_attach';
import {
CITED_EDIT_ALLOWED,
@@ -84,7 +84,7 @@ import { OwnCopies, ownCopyHtml } from './_own-copies';
import { PageTypeMenu } from './_page-type-menu';
import type { AgentRewrite } from './_brief-tab';
import { ruleStatusDetail, type AgentFix, type PageRewrite } from './_rules-tab';
-import { PageRewriteBar, pageChangedSince } from './_page-rewrite';
+import { pageChangedSince } from './_page-rewrite';
import { EditorPanelRail, EditorSidePanel, useSidePanelOpen, type PanelTab } from './_side-panel';
import {
AgentSuggestions,
@@ -572,6 +572,39 @@ export function DraftEditor({
};
const openSuggestions = suggestions.filter((s) => s.status === 'open').length;
const pageSuggestion = suggestions.find((s) => s.kind === 'page') ?? null;
+ // The rules as the agent card counts its gain: met now, and the ones still open.
+ const cardRules = useMemo(
+ () => ({
+ met: rules.met,
+ total: rules.total,
+ open: new Set(
+ rules.rules
+ .filter(({ rule, status }) => rule.on && status.state === 'bad')
+ .map(({ rule }) => rule.key),
+ ),
+ }),
+ [rules.met, rules.total, rules.rules],
+ );
+
+ /**
+ * Review: the first open suggestion in the page's order, scrolled to,
+ * marked for a moment and focused, so the keyboard lands on it too.
+ */
+ const reviewFirst = () => {
+ if (!editor) return;
+ const open = new Set(
+ suggestions.filter((s) => s.status === 'open' && s.kind !== 'page').map((s) => s.id),
+ );
+ const card = [...editor.view.dom.querySelectorAll<HTMLElement>('[data-suggestion]')].find(
+ (node) => open.has(node.dataset.suggestion ?? ''),
+ );
+ if (!card) return;
+ card.scrollIntoView({ block: 'center', behavior: 'smooth' });
+ card.querySelector('button')?.focus({ preventScroll: true });
+ const mark = ['ring-2', 'ring-amber-300', 'dark:ring-amber-700'];
+ card.classList.add(...mark);
+ setTimeout(() => card.classList.remove(...mark), 1200);
+ };
/**
* A whole page rewritten (Rewrite the page to these rules): Accept puts it
@@ -641,7 +674,8 @@ export function DraftEditor({
* batch of suggestions for review.
*/
const fixRules = async (only?: string[]) => {
- if (!editor || fixing || !citedRead) return;
+ // One agent run at a time, and never before the locked passages are read.
+ if (!editor || fixing || starting || rewriting || !citedRead) return;
if (openSuggestions > 0) {
toast(t('suggestions.decideFirst'));
return;
@@ -742,6 +776,14 @@ export function DraftEditor({
? t('suggestions.agentBusy')
: null,
};
+ // The card's Run Agent says why it won't run, as the Rules card does: also
+ // when the only rules left open are ones the agent doesn't fix (one H1).
+ const agentRules = openRulesForAgent(rules.rules);
+ const cardRunBlocked =
+ agentFix.blocked ??
+ (agentRules.forAgent.length === 0 && agentRules.notForAgent.length > 0
+ ? t('suggestions.notForAgent')
+ : null);
// A drag with files over the page shows where they go; one dropped beside
// the page (not on its text) goes in at the cursor.
@@ -1204,21 +1246,13 @@ export function DraftEditor({
</span>
</p>
)}
- {pageSuggestion && !(barClosed && openSuggestions === 0) && (
- <PageRewriteBar
- suggestion={pageSuggestion}
- rulesOpen={Math.max(0, rules.total - rules.met)}
+ {(fixing || (suggestions.length > 0 && !(barClosed && openSuggestions === 0))) && (
+ <AgentCard
+ suggestions={suggestions}
+ rules={cardRules}
// Not while the HTML view holds the page: it would write over it.
busy={deciding || htmlSource !== null}
- onDecide={(to) => void decidePage(pageSuggestion, to)}
- onClose={() => setBarClosed(true)}
- />
- )}
- {!pageSuggestion && suggestions.length > 0 && !(barClosed && openSuggestions === 0) && (
- <AgentBar
- suggestions={suggestions}
- rulesOpen={Math.max(0, rules.total - rules.met)}
- busy={deciding}
+ working={fixing}
onAcceptAll={() =>
void decide(
suggestions.filter((s) => s.status === 'open').map((s) => s.id),
@@ -1237,9 +1271,13 @@ export function DraftEditor({
'undo_all',
)
}
+ onReview={reviewFirst}
+ onRun={() => void fixRules()}
onClose={() => setBarClosed(true)}
- onFixRules={() => void fixRules()}
- fixing={fixing}
+ onDecidePage={(to) => {
+ if (pageSuggestion) void decidePage(pageSuggestion, to);
+ }}
+ runBlocked={cardRunBlocked}
/>
)}
{editor && (
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_page-rewrite.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_page-rewrite.tsx
index 1018ad9b5..f2cbc17aa 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_page-rewrite.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_page-rewrite.tsx
@@ -1,8 +1,7 @@
'use client';
-import { useMemo, useState } from 'react';
+import { useMemo } from 'react';
import { useTranslations } from 'next-intl';
-import { FileText, X } from 'lucide-react';
import { Button } from '@/components/ui/button';
import {
Dialog,
@@ -77,136 +76,61 @@ function PageColumn({ label, html }: { label: string; html: string }) {
);
}
-export function PageRewriteBar({
+/** The characters of a page rewrite's page before and after, as the Rules tab counts them. */
+export function pageCharacters(suggestion: DraftSuggestion): { before: number; after: number } {
+ return {
+ before: pageTextLength(suggestion.beforeHtml ?? ''),
+ after: pageTextLength(suggestion.afterText),
+ };
+}
+
+/**
+ * Compare: the page as the agent read it and the rewrite, side by side, with
+ * Reject and Accept while it is open.
+ */
+export function PageCompareDialog({
suggestion,
- rulesOpen,
+ open,
+ onOpenChange,
busy,
onDecide,
- onClose,
}: {
suggestion: DraftSuggestion;
- rulesOpen: number;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
busy: boolean;
- /** accepted, rejected, or open again (Undo). */
onDecide: (status: SuggestionStatus) => void;
- onClose: () => void;
}) {
const t = useTranslations('contentEditor.editor.rewrite');
- const [comparing, setComparing] = useState(false);
- const before = pageTextLength(suggestion.beforeHtml ?? '');
- const after = pageTextLength(suggestion.afterText);
- const open = suggestion.status === 'open';
+ const { before, after } = pageCharacters(suggestion);
const decide = (status: SuggestionStatus) => {
- setComparing(false);
+ onOpenChange(false);
onDecide(status);
};
-
return (
- <div
- role="region"
- aria-label={t('bar')}
- className="flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b bg-muted/40 px-4 py-1.5 text-[13px]"
- >
- <FileText aria-hidden className="h-4 w-4 shrink-0 text-muted-foreground" />
- {/* Room for a line of text first: on a narrow page the buttons go under it. */}
- <span className="min-w-0 flex-1 basis-64">
- {open ? (
- <>
- <span className="font-medium">{t('ready')}</span>
- {' · '}
- {t('characters', { before, after })}
- <span className="text-muted-foreground">
- {' · '}
- {suggestion.reason}
- </span>
- </>
- ) : (
- <>
- <span className="font-medium">
- {suggestion.status === 'accepted' ? t('accepted') : t('rejected')}
- </span>
- {suggestion.status === 'accepted' && rulesOpen > 0 && (
- <span className="text-muted-foreground">
- {' · '}
- {t('rulesOpen', { count: rulesOpen })}
- </span>
- )}
- </>
- )}
- </span>
- <span className="ml-auto flex shrink-0 items-center gap-1.5">
- <Button
- variant="ghost"
- size="sm"
- className="h-7"
- disabled={busy}
- onClick={() => setComparing(true)}
- >
- {t('compare')}
- </Button>
- {open ? (
- <>
- <Button
- variant="outline"
- size="sm"
- className="h-7"
- disabled={busy}
- onClick={() => decide('rejected')}
- >
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="flex max-h-[90vh] flex-col sm:max-w-6xl">
+ <DialogHeader>
+ <DialogTitle>{t('compareTitle')}</DialogTitle>
+ <DialogDescription>
+ {t('characters', { before, after })} · {suggestion.reason}
+ </DialogDescription>
+ </DialogHeader>
+ <div className="grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-y-auto md:grid-cols-2 md:overflow-hidden">
+ <PageColumn label={t('before', { count: before })} html={suggestion.beforeHtml ?? ''} />
+ <PageColumn label={t('after', { count: after })} html={suggestion.afterText} />
+ </div>
+ {suggestion.status === 'open' && (
+ <DialogFooter>
+ <Button variant="outline" disabled={busy} onClick={() => decide('rejected')}>
{t('reject')}
</Button>
- <Button size="sm" className="h-7" disabled={busy} onClick={() => decide('accepted')}>
+ <Button disabled={busy} onClick={() => decide('accepted')}>
{t('accept')}
</Button>
- </>
- ) : (
- <>
- <Button
- variant="outline"
- size="sm"
- className="h-7"
- disabled={busy}
- onClick={() => decide('open')}
- >
- {t('undo')}
- </Button>
- <Button
- variant="ghost"
- size="icon-sm"
- aria-label={t('close')}
- title={t('close')}
- onClick={onClose}
- >
- <X className="h-3.5 w-3.5" />
- </Button>
- </>
+ </DialogFooter>
)}
- </span>
-
- <Dialog open={comparing} onOpenChange={setComparing}>
- <DialogContent className="flex max-h-[90vh] flex-col sm:max-w-6xl">
- <DialogHeader>
- <DialogTitle>{t('compareTitle')}</DialogTitle>
- <DialogDescription>
- {t('characters', { before, after })} · {suggestion.reason}
- </DialogDescription>
- </DialogHeader>
- <div className="grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-y-auto md:grid-cols-2 md:overflow-hidden">
- <PageColumn label={t('before', { count: before })} html={suggestion.beforeHtml ?? ''} />
- <PageColumn label={t('after', { count: after })} html={suggestion.afterText} />
- </div>
- {open && (
- <DialogFooter>
- <Button variant="outline" disabled={busy} onClick={() => decide('rejected')}>
- {t('reject')}
- </Button>
- <Button disabled={busy} onClick={() => decide('accepted')}>
- {t('accept')}
- </Button>
- </DialogFooter>
- )}
- </DialogContent>
- </Dialog>
- </div>
+ </DialogContent>
+ </Dialog>
);
}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
index 9bf49b5f4..a9dc3efef 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
@@ -916,9 +916,8 @@ describe('the content editor', () => {
await renderPage();
expect(getDraftSuggestions).toHaveBeenCalledWith('d1');
- expect(bar()!.textContent).toContain(
- 'Content Agent suggested 2 changes · from Action AC-214',
- );
+ expect(bar()!.textContent).toContain('Content Agent has 2 suggestions for you');
+ expect(bar()!.textContent).toContain('from Action AC-214');
expect(bar()!.querySelector('a')!.getAttribute('href')).toBe(
'/dashboard/action-center/actions?action=a1',
);
@@ -935,6 +934,30 @@ describe('the content editor', () => {
expect(pageText()).not.toContain('Accuracy is shown');
});
+ it('reviews the first open suggestion: scrolls to it and marks it for a moment', async () => {
+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });
+ const scrolled = vi.fn();
+ const original = Element.prototype.scrollIntoView;
+ Element.prototype.scrollIntoView = scrolled;
+ try {
+ getContentDraft.mockResolvedValue(page);
+ getDraftSuggestions.mockResolvedValue(batch);
+ await renderPage();
+
+ await act(async () => barButton('Review').click());
+ expect(scrolled).toHaveBeenCalledWith({ block: 'center', behavior: 'smooth' });
+ expect(scrolled.mock.contexts[0]).toBe(cardOf('s1'));
+ expect(cardOf('s1')!.classList.contains('ring-2')).toBe(true);
+ // Focused too, so the keyboard lands on it.
+ expect(document.activeElement).toBe(cardOf('s1')!.querySelector('button'));
+ await act(async () => vi.advanceTimersByTime(1200));
+ expect(cardOf('s1')!.classList.contains('ring-2')).toBe(false);
+ } finally {
+ Element.prototype.scrollIntoView = original;
+ vi.useRealTimers();
+ }
+ });
+
it('accepts one into the page, keeping the page before it in History, and undoes it', async () => {
getContentDraft.mockResolvedValue(page);
getDraftSuggestions.mockResolvedValue(batch);
@@ -951,7 +974,7 @@ describe('the content editor', () => {
expect(container.querySelector('.ProseMirror .agent-accepted-text')!.textContent).toBe(
'Accuracy is shown per team, each week, against closed revenue.',
);
- expect(bar()!.textContent).toContain('suggested 1 change');
+ expect(bar()!.textContent).toContain('Content Agent has 1 suggestion for you');
await press('s1', 'Undo');
expect(decideDraftSuggestions).toHaveBeenLastCalledWith(['s1'], 'open');
@@ -1087,7 +1110,9 @@ describe('the content editor', () => {
expect(pageText()).toContain(
'Accuracy is shown per team, each week, against closed revenue.Teams trust it.FAQDoes it work with custom stages? Yes, any stage.',
);
- expect(bar()!.textContent).toMatch(/^2 accepted · 0 rejected · \d+ rules? still open/);
+ expect(bar()!.textContent).toMatch(
+ /^All suggestions reviewed2 accepted · Rules \d+ of \d+ · \d+ still open/,
+ );
// Not a full run's batch: nothing about running it again.
expect(bar()!.textContent).not.toContain('a run makes at most');
@@ -1095,7 +1120,7 @@ describe('the content editor', () => {
await act(async () => {});
expect(decideDraftSuggestions).toHaveBeenLastCalledWith(['s2', 's1'], 'open');
expect(pageText()).toBe(`Pipeline forecasting${VAGUE}Teams trust it.`);
- expect(bar()!.textContent).toContain('suggested 2 changes');
+ expect(bar()!.textContent).toContain('Content Agent has 2 suggestions for you');
});
it('never applies one to a passage AI quotes, or to one the page changed', async () => {
@@ -1912,6 +1937,26 @@ describe('the side panel', () => {
(b) => b.textContent === label,
)!;
+ it('shows the agent card working while the agent runs, then its batch', async () => {
+ getContentDraft.mockResolvedValue(traced);
+ getDraftSuggestions.mockResolvedValueOnce([]).mockResolvedValueOnce([agentSuggestion]);
+ let answer: (value: { count: number }) => void = () => {};
+ fixDraftRules.mockReturnValue(new Promise((resolve) => (answer = resolve)));
+ await openRules();
+
+ await act(async () => panelButton('Apply rules with Agent').click());
+ await act(async () => {});
+ const card = () =>
+ container.querySelector('[role="region"][aria-label="Agent suggestions"]')!;
+ expect(card().getAttribute('aria-busy')).toBe('true');
+ expect(card().textContent).toBe('Content Agent is working');
+
+ await act(async () => answer({ count: 1 }));
+ await act(async () => {});
+ expect(card().getAttribute('aria-busy')).toBe('false');
+ expect(card().textContent).toContain('Content Agent has 1 suggestion for you');
+ });
+
it('sends the open rules and leaves the agent’s batch for review', async () => {
getContentDraft.mockResolvedValue(traced);
getDraftSuggestions.mockResolvedValueOnce([]).mockResolvedValueOnce([agentSuggestion]);
@@ -1939,7 +1984,7 @@ describe('the side panel', () => {
expect(request).toMatchObject({ textRules: [], locked: [] });
expect(
container.querySelector('[role="region"][aria-label="Agent suggestions"]')!.textContent,
- ).toContain('Content Agent suggested 1 change');
+ ).toContain('Content Agent has 1 suggestion for you');
expect(toast.success).toHaveBeenCalledWith(
'Content Agent suggested 1 change · review them in the page',
);
@@ -1995,7 +2040,7 @@ describe('the side panel', () => {
expect(
container.querySelector('[role="region"][aria-label="Agent suggestions"]')!.textContent,
).toMatch(
- /^0 accepted · 8 rejected · \d+ rules? still open · a run makes at most 8 changes: run it again for the rest/,
+ /^All suggestions reviewed0 accepted · Rules \d+ of \d+ · \d+ still open · a run makes at most 8 changes: run it again for the rest/,
);
});
@@ -2020,7 +2065,7 @@ describe('the side panel', () => {
expect(getDraftSuggestions).toHaveBeenCalledTimes(3);
expect(
container.querySelector('[role="region"][aria-label="Agent suggestions"]')!.textContent,
- ).toContain('Content Agent suggested 1 change');
+ ).toContain('Content Agent has 1 suggestion for you');
expect(toast.success).toHaveBeenCalledWith(
'Content Agent suggested 1 change · review them in the page',
);
@@ -2134,7 +2179,7 @@ describe('the side panel', () => {
);
expect(
container.querySelector('[role="region"][aria-label="Agent suggestions"]')!.textContent,
- ).toContain('Content Agent suggested 1 change');
+ ).toContain('Content Agent has 1 suggestion for you');
});
});
diff --git a/web/src/app/globals.css b/web/src/app/globals.css
index 5edc2bd33..430f3207b 100644
--- a/web/src/app/globals.css
+++ b/web/src/app/globals.css
@@ -153,4 +153,99 @@
@media (width >= 1536px) {
max-width: 1536px;
}
-}
\ No newline at end of file
+}
+
+/*
+ * The Content Agent card's motion (Content Editor v1.1, CE-026): subtle, and
+ * never a rotating ring. Each element that moves also takes
+ * motion-reduce:animate-none, so all of it stops with reduced motion.
+ */
+@theme {
+ --animate-agent-ring: agent-ring 2.2s ease-out infinite;
+ --animate-agent-ring-slow: agent-ring 3s ease-out infinite;
+ --animate-agent-blink: agent-blink 4s infinite;
+ --animate-agent-spark: agent-spark 1.6s ease-in-out infinite;
+ --animate-agent-breathe: agent-breathe 1.6s ease-in-out infinite;
+ --animate-agent-sweep: agent-sweep 1.6s ease-in-out infinite;
+ --animate-agent-look: agent-look 1.2s ease-in-out infinite;
+ --animate-agent-dot: agent-dot 1.2s infinite;
+ --animate-agent-slide: agent-slide 1.4s ease-in-out infinite;
+
+ @keyframes agent-ring {
+ 0% {
+ transform: scale(0.9);
+ opacity: 0.9;
+ }
+ 100% {
+ transform: scale(1.25);
+ opacity: 0;
+ }
+ }
+ @keyframes agent-blink {
+ 0%,
+ 92%,
+ 100% {
+ transform: scaleY(1);
+ }
+ 95% {
+ transform: scaleY(0.1);
+ }
+ }
+ @keyframes agent-spark {
+ 0%,
+ 100% {
+ opacity: 0.3;
+ transform: scale(0.7);
+ }
+ 50% {
+ opacity: 1;
+ transform: scale(1.1);
+ }
+ }
+ @keyframes agent-breathe {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--foreground) 10%, transparent);
+ }
+ 50% {
+ box-shadow: 0 0 0 6px color-mix(in oklab, var(--foreground) 6%, transparent);
+ }
+ }
+ @keyframes agent-sweep {
+ 0% {
+ background-position: 150% 0;
+ }
+ 100% {
+ background-position: -100% 0;
+ }
+ }
+ @keyframes agent-look {
+ 0%,
+ 100% {
+ transform: translateX(-1px);
+ }
+ 50% {
+ transform: translateX(1.5px);
+ }
+ }
+ @keyframes agent-dot {
+ 0%,
+ 80%,
+ 100% {
+ opacity: 0.25;
+ transform: translateY(0);
+ }
+ 40% {
+ opacity: 1;
+ transform: translateY(-2px);
+ }
+ }
+ @keyframes agent-slide {
+ 0% {
+ transform: translateX(-100%);
+ }
+ 100% {
+ transform: translateX(340%);
+ }
+ }
+}