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): say in the editor and the Library where a page was sent (#1623)
Cihan4e9975223393
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 53c0c90ca..8ac948e7d 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -4676,6 +4676,20 @@"md": "Export Markdown","failed": "Couldn't export the page. Try again."},+ "sentChip": {+ "webflow": {+ "queued": "Sending to Webflow…",+ "sent": "In Webflow · draft",+ "failed": "Webflow send failed",+ "published": "Live"+ },+ "webhook": {+ "queued": "Sending to your CMS…",+ "sent": "Sent to your CMS",+ "failed": "Send failed",+ "published": "Live"+ }+ },"send": {"button": "Send to CMS","hint": "Send the page to your CMS: Webflow, or your workflow through the brand's webhook",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.tsxindex 1c54e38a2..4cdd81fe4 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@@ -33,6 +33,8 @@ import { DraftMethodBadge, DraftStatusBadge } from '@/components/content/draft-bimport { PublishDialog } from '@/components/content/publish-dialog';import { readLiveUrl } from '@/lib/content/publish-client';import { SendDialog } from '@/components/content/send-to-cms-dialog';+import { CmsSentChip } from '@/components/content/cms-sent-chip';+import { readDraftCms, type DraftCms } from '@/lib/content/cms-send-client';import { updateBrand } from '@/lib/actions/brand';import {decideDraftSuggestions,@@ -3106,6 +3108,19 @@ export function DraftEditor({// Quality is live.const { canManage } = useUserRole();const [sendOpen, setSendOpen] = useState<{ html: string } | null>(null);+ // The page's last send to a CMS, for the header (#1331): read once, then as sent.+ const [cmsLast, setCmsLast] = useState<DraftCms['last']>(null);+ useEffect(() => {+ let cancelled = false;+ readDraftCms(draft.id)+ .then((read) => {+ if (!cancelled && read?.last) setCmsLast(read.last);+ })+ .catch((err) => console.error('Failed to read the page’s last send:', err));+ return () => {+ cancelled = true;+ };+ }, [draft.id]);const [preparing, setPreparing] = useState(false);// HTML edited in the HTML view and not applied isn't in the page to save.const htmlUnapplied = htmlSource !== null && htmlEdited;@@ -3915,6 +3930,7 @@ export function DraftEditor({)}<DraftMethodBadge method={draft.method} /><DraftStatusBadge status={status} />+ {cmsLast && <CmsSentChip last={cmsLast} />}<buttontype="button"onClick={() => openPanelTab('rules')}@@ -4318,6 +4334,7 @@ export function DraftEditor({fillFirstPlaceholder();}}onClose={() => setSendOpen(null)}+ onSent={setCmsLast}/>)}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.tsxindex 5adbe4bd8..7cb0eee22 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@@ -192,7 +192,8 @@ vi.mock('mammoth', () => ({vi.mock('sonner', () => ({ toast }));const saveBlob = vi.hoisted(() => vi.fn());vi.mock('@/lib/download', () => ({ saveBlob }));-const readDraftCms = vi.hoisted(() => vi.fn());+// The header reads the page's last send as it opens: none, unless a test says.+const readDraftCms = vi.hoisted(() => vi.fn(async () => null as unknown));const sendPagesToCms = vi.hoisted(() => vi.fn());vi.mock('@/lib/content/cms-send-client', () => ({ readDraftCms, sendPagesToCms }));// The brand's Webflow connection (#1331, phase 2): none here.@@ -5948,10 +5949,52 @@ describe('the side panel', () => {);});+ it('says in the header where the page went, once sent', async () => {+ getContentDraft.mockResolvedValue(draft());+ await renderPage();+ expect(container.textContent).not.toContain('Sent to your CMS');+ await act(async () => button('Send to CMS')!.click());+ await act(async () => {});+ await act(async () => inDialog('Send').click());+ expect(container.textContent).toContain('Sent to your CMS');+ });++ it('says in the header that a send failed, while the dialog says why', async () => {+ sendPagesToCms.mockResolvedValueOnce({+ ok: true,+ deliveries: [{ id: 'x1', draftId: 'd1', status: 'failed', http_status: 500, error: null }],+ });+ getContentDraft.mockResolvedValue(draft());+ await renderPage();+ await act(async () => button('Send to CMS')!.click());+ await act(async () => {});+ await act(async () => inDialog('Send').click());+ expect(dialog()!.querySelector('[role="alert"]')!.textContent).toContain(+ "The webhook answered 500 and didn't take the page.",+ );+ expect(container.textContent).toContain('Send failed');+ await act(async () => inDialog('Cancel').click());+ expect(dialog()).toBeNull();+ expect(container.textContent).toContain('Send failed');+ });++ it('says in the header, as the page opens, that it is in Webflow as a draft', async () => {+ readDraftCms.mockResolvedValue({+ fields: {},+ publishedUrl: null,+ last: { status: 'sent', target: 'webflow', at: '2026-10-27T09:00:00Z', error: null },+ });+ getContentDraft.mockResolvedValue(draft());+ await renderPage();+ expect(container.textContent).toContain('In Webflow · draft');+ });+it('opens Before you publish first while Quality is on', async () => {process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '1';getContentDraft.mockResolvedValue(draft({ pageType: 'blog_post' }));await renderPage();+ // The header's read, as the page opened: the dialog's own comes after.+ readDraftCms.mockClear();await act(async () => button('Send to CMS')!.click());expect(dialog()!.textContent).toContain('Before you publish');expect(readDraftCms).not.toHaveBeenCalled();@@ -5979,6 +6022,7 @@ describe('the side panel', () => {it('saves what is waiting before it sends, as Mark ready does', async () => {getContentDraft.mockResolvedValue(draft());await renderPage();+ readDraftCms.mockClear();await editAsHtml('<h1>Pipeline forecasting</h1><p>Edited.</p>');expect(saveContentDraft).not.toHaveBeenCalled();await act(async () => button('Send to CMS')!.click());@@ -6002,6 +6046,7 @@ describe('the side panel', () => {saveContentDraft.mockResolvedValue({ ok: false, reason: 'conflict' });getContentDraft.mockResolvedValue(draft());await renderPage();+ readDraftCms.mockClear();await editAsHtml('<h1>Pipeline forecasting</h1><p>Edited.</p>');await act(async () => button('Send to CMS')!.click());await act(async () => {});diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsxindex ac6975375..f94b04657 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx@@ -288,9 +288,13 @@ function RowMenu({ draft, actions }: { draft: ContentDraftListItem; actions: Lib);}-/** A draft's last send to the CMS, as an icon whose tip says when and how it went. */+/**+ * A draft's last send to the CMS, as an icon whose tip says when and how it+ * went, and on wide screens its word: "In Webflow · draft", "Live"…+ */function CmsStatusMark({ status }: { status: CmsStatus }) {const t = useTranslations('contentEditor.library.cms');+ const tShort = useTranslations('contentEditor.editor.sentChip');const format = useFormatter();const when = format.dateTime(new Date(status.at), { dateStyle: 'medium', timeStyle: 'short' });const live = status.status === 'published' ? status.publishedUrl : null;@@ -310,7 +314,7 @@ function CmsStatusMark({ status }: { status: CmsStatus }) {: status.status === 'published'? 'text-blue-600 dark:text-blue-400': 'text-muted-foreground';- const className = `inline-flex rounded p-0.5 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 ${tone}`;+ const className = `inline-flex items-center gap-1 rounded p-0.5 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 ${tone}`;return (<Tooltip><TooltipTrigger@@ -332,6 +336,9 @@ function CmsStatusMark({ status }: { status: CmsStatus }) {}>{icon}+ <span aria-hidden className="hidden whitespace-nowrap text-xs font-medium xl:inline">+ {tShort(`${status.target}.${status.status}`)}+ </span></TooltipTrigger><TooltipContent className="max-w-72 space-y-1"><p>{label}</p>diff --git a/web/src/components/content/cms-sent-chip.test.tsx b/web/src/components/content/cms-sent-chip.test.tsxnew file mode 100644index 000000000..9914bf5eb--- /dev/null+++ b/web/src/components/content/cms-sent-chip.test.tsx@@ -0,0 +1,66 @@+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { NextIntlClientProvider } from 'next-intl';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import messages from '../../../messages/en.json';+import type { DraftCms } from '@/lib/content/cms-send-client';+import { CmsSentChip } from './cms-sent-chip';++(+ globalThis as typeof globalThis & {+ IS_REACT_ACT_ENVIRONMENT: boolean;+ }+).IS_REACT_ACT_ENVIRONMENT = true;++let container: HTMLDivElement;+let root: Root;++async function render(last: NonNullable<DraftCms['last']>) {+ await act(async () => {+ root.render(+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">+ <CmsSentChip last={last} />+ </NextIntlClientProvider>,+ );+ });+}++beforeEach(() => {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+});++afterEach(() => {+ act(() => root.unmount());+ container.remove();+});++const at = '2026-10-27T09:00:00Z';++/** The editor header's word on the page's last send (#1331). */+describe('CmsSentChip', () => {+ it('says a page sent to Webflow is a draft item there, and when, in its tip', async () => {+ await render({ status: 'sent', target: 'webflow', at, error: null });+ const chip = container.querySelector('span')!;+ expect(chip.textContent).toBe('In Webflow · draft');+ expect(chip.getAttribute('title')).toContain('In Webflow as a draft item since');+ });++ it('says a webhook send went, is going, or failed, with why', async () => {+ await render({ status: 'sent', target: 'webhook', at, error: null });+ expect(container.textContent).toBe('Sent to your CMS');+ await render({ status: 'queued', target: 'webflow', at, error: null });+ expect(container.textContent).toBe('Sending to Webflow…');+ await render({ status: 'failed', target: 'webhook', at, error: 'The webhook answered 500.' });+ expect(container.textContent).toBe('Send failed');+ expect(container.querySelector('span')!.getAttribute('title')).toContain(+ 'The webhook answered 500.',+ );+ });++ it('leaves a published page to its status', async () => {+ await render({ status: 'published', target: 'webflow', at, error: null });+ expect(container.textContent).toBe('');+ });+});diff --git a/web/src/components/content/cms-sent-chip.tsx b/web/src/components/content/cms-sent-chip.tsxnew file mode 100644index 000000000..b9ec04536--- /dev/null+++ b/web/src/components/content/cms-sent-chip.tsx@@ -0,0 +1,41 @@+'use client';++import { useFormatter, useTranslations } from 'next-intl';+import { AlertTriangle, Clock, Send } from 'lucide-react';+import type { DraftCms } from '@/lib/content/cms-send-client';+import { cn } from '@/lib/utils';++/**+ * The editor header's word on the page's last send to a CMS (#1331), beside+ * its status: "In Webflow · draft", "Sent to your CMS", "Sending…" or "Send+ * failed". The page's status stays what the person set: a page sent as a+ * Webflow draft item is still the person's to publish there. A published+ * page says so in its status; nothing more here.+ */+export function CmsSentChip({ last }: { last: NonNullable<DraftCms['last']> }) {+ const t = useTranslations('contentEditor.editor.sentChip');+ const tLibrary = useTranslations('contentEditor.library.cms');+ const format = useFormatter();+ if (last.status === 'published') return null;+ const when = format.dateTime(new Date(last.at), { dateStyle: 'medium', timeStyle: 'short' });+ // The Library's sentence, with when: the chip's tip.+ const tip = tLibrary(last.target === 'webflow' ? `webflow.${last.status}` : last.status, {+ when,+ });+ const failed = last.status === 'failed';+ const Icon = failed ? AlertTriangle : last.status === 'queued' ? Clock : Send;+ return (+ <span+ title={failed && last.error ? `${tip} ${last.error}` : tip}+ className={cn(+ 'inline-flex h-5 shrink-0 items-center gap-1 rounded-full border px-2 text-xs font-medium',+ failed+ ? 'border-red-200 bg-red-50 text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-300'+ : 'border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900 dark:bg-blue-950 dark:text-blue-300',+ )}+ >+ <Icon aria-hidden className="h-3 w-3" />+ {t(`${last.target}.${last.status}`)}+ </span>+ );+}diff --git a/web/src/components/content/send-to-cms-dialog.test.tsx b/web/src/components/content/send-to-cms-dialog.test.tsxindex 06cde4712..6b8c66ae4 100644--- a/web/src/components/content/send-to-cms-dialog.test.tsx+++ b/web/src/components/content/send-to-cms-dialog.test.tsx@@ -99,7 +99,8 @@ afterEach(() => {describe('SendDialog', () => {it('fills the fields from the page and sends it without its H1', async () => {- await render({ byline: 'By Ada Lovelace' });+ const onSent = vi.fn();+ await render({ byline: 'By Ada Lovelace', onSent });expect(readDraftCms).toHaveBeenCalledWith('d1');expect(field('cms-slug').value).toBe('pour-over');expect(field('cms-meta-title').value).toBe('Pour-over');@@ -126,6 +127,10 @@ describe('SendDialog', () => {);expect(toast.success).toHaveBeenCalledWith('Sent to your CMS');expect(onClose).toHaveBeenCalled();+ // The editor's header says where it went.+ expect(onSent).toHaveBeenCalledWith(+ expect.objectContaining({ status: 'sent', target: 'webhook', error: null }),+ );});it('starts from what the draft kept and says where the page went live', async () => {@@ -296,6 +301,38 @@ describe('SendDialog', () => {expect(toast.success).not.toHaveBeenCalled();});+ it('tells the editor a send failed too, with why, so its header says so', async () => {+ const onSent = vi.fn();+ await render({ onSent });+ sendPagesToCms.mockResolvedValueOnce({+ ok: true,+ deliveries: [{ id: 'x1', draftId: 'd1', status: 'failed', http_status: 500, error: null }],+ });+ await act(async () => button('Send').click());+ expect(onSent).toHaveBeenCalledWith({+ status: 'failed',+ target: 'webhook',+ at: expect.any(String),+ error:+ "The webhook answered 500 and didn't take the page. Check your workflow, then send again.",+ });+ sendPagesToCms.mockResolvedValueOnce({+ ok: true,+ deliveries: [+ { id: 'x2', draftId: 'd1', status: 'failed', http_status: null, error: 'Not reached' },+ ],+ });+ await act(async () => button('Send').click());+ expect(onSent).toHaveBeenLastCalledWith(+ expect.objectContaining({ status: 'failed', target: 'webhook', error: 'Not reached' }),+ );+ // Nothing went for a request refused before a send: no word in the header.+ sendPagesToCms.mockResolvedValueOnce({ ok: false, code: 'workspace', field: null });+ await act(async () => button('Send').click());+ expect(onSent).toHaveBeenCalledTimes(2);+ expect(onClose).not.toHaveBeenCalled();+ });+describe('to Webflow (#1331, phase 2)', () => {const ready = {ok: true,diff --git a/web/src/components/content/send-to-cms-dialog.tsx b/web/src/components/content/send-to-cms-dialog.tsxindex 166b210e6..7143e3ec2 100644--- a/web/src/components/content/send-to-cms-dialog.tsx+++ b/web/src/components/content/send-to-cms-dialog.tsx@@ -56,6 +56,7 @@ export function SendDialog({byline,onFillNow,onClose,+ onSent,}: {draftId: string;brandId: string;@@ -71,6 +72,8 @@ export function SendDialog({/** Goes to the first placeholder, to fill it. */onFillNow: () => void;onClose: () => void;+ /** The page went: where, and how it stands (the editor's header says so). */+ onSent?: (last: NonNullable<DraftCms['last']>) => void;}) {const t = useTranslations('contentEditor.editor.send');const tFailure = useTranslations('apiFailure');@@ -177,9 +180,26 @@ export function SendDialog({? { status: delivery.http_status! }: { failed: delivery.error ?? t('errors.failed'), webflow: target === 'webflow' },);+ // The header says it failed too, with why, as the page's last send.+ onSent?.({+ status: 'failed',+ target,+ at: new Date().toISOString(),+ error:+ delivery.error ??+ (refused+ ? t('errors.webhookStatus', { status: delivery.http_status! })+ : t('errors.failed')),+ });return;}keepTarget(target);+ onSent?.({+ status: delivery?.status ?? 'sent',+ target,+ at: new Date().toISOString(),+ error: null,+ });if (target === 'webflow') {// What of the page Webflow's rich text couldn't keep: tables went as lists, images not yet.const changed = delivery?.changed;