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): send a Library page to the CMS from its row, and show each row's last send (Send to CMS #1331, part 3a: Library row) (#1439)

Cihanb1e55d4f4b4a
diff --git a/web/messages/en.json b/web/messages/en.json
index c92af9fc4..7862b4264 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -3379,7 +3379,17 @@
"undo": "Undo",
"failed": "Couldn't save that. Try again.",
"forbidden": "Only admins and managers can archive or delete content.",
- "newerDraft": "A newer draft does this task's work. Archive or delete it first, then restore this one."
+ "newerDraft": "A newer draft does this task's work. Archive or delete it first, then restore this one.",
+ "sendToCms": "Send to CMS",
+ "sendFailed": "Couldn't open the page to send. Try again."
+ },
+ "cms": {
+ "queued": "Sending to your CMS since {when}",
+ "sent": "Sent to your CMS {when}",
+ "failed": "The last send to your CMS failed, {when}",
+ "published": "Published {when}",
+ "openLive": "Published {when}: open the live page in a new tab",
+ "answered": "The webhook answered {status}."
},
"deleteDialog": {
"title": "Delete “{title}”?",
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 532de4eb8..860e4d9c8 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
@@ -29,6 +29,7 @@ import { useAiUsage } from '@/components/providers/ai-usage-provider';
import { useUserRole } from '@/hooks/use-user-role';
import { PLATFORM_LABELS } from '@/config/platform-labels';
import { DraftMethodBadge, DraftStatusBadge } from '@/components/content/draft-badges';
+import { SendDialog } from '@/components/content/send-to-cms-dialog';
import {
decideDraftSuggestions,
fixDraftRules,
@@ -135,7 +136,6 @@ import {
type HeldEdit,
} from './_cited-passages';
import { ExportDialog, type ExportDestination } from './_export-dialog';
-import { SendDialog } from './_send-dialog';
import { ExportMenu } from './_export-menu';
import { sourceDetail } from './_sources-tab';
import { HistoryMenu } from './_history-menu';
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.tsx
index 0868ab776..483546b84 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
@@ -1,14 +1,18 @@
'use client';
-import { useTranslations } from 'next-intl';
+import { useFormatter, useTranslations } from 'next-intl';
import {
+ AlertTriangle,
Archive,
ArchiveRestore,
Bot,
Check,
+ Clock,
Download,
+ ExternalLink,
FileText,
MoreHorizontal,
+ Send,
Trash2,
} from 'lucide-react';
import { Link } from '@/i18n/navigation';
@@ -23,6 +27,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import {
Table,
TableBody,
@@ -45,6 +50,7 @@ import {
type DraftStatus,
type LibraryTab,
} from '@/lib/content/drafts';
+import type { CmsStatus } from '@/lib/content/cms-send-client';
import type { DraftExportFormat } from '@/lib/content/draft-export';
import { formatDate, formatMonthDay } from '@/lib/format';
@@ -63,23 +69,29 @@ export interface LibraryRowActions {
onDelete: (draft: ContentDraftListItem) => void;
/** The draft's page as Word, HTML or Markdown, as the editor's Export. */
onExport: (draft: ContentDraftListItem, format: DraftExportFormat) => void;
+ /** Send to CMS (#1331), for admins and managers. */
+ onSend: (draft: ContentDraftListItem) => void;
}
/**
* The Library's list (CE-002): one row per draft, the latest changed first.
* Columns: Content · Type · Method (Create / Optimize) · By (a person or the
* Content Agent) · Status · Created · Updated. A row opens the draft in the
- * editor; its menu sets the status and, for admins and managers, archives
- * or deletes it (00233).
+ * editor; its menu sets the status and, for admins and managers, sends it
+ * to the CMS (#1331), archives or deletes it (00233). Beside its status, its
+ * last send to the CMS.
*/
export function LibraryTable({
drafts,
tab,
actions,
+ cms,
}: {
drafts: ContentDraftListItem[];
tab: LibraryTab;
actions: LibraryRowActions;
+ /** Each draft's last send to the CMS; none for a draft never sent. */
+ cms: ReadonlyMap<string, CmsStatus>;
}) {
const t = useTranslations('contentEditor.library');
const tTypes = useTranslations('contentEditor.pageTypes');
@@ -114,6 +126,7 @@ export function LibraryTable({
</TableHeader>
<TableBody>
{drafts.map((draft) => {
+ const sent = cms.get(draft.id);
return (
<TableRow key={draft.id}>
<TableCell className="max-w-[180px] pl-6 xl:max-w-[320px]">
@@ -142,11 +155,15 @@ export function LibraryTable({
<TableCell>
{/* The agent works on drafts only: its state says more than "Draft".
One marked ready by hand since reads Ready. */}
- {draft.agentState && (draft.status === 'draft' || draft.status === 'in_review') ? (
- <AgentStateBadge state={draft.agentState} />
- ) : (
- <DraftStatusBadge status={draft.status} />
- )}
+ <span className="flex items-center gap-1.5">
+ {draft.agentState &&
+ (draft.status === 'draft' || draft.status === 'in_review') ? (
+ <AgentStateBadge state={draft.agentState} />
+ ) : (
+ <DraftStatusBadge status={draft.status} />
+ )}
+ {sent && <CmsStatusMark status={sent} />}
+ </span>
</TableCell>
<TableCell className="whitespace-nowrap text-xs text-muted-foreground tabular-nums">
<time dateTime={draft.createdAt} title={formatDate(draft.createdAt)}>
@@ -209,6 +226,13 @@ function RowMenu({ draft, actions }: { draft: ContentDraftListItem; actions: Lib
))}
{actions.canManage && (
<>
+ {/* An archived draft isn't sent: restored, it is. */}
+ {!draft.archivedAt && (
+ <DropdownMenuItem onClick={() => actions.onSend(draft)}>
+ <Send className="h-4 w-4" />
+ {t('sendToCms')}
+ </DropdownMenuItem>
+ )}
<DropdownMenuSeparator />
{draft.archivedAt ? (
<DropdownMenuItem onClick={() => actions.onArchive(draft, false)}>
@@ -232,6 +256,65 @@ 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. */
+function CmsStatusMark({ status }: { status: CmsStatus }) {
+ const t = useTranslations('contentEditor.library.cms');
+ const format = useFormatter();
+ const when = format.dateTime(new Date(status.at), { dateStyle: 'medium', timeStyle: 'short' });
+ const live = status.status === 'published' ? status.publishedUrl : null;
+ const label = t(status.status, { when });
+ const icon = {
+ queued: <Clock className="h-3.5 w-3.5" />,
+ sent: <Send className="h-3.5 w-3.5" />,
+ failed: <AlertTriangle className="h-3.5 w-3.5" />,
+ published: <ExternalLink className="h-3.5 w-3.5" />,
+ }[status.status];
+ const tone =
+ status.status === 'failed'
+ ? 'text-red-600 dark:text-red-400'
+ : 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}`;
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ delay={300}
+ closeDelay={0}
+ render={
+ // Published: the live page, a click away, in a new tab.
+ live ? (
+ <a
+ href={live}
+ target="_blank"
+ rel="noreferrer noopener"
+ className={className}
+ aria-label={t('openLive', { when })}
+ />
+ ) : (
+ <button type="button" className={className} aria-label={label} />
+ )
+ }
+ >
+ {icon}
+ </TooltipTrigger>
+ <TooltipContent className="max-w-72 space-y-1">
+ <p>{label}</p>
+ {live && <p className="opacity-80 [overflow-wrap:anywhere]">{live}</p>}
+ {status.status === 'failed' && (status.httpStatus || status.error) && (
+ <p className="opacity-80 [overflow-wrap:anywhere]">
+ {/* What the webhook answered when it refused the page; else the
+ reason (not reached, or the workflow's callback after a 2xx). */}
+ {status.httpStatus && (status.httpStatus < 200 || status.httpStatus > 299)
+ ? t('answered', { status: status.httpStatus })
+ : status.error}
+ </p>
+ )}
+ </TooltipContent>
+ </Tooltip>
+ );
+}
+
/** Who wrote it: the Content Agent, "You", or the member by name. */
function DraftAuthorCell({ draft }: { draft: ContentDraftListItem }) {
const t = useTranslations('contentEditor.library');
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx
index 0e331f52c..6eb4ebaea 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx
@@ -45,6 +45,11 @@ const toast = vi.hoisted(() => Object.assign(vi.fn(), { success: vi.fn(), error:
vi.mock('sonner', () => ({ toast }));
const saveBlob = vi.hoisted(() => vi.fn());
vi.mock('@/lib/download', () => ({ saveBlob }));
+const readCmsStatuses = vi.hoisted(() => vi.fn());
+const readDraftCms = vi.hoisted(() => vi.fn());
+const sendPagesToCms = vi.hoisted(() => vi.fn());
+vi.mock('@/lib/content/cms-send-client', () => ({ readCmsStatuses, readDraftCms, sendPagesToCms }));
+vi.mock('@/lib/actions/content-authors', () => ({ getContentAuthors: vi.fn(async () => null) }));
/** jsdom's Blob has no text(): read it as a browser's FileReader would. */
const readText = (blob: Blob) =>
@@ -132,6 +137,12 @@ beforeEach(() => {
rest: [],
}));
saveBlob.mockReset();
+ readCmsStatuses.mockReset().mockResolvedValue(new Map());
+ readDraftCms.mockReset().mockResolvedValue({ fields: {}, publishedUrl: null, last: null });
+ sendPagesToCms.mockReset().mockResolvedValue({
+ ok: true,
+ deliveries: [{ id: 'x1', draftId: 'd1', status: 'sent' }],
+ });
role.canManage = true;
});
@@ -325,6 +336,202 @@ describe('the Content Library', () => {
});
});
+describe('Send to CMS from a Library row (#1331)', () => {
+ const pick = async (title: string, item: string) => {
+ const trigger = container.querySelector<HTMLElement>(`[aria-label="Actions for ${title}"]`)!;
+ await act(async () => trigger.click());
+ const found = [...document.body.querySelectorAll<HTMLElement>('[role="menuitem"]')].find(
+ (el) => el.textContent === item,
+ )!;
+ await act(async () => found.click());
+ };
+ const dialog = () => document.querySelector('[role="dialog"]');
+ const inDialog = (name: string) =>
+ [...document.querySelectorAll<HTMLButtonElement>('[role="dialog"] button')].find(
+ (b) => b.textContent === name,
+ )!;
+
+ it('opens the Send dialog on the row’s page, and reads the sends again once it went', async () => {
+ getContentDrafts.mockResolvedValue([row({})]);
+ await renderPage();
+ expect(readCmsStatuses).toHaveBeenCalledWith(['d1']);
+ await pick('Pipeline forecasting', 'Send to CMS');
+ expect(getContentDraftPages).toHaveBeenCalledWith('brand-1', ['d1']);
+ expect(dialog()!.textContent).toContain('Send to CMS');
+ // The live page's own address part.
+ expect(document.querySelector<HTMLInputElement>('#cms-slug')!.value).toBe('pricing');
+
+ await act(async () => inDialog('Send').click());
+ expect(sendPagesToCms).toHaveBeenCalledWith('brand-1', [
+ expect.objectContaining({
+ draftId: 'd1',
+ slug: 'pricing',
+ html: '<p>Teams trust it.</p>',
+ // Authors come with Quality (CE-038): while it is off, none goes.
+ author: null,
+ }),
+ ]);
+ expect(dialog()).toBeNull();
+ expect(readCmsStatuses).toHaveBeenCalledTimes(2);
+ });
+
+ it('fills a placeholder in the editor', async () => {
+ getContentDrafts.mockResolvedValue([row({})]);
+ getContentDraftPages.mockResolvedValue({
+ pages: [
+ {
+ id: 'd1',
+ title: 'Pipeline forecasting',
+ bodyHtml: '<h1>Pipeline forecasting</h1><p>Teams save [figure] hours.</p>',
+ sourceUrl: null,
+ authorId: null,
+ language: null,
+ },
+ ],
+ rest: [],
+ });
+ await renderPage();
+ await pick('Pipeline forecasting', 'Send to CMS');
+ expect(inDialog('Send').disabled).toBe(true);
+ await act(async () => inDialog('Fill now').click());
+ expect(push).toHaveBeenCalledWith('/dashboard/content/editor/d1');
+ });
+
+ it('says when the page couldn’t be read', async () => {
+ getContentDrafts.mockResolvedValue([row({})]);
+ getContentDraftPages.mockResolvedValue({ pages: [], rest: [] });
+ vi.spyOn(console, 'error').mockImplementation(() => {});
+ await renderPage();
+ await pick('Pipeline forecasting', 'Send to CMS');
+ expect(toast.error).toHaveBeenCalledWith("Couldn't open the page to send. Try again.");
+ expect(dialog()).toBeNull();
+ });
+
+ it('shows each row’s last send beside its status', async () => {
+ getContentDrafts.mockResolvedValue([
+ row({}),
+ row({ id: 'd2', title: 'Churn guide', status: 'published' }),
+ row({ id: 'd3', title: 'Never sent' }),
+ ]);
+ readCmsStatuses.mockResolvedValue(
+ new Map([
+ [
+ 'd1',
+ {
+ status: 'failed',
+ at: '2026-10-24T10:00:00Z',
+ httpStatus: 500,
+ error: 'The webhook answered 500',
+ publishedUrl: null,
+ },
+ ],
+ [
+ 'd2',
+ {
+ status: 'published',
+ at: '2026-10-24T11:00:00Z',
+ httpStatus: 200,
+ error: null,
+ publishedUrl: 'https://acme.example/churn',
+ },
+ ],
+ ]),
+ );
+ await renderPage();
+ const marks = [
+ ...container.querySelectorAll<HTMLElement>(
+ '[aria-label^="The last send"], [aria-label^="Published"]',
+ ),
+ ];
+ expect(marks.map((el) => [el.tagName, el.getAttribute('aria-label')])).toEqual([
+ ['BUTTON', expect.stringMatching(/^The last send to your CMS failed, Oct 24, 2026/)],
+ ['A', expect.stringMatching(/^Published Oct 24, 2026/)],
+ ]);
+ expect(marks[1].getAttribute('href')).toBe('https://acme.example/churn');
+ });
+
+ it('says the workflow’s reason for a page its webhook took that then failed', async () => {
+ getContentDrafts.mockResolvedValue([row({})]);
+ readCmsStatuses.mockResolvedValue(
+ new Map([
+ [
+ 'd1',
+ {
+ status: 'failed',
+ at: '2026-10-24T10:00:00Z',
+ httpStatus: 200,
+ error: 'Slug already taken',
+ publishedUrl: null,
+ },
+ ],
+ ]),
+ );
+ await renderPage();
+ const mark = container.querySelector<HTMLElement>('[aria-label^="The last send"]')!;
+ await act(async () => {
+ mark.focus();
+ mark.dispatchEvent(new FocusEvent('focusin', { bubbles: true }));
+ });
+ await act(async () => new Promise((resolve) => setTimeout(resolve, 50)));
+ expect(document.body.textContent).toContain('Slug already taken');
+ expect(document.body.textContent).not.toContain('The webhook answered 200');
+ });
+
+ it('isn’t offered on an archived draft, which the server doesn’t send', async () => {
+ window.history.replaceState(null, '', '/dashboard/content/library?tab=archived');
+ getContentDrafts.mockResolvedValue([row({ archivedAt: '2026-10-21T08:00:00Z' })]);
+ await renderPage();
+ const trigger = container.querySelector<HTMLElement>(
+ '[aria-label="Actions for Pipeline forecasting"]',
+ )!;
+ await act(async () => trigger.click());
+ const items = [...document.body.querySelectorAll<HTMLElement>('[role="menuitem"]')];
+ expect(items.map((el) => el.textContent)).toContain('Restore');
+ expect(items.map((el) => el.textContent)).not.toContain('Send to CMS');
+ });
+
+ it('sends to the draft’s own brand, should the brand switch while its page is read', async () => {
+ getContentDrafts.mockResolvedValue([row({})]);
+ let answer: (read: unknown) => void = () => {};
+ getContentDraftPages.mockReturnValueOnce(new Promise((resolve) => (answer = resolve)));
+ await renderPage();
+ await pick('Pipeline forecasting', 'Send to CMS');
+ brandState.activeBrandId = 'brand-2';
+ await renderPage();
+ await act(async () =>
+ answer({
+ pages: [
+ {
+ id: 'd1',
+ title: 'Pipeline forecasting',
+ bodyHtml: '<h1>Pipeline forecasting</h1><p>Teams trust it.</p>',
+ sourceUrl: null,
+ authorId: null,
+ language: null,
+ },
+ ],
+ rest: [],
+ }),
+ );
+ await act(async () => inDialog('Send').click());
+ expect(sendPagesToCms).toHaveBeenCalledWith('brand-1', [
+ expect.objectContaining({ draftId: 'd1' }),
+ ]);
+ });
+
+ it('is for admins and managers only', async () => {
+ role.canManage = false;
+ getContentDrafts.mockResolvedValue([row({})]);
+ await renderPage();
+ const trigger = container.querySelector<HTMLElement>(
+ '[aria-label="Actions for Pipeline forecasting"]',
+ )!;
+ await act(async () => trigger.click());
+ const items = [...document.body.querySelectorAll<HTMLElement>('[role="menuitem"]')];
+ expect(items.map((el) => el.textContent)).not.toContain('Send to CMS');
+ });
+});
+
describe('a Library row’s menu (00233)', () => {
const menuItems = async (title: string) => {
const trigger = container.querySelector<HTMLElement>(`[aria-label="Actions for ${title}"]`)!;
@@ -348,6 +555,7 @@ describe('a Library row’s menu (00233)', () => {
'Export Word',
'Export HTML',
'Export Markdown',
+ 'Send to CMS',
'Send to Archive',
'Delete',
]);
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx
index 0712e7585..fc9b5d135 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx
@@ -24,18 +24,25 @@ import {
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { LoadingDots } from '@/components/ui/loading-dots';
import { NewContentDialog } from '@/components/content/new-content-dialog';
+import { SendDialog } from '@/components/content/send-to-cms-dialog';
import { useUserRole } from '@/hooks/use-user-role';
+import { useRouter } from '@/i18n/navigation';
+import { getContentAuthors } from '@/lib/actions/content-authors';
import {
archiveContentDraft,
deleteContentDraft,
+ getContentDraftPages,
getContentDrafts,
markContentDraftReady,
setContentDraftStatus,
} from '@/lib/actions/content-drafts';
+import { cmsSource, type CmsSource } from '@/lib/content/cms-send';
+import { readCmsStatuses, type CmsStatus } from '@/lib/content/cms-send-client';
import {
AGENT_POLL_MS,
CREATED_RANGES,
LIBRARY_TABS,
+ contentEditorPath,
draftsCreatedIn,
draftsInTab,
type ContentDraftListItem,
@@ -44,6 +51,7 @@ import {
type LibraryTab,
} from '@/lib/content/drafts';
import { siteTypeOf } from '@/lib/content/page-types';
+import { qualityPhase } from '@/lib/content/quality';
import { formatNumber } from '@/lib/format';
import { readUrlChoice, writeUrlParams } from '@/lib/url-state';
import { useBrandStore } from '@/stores/use-brand-store';
@@ -51,6 +59,41 @@ import { LibraryExportMenu, useLibraryExport } from './_library-export';
import { LibraryTable, type LibraryRowActions } from './_library-table';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
+/**
+ * A row's page for Send to CMS, made ready as the editor makes its own: its
+ * author and the brand's byline line once Quality is live. Null when the
+ * page is gone.
+ */
+async function readSendSource({
+ brandId,
+ draftId,
+ brandName,
+ brandLanguage,
+ teamByline,
+}: {
+ brandId: string;
+ draftId: string;
+ brandName: string;
+ brandLanguage: string | null | undefined;
+ teamByline: (brand: string) => string;
+}): Promise<CmsSource | null> {
+ const [{ pages }, authors] = await Promise.all([
+ getContentDraftPages(brandId, [draftId]),
+ qualityPhase() >= 1 ? getContentAuthors().catch(() => null) : Promise.resolve(null),
+ ]);
+ const page = pages[0];
+ if (!page) return null;
+ const name = authors?.brands.find((b) => b.id === brandId)?.name ?? brandName;
+ return cmsSource({
+ page,
+ authors,
+ brandId,
+ brandName: name,
+ brandLanguage,
+ teamByline: teamByline(name),
+ });
+}
+
/** A read of the brand's drafts: null until it comes back. */
interface LibraryRead {
brandId: string;
@@ -64,11 +107,13 @@ interface LibraryRead {
* The Content Library (Content Editor, CE-002): everything a person or the
* Content Agent wrote or changed in Ansvisor, by status, and what was
* archived (00233). A row's menu sets its status; admins and managers also
- * archive, restore and delete. The tab lives in the URL (?tab=in_review), so
- * a link can open "Library › In review".
+ * send it to the CMS (#1331), archive, restore and delete. The tab lives in
+ * the URL (?tab=in_review), so a link can open "Library › In review".
*/
export default function ContentLibraryPage() {
const t = useTranslations('contentEditor.library');
+ const tEditor = useTranslations('contentEditor.editor');
+ const router = useRouter();
const activeBrandId = useBrandStore((s) => s.activeBrandId);
const activeBrand = useBrandStore((s) => s.brands.find((b) => b.id === s.activeBrandId));
const [tab, setTab] = useState<LibraryTab>('all');
@@ -81,6 +126,11 @@ export default function ContentLibraryPage() {
// The draft whose Delete waits for a confirmation.
const [deleting, setDeleting] = useState<ContentDraftListItem | null>(null);
const [deletePending, setDeletePending] = useState(false);
+ // Send to CMS: while the row's page is read, then the dialog's page.
+ const [preparing, setPreparing] = useState(false);
+ const [sending, setSending] = useState<{ brandId: string; source: CmsSource } | null>(null);
+ // Each draft's last send, beside its status; read with the list.
+ const [cms, setCms] = useState<ReadonlyMap<string, CmsStatus>>(new Map());
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect -- one read of the URL after mount
@@ -116,6 +166,20 @@ export default function ContentLibraryPage() {
return () => clearTimeout(timer);
}, [agentWriting, read]);
+ // The sends of the drafts read, after each read of the list.
+ const readIds = read?.drafts?.map((draft) => draft.id).join(',') ?? '';
+ const [cmsAttempt, setCmsAttempt] = useState(0);
+ useEffect(() => {
+ if (!readIds) return;
+ let cancelled = false;
+ readCmsStatuses(readIds.split(','))
+ .then((statuses) => !cancelled && setCms(statuses))
+ .catch((err) => console.error('Failed to read the pages’ sends:', err));
+ return () => {
+ cancelled = true;
+ };
+ }, [readIds, cmsAttempt]);
+
const reload = () => setAttempt((n) => n + 1);
const titleOf = (draft: ContentDraftListItem) => draft.title.trim() || t('untitled');
const failed = (err: unknown) => {
@@ -145,6 +209,26 @@ export default function ContentLibraryPage() {
}
};
+ const openSend = async (draft: ContentDraftListItem) => {
+ if (!activeBrandId || preparing) return;
+ // The draft's brand stays the send's, should the brand switch meanwhile.
+ const brandId = activeBrandId;
+ setPreparing(true);
+ const source = await readSendSource({
+ brandId,
+ draftId: draft.id,
+ brandName: activeBrand?.name ?? '',
+ brandLanguage: activeBrand?.language,
+ teamByline: (brand) => tEditor('author.organization', { brand }),
+ }).catch((err) => {
+ console.error('Failed to read the page to send:', err);
+ return null;
+ });
+ setPreparing(false);
+ if (source) setSending({ brandId, source });
+ else toast.error(t('rowMenu.sendFailed'));
+ };
+
const rowActions: LibraryRowActions = {
canManage,
onStatus: (draft: ContentDraftListItem, status: DraftStatus) => {
@@ -158,6 +242,7 @@ export default function ContentLibraryPage() {
onArchive: (draft, archived) => void archive(draft, archived),
onDelete: setDeleting,
onExport: (draft, format) => void exportDraft(draft, format),
+ onSend: (draft) => void openSend(draft),
};
const confirmDelete = async () => {
@@ -285,10 +370,29 @@ export default function ContentLibraryPage() {
{t('created.empty')}
</p>
) : (
- <LibraryTable drafts={listed} tab={tab} actions={rowActions} />
+ <LibraryTable drafts={listed} tab={tab} actions={rowActions} cms={cms} />
)}
</CardContent>
</Card>
+ {sending && (
+ <SendDialog
+ draftId={sending.source.draftId}
+ brandId={sending.brandId}
+ title={sending.source.title}
+ html={sending.source.html}
+ sourceUrl={sending.source.sourceUrl}
+ author={sending.source.author}
+ teamByline={sending.source.teamByline}
+ byline={sending.source.byline}
+ // Placeholders are filled in the editor.
+ onFillNow={() => router.push(contentEditorPath(sending.source.draftId))}
+ // A send that went or failed is the row's last: its sends are read again.
+ onClose={() => {
+ setSending(null);
+ setCmsAttempt((n) => n + 1);
+ }}
+ />
+ )}
<Dialog open={deleting !== null} onOpenChange={(open) => !open && setDeleting(null)}>
<DialogContent className="grid-cols-[minmax(0,1fr)] sm:max-w-md">
<DialogHeader>
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_send-dialog.test.tsx b/web/src/components/content/send-to-cms-dialog.test.tsx
similarity index 98%
rename from web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_send-dialog.test.tsx
rename to web/src/components/content/send-to-cms-dialog.test.tsx
index 4dc023a57..018098463 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_send-dialog.test.tsx
+++ b/web/src/components/content/send-to-cms-dialog.test.tsx
@@ -2,7 +2,7 @@ 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 messages from '../../../messages/en.json';
import type { ContentAuthor } from '@/lib/content/authors';
import type { DraftCms } from '@/lib/content/cms-send-client';
@@ -12,7 +12,7 @@ const readDraftCms = vi.hoisted(() => vi.fn());
const sendPagesToCms = vi.hoisted(() => vi.fn());
vi.mock('@/lib/content/cms-send-client', () => ({ readDraftCms, sendPagesToCms }));
-const { SendDialog } = await import('./_send-dialog');
+const { SendDialog } = await import('./send-to-cms-dialog');
/**
* Send to CMS (#1331): the page to the brand's webhook, its slug and meta
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_send-dialog.tsx b/web/src/components/content/send-to-cms-dialog.tsx
similarity index 99%
rename from web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_send-dialog.tsx
rename to web/src/components/content/send-to-cms-dialog.tsx
index 9585af3c2..b575b2f9d 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_send-dialog.tsx
+++ b/web/src/components/content/send-to-cms-dialog.tsx
@@ -40,7 +40,8 @@ import { exportPlaceholders, pageFields, titlePlaceholders } from '@/lib/content
* CMS or automation to publish. Its slug and meta are filled from the page,
* or what the draft kept, and editable; they stay on the draft. The page
* goes as Export makes it ready (CE-057): no placeholder goes, so they are
- * filled first. Rendered only while open, on the page as it was then.
+ * filled first. From the editor's header and a Library row; rendered only
+ * while open, on the page as it was then.
*/
export function SendDialog({
draftId,
diff --git a/web/src/lib/actions/content-drafts-pages.test.ts b/web/src/lib/actions/content-drafts-pages.test.ts
index 3144c9c4b..624aa5d6a 100644
--- a/web/src/lib/actions/content-drafts-pages.test.ts
+++ b/web/src/lib/actions/content-drafts-pages.test.ts
@@ -43,6 +43,8 @@ const page = (n: number) => ({
title: `Draft ${n}`,
body_html: `<h1>Draft ${n}</h1>`,
source_url: null,
+ author_id: null,
+ rules: null,
});
beforeEach(() => {
@@ -60,10 +62,28 @@ describe('getContentDraftPages', () => {
title: 'Draft 3',
bodyHtml: '<h1>Draft 3</h1>',
sourceUrl: null,
+ authorId: null,
+ language: null,
});
expect(reads).toEqual([{ brand: BRAND, ids: [id(3), id(9), id(1)] }]);
});
+ it('gives the author and the language the draft’s own Language rule names', async () => {
+ const rules = (language: unknown) => ({ set: null, overrides: { language } });
+ stored = [
+ { ...page(1), author_id: id(7), rules: rules({ value: ' Turkish ' }) },
+ // Off, or on without a value of its own: the brand's language.
+ { ...page(2), rules: rules({ on: false, value: 'German' }) },
+ { ...page(3), rules: rules({ on: true }) },
+ ];
+ const { pages } = await getContentDraftPages(BRAND, [id(1), id(2), id(3)]);
+ expect(pages.map((p) => [p.authorId, p.language])).toEqual([
+ [id(7), 'Turkish'],
+ [null, null],
+ [null, null],
+ ]);
+ });
+
it('takes at most fifty ids a call, and only ids', async () => {
const fifty = Array.from({ length: 50 }, (_, i) => id(i + 1));
expect((await getContentDraftPages(BRAND, fifty)).pages).toHaveLength(3);
diff --git a/web/src/lib/actions/content-drafts.ts b/web/src/lib/actions/content-drafts.ts
index 273ddd08d..c78e71e76 100644
--- a/web/src/lib/actions/content-drafts.ts
+++ b/web/src/lib/actions/content-drafts.ts
@@ -257,6 +257,17 @@ export interface DraftPage {
title: string;
bodyHtml: string;
sourceUrl: string | null;
+ /** Who the page is by (CE-038), for Send to CMS. */
+ authorId: string | null;
+ /** The language the draft's own Language rule names, or null: the brand's. */
+ language: string | null;
+}
+
+/** The language a draft's own Language rule names, when it is on and set. */
+function draftLanguage(rules: unknown): string | null {
+ const language = draftRulesSchema.safeParse(rules).data?.overrides.language;
+ const value = language?.on === false ? '' : (language?.value?.trim() ?? '');
+ return value || null;
}
/**
@@ -288,14 +299,21 @@ export async function getContentDraftPages(
const supabase = await createClient();
const { data, error } = await supabase
.from('content_drafts')
- .select('id, title, body_html, source_url')
+ .select('id, title, body_html, source_url, author_id, rules')
.eq('brand_id', brandId)
.in('id', parsed.data);
if (error) throw new Error(error.message);
const byId = new Map<string, DraftPage>(
(data ?? []).map((row) => [
row.id,
- { id: row.id, title: row.title, bodyHtml: row.body_html, sourceUrl: row.source_url },
+ {
+ id: row.id,
+ title: row.title,
+ bodyHtml: row.body_html,
+ sourceUrl: row.source_url,
+ authorId: row.author_id,
+ language: draftLanguage(row.rules),
+ },
]),
);
const pages: DraftPage[] = [];
diff --git a/web/src/lib/content/cms-send-client.test.ts b/web/src/lib/content/cms-send-client.test.ts
index dca048e89..a3108e46e 100644
--- a/web/src/lib/content/cms-send-client.test.ts
+++ b/web/src/lib/content/cms-send-client.test.ts
@@ -10,11 +10,20 @@ import type { CmsPage } from './cms-send';
let session: { access_token: string } | null;
let reads: Record<string, { data: unknown; error: unknown }>;
const filters: [string, string, unknown][] = [];
+/** Each draft's last send, read by draft ids: each read's answer, in turn. */
+let statusReads: { data: unknown; error: unknown }[];
+const statusIds: string[][] = [];
+const rpcs: string[] = [];
vi.mock('@/config/api', () => ({ BROWSER_API_BASE_URL: '/api/aeo' }));
vi.mock('@/lib/supabase/client', () => ({
createClient: () => ({
auth: { getSession: async () => ({ data: { session } }) },
+ rpc: async (fn: string, args: { p_draft_ids: string[] }) => {
+ rpcs.push(fn);
+ statusIds.push(args.p_draft_ids);
+ return statusReads.shift();
+ },
from: (table: string) => {
const chain: Record<string, unknown> = {
select: () => chain,
@@ -28,7 +37,7 @@ vi.mock('@/lib/supabase/client', () => ({
}),
}));
-const { readDraftCms, sendPagesToCms } = await import('./cms-send-client');
+const { readCmsStatuses, readDraftCms, sendPagesToCms } = await import('./cms-send-client');
const page: CmsPage = {
draftId: 'd1',
@@ -47,6 +56,9 @@ const answer = (status: number, body: unknown) =>
beforeEach(() => {
session = { access_token: 'token-1' };
filters.length = 0;
+ statusIds.length = 0;
+ rpcs.length = 0;
+ statusReads = [];
fetchMock.mockReset();
vi.stubGlobal('fetch', fetchMock);
vi.spyOn(console, 'error').mockImplementation(() => {});
@@ -151,6 +163,29 @@ describe('readDraftCms', () => {
]);
});
+ it('reads a send left queued for over 30 minutes as interrupted, as the Library does', async () => {
+ reads = {
+ content_drafts: {
+ data: { slug: null, meta_title: null, meta_description: null, published_url: null },
+ error: null,
+ },
+ content_draft_deliveries: {
+ data: {
+ status: 'queued',
+ created_at: new Date(Date.now() - 31 * 60_000).toISOString(),
+ sent_at: null,
+ published_at: null,
+ error: null,
+ },
+ error: null,
+ },
+ };
+ expect((await readDraftCms('d1'))?.last).toMatchObject({
+ status: 'failed',
+ error: 'Not sent: interrupted',
+ });
+ });
+
it('gives no last send when its read fails, and null when the draft’s does', async () => {
reads = {
content_drafts: {
@@ -160,8 +195,89 @@ describe('readDraftCms', () => {
content_draft_deliveries: { data: null, error: { message: 'no such table' } },
};
expect((await readDraftCms('d1'))?.last).toBeNull();
- // Before its columns are there (00262), the dialog fills the fields from the page.
+ // Before its columns are there (00262): null, and the dialog holds Send.
reads.content_drafts = { data: null, error: { message: 'column "slug" does not exist' } };
expect(await readDraftCms('d1')).toBeNull();
});
});
+
+describe('readCmsStatuses', () => {
+ const delivery = (draft: string, status: string, at: string, over = {}) => ({
+ draft_id: draft,
+ status,
+ created_at: at,
+ sent_at: null,
+ published_at: null,
+ http_status: null,
+ error: null,
+ published_url: null,
+ ...over,
+ });
+
+ it('gives each draft its last send, one row a draft, five hundred drafts a read', async () => {
+ const ids = Array.from({ length: 600 }, (_, i) => `d${i}`);
+ statusReads = [
+ {
+ data: [
+ delivery('d1', 'published', '2026-10-24T10:00:00Z', {
+ sent_at: '2026-10-24T10:00:02Z',
+ published_at: '2026-10-24T12:00:00Z',
+ http_status: 200,
+ published_url: 'https://example.com/coffee',
+ }),
+ delivery(null as unknown as string, 'sent', '2026-10-22T10:00:00Z'),
+ ],
+ error: null,
+ },
+ {
+ data: [delivery('d520', 'failed', '2026-10-24T09:00:00Z', { error: 'Not reached' })],
+ error: null,
+ },
+ ];
+ const statuses = await readCmsStatuses(ids);
+ expect(rpcs).toEqual(['content_draft_last_deliveries', 'content_draft_last_deliveries']);
+ expect(statusIds.map((chunk) => chunk.length)).toEqual([500, 100]);
+ expect([...statuses.entries()]).toEqual([
+ [
+ 'd1',
+ {
+ status: 'published',
+ at: '2026-10-24T12:00:00Z',
+ httpStatus: 200,
+ error: null,
+ publishedUrl: 'https://example.com/coffee',
+ },
+ ],
+ [
+ 'd520',
+ {
+ status: 'failed',
+ at: '2026-10-24T09:00:00Z',
+ httpStatus: null,
+ error: 'Not reached',
+ publishedUrl: null,
+ },
+ ],
+ ]);
+ });
+
+ it('reads a send queued for over 30 minutes as interrupted, a newer one as going', async () => {
+ const ago = (minutes: number) => new Date(Date.now() - minutes * 60_000).toISOString();
+ statusReads = [
+ {
+ data: [delivery('d1', 'queued', ago(31)), delivery('d2', 'queued', ago(2))],
+ error: null,
+ },
+ ];
+ const statuses = await readCmsStatuses(['d1', 'd2']);
+ expect(statuses.get('d1')).toMatchObject({ status: 'failed', error: 'Not sent: interrupted' });
+ expect(statuses.get('d2')).toMatchObject({ status: 'queued', error: null });
+ });
+
+ it('leaves a read that fails with no sends, as before its table is there', async () => {
+ statusReads = [{ data: null, error: { message: 'relation does not exist' } }];
+ expect((await readCmsStatuses(['d1'])).size).toBe(0);
+ expect((await readCmsStatuses([])).size).toBe(0);
+ expect(statusIds).toHaveLength(1);
+ });
+});
diff --git a/web/src/lib/content/cms-send-client.ts b/web/src/lib/content/cms-send-client.ts
index 95d8520fe..6ca54b626 100644
--- a/web/src/lib/content/cms-send-client.ts
+++ b/web/src/lib/content/cms-send-client.ts
@@ -83,6 +83,77 @@ export async function sendPagesToCms(brandId: string, pages: CmsPage[]): Promise
}
}
+/** A draft's last send, as the Library shows it beside its status. */
+export interface CmsStatus {
+ status: CmsDelivery['status'];
+ /** When it was published, sent or queued. */
+ at: string;
+ /** What the webhook answered, when it did; else why it wasn't reached. */
+ httpStatus: number | null;
+ error: string | null;
+ publishedUrl: string | null;
+}
+
+/** Ids a read takes: content_draft_last_deliveries (00262) reads up to 500. */
+const STATUS_IDS_PER_READ = 500;
+/**
+ * A send still queued after this was left by a server that stopped mid-batch
+ * (00262 closes it at the workspace's next send): it reads as interrupted,
+ * so neither the Library nor the editor waits on it or says it is still
+ * going. Read by the browser's clock: one 30 minutes fast would read a send
+ * under way as interrupted, until its next read.
+ */
+const INTERRUPTED_AFTER_MS = 30 * 60_000;
+
+/** A send as the Library and the editor read it: one left queued, as interrupted. */
+function lastSend(row: {
+ status: string;
+ created_at: string;
+ sent_at: string | null;
+ published_at: string | null;
+ error: string | null;
+}): { status: CmsDelivery['status']; at: string; error: string | null } {
+ const interrupted =
+ row.status === 'queued' && Date.parse(row.created_at) < Date.now() - INTERRUPTED_AFTER_MS;
+ return {
+ status: interrupted ? 'failed' : (row.status as CmsDelivery['status']),
+ at: row.published_at ?? row.sent_at ?? row.created_at,
+ error: interrupted ? 'Not sent: interrupted' : row.error,
+ };
+}
+
+/**
+ * Each draft's last send, for the Library's rows: one row a draft, however
+ * often it was sent. A read that fails (its function not there yet, 00262)
+ * leaves its drafts with none.
+ */
+export async function readCmsStatuses(draftIds: string[]): Promise<Map<string, CmsStatus>> {
+ const supabase = createClient();
+ const chunks: string[][] = [];
+ for (let i = 0; i < draftIds.length; i += STATUS_IDS_PER_READ) {
+ chunks.push(draftIds.slice(i, i + STATUS_IDS_PER_READ));
+ }
+ const reads = await Promise.all(
+ chunks.map((ids) => supabase.rpc('content_draft_last_deliveries', { p_draft_ids: ids })),
+ );
+ const statuses = new Map<string, CmsStatus>();
+ for (const { data, error } of reads) {
+ if (error) {
+ console.error('Failed to read the pages’ sends:', error);
+ continue;
+ }
+ for (const row of data ?? []) {
+ if (!row.draft_id) continue;
+ statuses.set(row.draft_id, {
+ ...lastSend(row),
+ httpStatus: row.http_status,
+ publishedUrl: row.published_url,
+ });
+ }
+ }
+ return statuses;
+}
+
/** What a draft keeps of its sends: its slug and meta, where it went live, and its last send. */
export interface DraftCms {
fields: Partial<CmsFields>;
@@ -105,7 +176,7 @@ export async function readDraftCms(draftId: string): Promise<DraftCms | null> {
.maybeSingle(),
supabase
.from('content_draft_deliveries')
- .select('status, created_at, sent_at, error')
+ .select('status, created_at, sent_at, published_at, error')
.eq('draft_id', draftId)
.order('created_at', { ascending: false })
.limit(1)
@@ -123,12 +194,6 @@ export async function readDraftCms(draftId: string): Promise<DraftCms | null> {
metaDescription: draft.data.meta_description ?? undefined,
},
publishedUrl: draft.data.published_url,
- last: delivery
- ? {
- status: delivery.status as CmsDelivery['status'],
- at: delivery.sent_at ?? delivery.created_at,
- error: delivery.error,
- }
- : null,
+ last: delivery ? lastSend(delivery) : null,
};
}
diff --git a/web/src/lib/content/cms-send.test.ts b/web/src/lib/content/cms-send.test.ts
index 6211a8808..ba41f781c 100644
--- a/web/src/lib/content/cms-send.test.ts
+++ b/web/src/lib/content/cms-send.test.ts
@@ -1,5 +1,14 @@
import { describe, expect, it } from 'vitest';
-import { cmsFields, cmsFieldsProblem, cmsPage, cmsPageProblem, type CmsFields } from './cms-send';
+import type { DraftPage } from '@/lib/actions/content-drafts';
+import type { AuthorsRead, ContentAuthor } from './authors';
+import {
+ cmsFields,
+ cmsFieldsProblem,
+ cmsPage,
+ cmsPageProblem,
+ cmsSource,
+ type CmsFields,
+} from './cms-send';
import type { PageFields } from './ready-to-publish';
/**
@@ -156,3 +165,57 @@ describe('cmsPage', () => {
).toBeNull();
});
});
+
+describe('cmsSource', () => {
+ const stored: DraftPage = {
+ id: 'd1',
+ title: 'Pour-over',
+ bodyHtml: '<h1>Pour-over</h1><p>Brew it slowly.</p>',
+ sourceUrl: 'https://acme.example/pour-over',
+ authorId: 'a1',
+ language: null,
+ };
+ const ada = { id: 'a1', name: 'Ada Lovelace' } as ContentAuthor;
+ const authors = (bylineInContent: boolean): AuthorsRead => ({
+ authors: [ada],
+ brands: [{ id: 'b1', name: 'Acme', bylineInContent }],
+ me: { id: 'u1', role: 'admin' },
+ });
+ const source = (over: Partial<Parameters<typeof cmsSource>[0]> = {}) =>
+ cmsSource({
+ page: stored,
+ authors: authors(false),
+ brandId: 'b1',
+ brandName: 'Acme',
+ brandLanguage: 'en',
+ teamByline: 'Acme Team',
+ ...over,
+ });
+
+ it('gives the stored page as the editor would: publishable, with its author', () => {
+ expect(source()).toEqual({
+ draftId: 'd1',
+ title: 'Pour-over',
+ html: expect.stringContaining('<p>Brew it slowly.</p>'),
+ sourceUrl: 'https://acme.example/pour-over',
+ author: ada,
+ teamByline: 'Acme Team',
+ byline: null,
+ });
+ });
+
+ it('adds the byline line in the page’s language, else the brand’s', () => {
+ expect(source({ authors: authors(true) }).byline).toBe('By Ada Lovelace');
+ expect(source({ authors: authors(true), brandLanguage: 'tr' }).byline).toBe(
+ 'Yazar: Ada Lovelace',
+ );
+ expect(
+ source({ authors: authors(true), page: { ...stored, language: 'German', authorId: null } })
+ .byline,
+ ).toBe('Vom Acme-Team');
+ });
+
+ it('gives no author or team byline while Quality is off', () => {
+ expect(source({ authors: null })).toMatchObject({ author: null, teamByline: '', byline: null });
+ });
+});
diff --git a/web/src/lib/content/cms-send.ts b/web/src/lib/content/cms-send.ts
index b2309cf3d..a4bbc01ef 100644
--- a/web/src/lib/content/cms-send.ts
+++ b/web/src/lib/content/cms-send.ts
@@ -1,4 +1,8 @@
+import type { DraftPage } from '@/lib/actions/content-drafts';
+import type { AuthorsRead, ContentAuthor } from '@/lib/content/authors';
+import { publishableHtml } from '@/lib/content/clean-html';
import {
+ bylineText,
fragment,
withByline,
withoutLeadingH1,
@@ -101,6 +105,57 @@ export function cmsPageProblem(
return null;
}
+/** A stored page as the Send dialog takes it, as the editor would give it. */
+export interface CmsSource {
+ draftId: string;
+ title: string;
+ /** publishableHtml's, as Copy HTML gives it. */
+ html: string;
+ sourceUrl: string | null;
+ author: ContentAuthor | null;
+ /** The team byline; empty while the authors aren't read. */
+ teamByline: string;
+ /** The byline line the brand puts in the content, or null. */
+ byline: string | null;
+}
+
+/**
+ * A Library row's page for Send to CMS, as the editor gives its own: the
+ * stored page made publishable, its author and the brand's byline line in
+ * the page's language (its own Language rule, else the brand's; a
+ * workspace's My rules for the type aren't read here). `authors` is null
+ * while Quality is off, as the editor reads none then.
+ */
+export function cmsSource({
+ page,
+ authors,
+ brandId,
+ brandName,
+ brandLanguage,
+ teamByline,
+}: {
+ page: DraftPage;
+ authors: AuthorsRead | null;
+ brandId: string;
+ brandName: string;
+ brandLanguage: string | null | undefined;
+ teamByline: string;
+}): CmsSource {
+ const author = authors?.authors.find((a) => a.id === page.authorId) ?? null;
+ const inContent = authors?.brands.find((b) => b.id === brandId)?.bylineInContent ?? false;
+ return {
+ draftId: page.id,
+ title: page.title,
+ html: publishableHtml(page.bodyHtml),
+ sourceUrl: page.sourceUrl,
+ author,
+ teamByline: authors ? teamByline : '',
+ byline: inContent
+ ? bylineText(page.language ?? brandLanguage, author?.name ?? null, brandName)
+ : null,
+ };
+}
+
/** The image's alt text, where the page shows it. */
function altOf(html: string, src: string): string {
const image = [...fragment(html).querySelectorAll('img')].find(
diff --git a/web/src/types/supabase.ts b/web/src/types/supabase.ts
index 3634fb5d3..915604375 100644
--- a/web/src/types/supabase.ts
+++ b/web/src/types/supabase.ts
@@ -4278,6 +4278,34 @@ export type Database = {
Args: { p_ids: string[]; p_status: string }
Returns: number
}
+ content_draft_last_deliveries: {
+ Args: { p_draft_ids: string[] }
+ Returns: {
+ batch_id: string | null
+ brand_id: string
+ created_at: string
+ draft_id: string | null
+ error: string | null
+ external_id: string | null
+ http_status: number | null
+ id: string
+ organization_id: string
+ published_at: string | null
+ published_url: string | null
+ response_excerpt: string | null
+ sent_at: string | null
+ sent_by: string | null
+ slug: string | null
+ status: string
+ title: string
+ }[]
+ SetofOptions: {
+ from: "*"
+ to: "content_draft_deliveries"
+ isOneToOne: false
+ isSetofReturn: true
+ }
+ }
content_draft_member: { Args: { p_draft_id: string }; Returns: boolean }
content_draft_restore: { Args: { p_version_id: string }; Returns: Json }
content_draft_snapshot: {