Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(content): go straight to Send when Before you publish has nothing to ask, and fold the JSON-LD away (#1622)

Cihanb7cffa4cde5b
diff --git a/docs/guides/send-to-cms.mdx b/docs/guides/send-to-cms.mdx
index 9c0b7728a..9e56a6ea8 100644
--- a/docs/guides/send-to-cms.mdx
+++ b/docs/guides/send-to-cms.mdx
@@ -48,7 +48,7 @@ Once the brand's Webflow collection is ready, the Send dialog offers **Webflow**
## Send one page
-- **From the editor:** click the paper-plane icon in the header. If **Before you publish** opens first, check it and click **Continue to send**.
+- **From the editor:** click the paper-plane icon in the header. **Before you publish** opens first only when it has something to ask about: Trust under 60, something missing (an author, placeholders, alt text, broken links) or checks still being read. Check it and click **Continue to send**. Its JSON-LD is folded away here; **Show the JSON-LD** opens it for a CMS that doesn't add one.
- **From the Library:** open a row's **…** menu and pick **Send to CMS**.
The dialog fills the fields from the page, and you can change them before sending:
diff --git a/web/messages/en.json b/web/messages/en.json
index 888a6e869..53c0c90ca 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -5094,6 +5094,7 @@
},
"jsonLd": "JSON-LD for this page",
"copy": "Copy JSON-LD",
+ "showCode": "Show the JSON-LD, for a CMS that doesn't add it",
"copied": "JSON-LD copied",
"copyFailed": "Couldn't copy the JSON-LD. Select it and copy it yourself.",
"fixFirst": "Fix first",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsx
index 6afd18ef4..4cb45eb44 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsx
@@ -1,4 +1,4 @@
-import { act } from 'react';
+import { act, Fragment, StrictMode } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { NextIntlClientProvider } from 'next-intl';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -107,35 +107,39 @@ async function render(
disclosureAdded = false,
product = null as Parameters<typeof BeforePublish>[0]['product'],
category = null as Parameters<typeof BeforePublish>[0]['category'],
+ strict = false,
shopping = null as Parameters<typeof BeforePublish>[0]['shopping'],
} = {},
) {
+ const Wrap = strict ? StrictMode : Fragment;
await act(async () => {
root.render(
- <NextIntlClientProvider locale="en" messages={messages}>
- <BeforePublish
- mode={mode}
- paste={paste}
- onFillNow={onFillNow}
- contentByline={contentByline}
- onContinue={onContinue}
- onClose={() => {}}
- quality={q}
- title={title}
- isNew={isNew}
- pageType={pageType}
- image={image}
- linksPending={linksPending}
- product={product}
- category={category}
- shopping={shopping}
- onMarkReady={onMarkReady}
- onFixFirst={onFixFirst}
- disclosureLine={disclosureLine}
- disclosureAdded={disclosureAdded}
- onAddDisclosure={onAddDisclosure}
- />
- </NextIntlClientProvider>,
+ <Wrap>
+ <NextIntlClientProvider locale="en" messages={messages}>
+ <BeforePublish
+ mode={mode}
+ paste={paste}
+ onFillNow={onFillNow}
+ contentByline={contentByline}
+ onContinue={onContinue}
+ onClose={() => {}}
+ quality={q}
+ title={title}
+ isNew={isNew}
+ pageType={pageType}
+ image={image}
+ linksPending={linksPending}
+ product={product}
+ category={category}
+ shopping={shopping}
+ onMarkReady={onMarkReady}
+ onFixFirst={onFixFirst}
+ disclosureLine={disclosureLine}
+ disclosureAdded={disclosureAdded}
+ onAddDisclosure={onAddDisclosure}
+ />
+ </NextIntlClientProvider>
+ </Wrap>,
);
});
}
@@ -622,6 +626,107 @@ describe('BeforePublish', () => {
expect(onMarkReady).not.toHaveBeenCalled();
});
+ it('folds the code away on Send to CMS, and shows it on a click', async () => {
+ await render(quality(), { mode: 'send' });
+ expect(dialog().querySelector('pre')).toBeNull();
+ // Copy JSON-LD is still there, for a CMS that doesn't add it.
+ expect(button('Copy JSON-LD')).toBeDefined();
+ await act(async () => button("Show the JSON-LD, for a CMS that doesn't add it")!.click());
+ expect(jsonLd()['@type']).toBe('Article');
+ // Export and Mark ready show it as before.
+ await render(quality(), { mode: 'export' });
+ expect(dialog().querySelector('pre')).not.toBeNull();
+ });
+
+ it('opens and folds the code with one button, its focus on the code it opens', async () => {
+ await render(quality(), { mode: 'send' });
+ const show = button("Show the JSON-LD, for a CMS that doesn't add it")!;
+ expect(show.getAttribute('aria-expanded')).toBe('false');
+ await act(async () => show.click());
+ expect(show.getAttribute('aria-expanded')).toBe('true');
+ const code = dialog().querySelector('pre')!;
+ expect(show.getAttribute('aria-controls')).toBe(code.id);
+ expect(document.activeElement).toBe(code);
+ await act(async () => show.click());
+ expect(show.getAttribute('aria-expanded')).toBe('false');
+ expect(dialog().querySelector('pre')).toBeNull();
+ // Export shows its code with no button to fold it.
+ await render(quality(), { mode: 'export' });
+ expect(dialog().querySelector('[aria-expanded]')).toBeNull();
+ });
+
+ it('says the headline is left out with the code folded too', async () => {
+ await render(quality(), { mode: 'send', title: 'How [name of a real person] forecasts' });
+ expect(dialog().querySelector('pre')).toBeNull();
+ expect(dialog().textContent).toContain(
+ 'The title still has a placeholder in square brackets, so the code leaves the headline out.',
+ );
+ });
+
+ it('goes straight on to the Send dialog when there is nothing to ask about', async () => {
+ const fine = quality({ trust: trustRead({ score: 90 }) });
+ await render(fine, { mode: 'send' });
+ expect(onContinue).toHaveBeenCalledOnce();
+ expect(document.querySelector('[role="dialog"]')).toBeNull();
+ // Trust read with no score: no figure or dated source to score, nothing to ask.
+ await act(async () => root.unmount());
+ root = createRoot(container);
+ await render(quality({ trust: trustRead({ score: null }) }), { mode: 'send' });
+ expect(onContinue).toHaveBeenCalledTimes(2);
+ expect(document.querySelector('[role="dialog"]')).toBeNull();
+ });
+
+ it('goes on to the Send dialog once in StrictMode, which runs an effect twice', async () => {
+ await render(quality({ trust: trustRead({ score: 90 }) }), { mode: 'send', strict: true });
+ expect(onContinue).toHaveBeenCalledOnce();
+ expect(document.querySelector('[role="dialog"]')).toBeNull();
+ });
+
+ it('asks on Send to CMS while Trust, the authors, a category’s products or the shopping links aren’t read yet', async () => {
+ const again = async () => {
+ await act(async () => root.unmount());
+ root = createRoot(container);
+ };
+ // Trust not read yet.
+ await render(quality({ trust: null }), { mode: 'send' });
+ expect(button('Continue to send')).toBeDefined();
+ await again();
+ // The authors not read yet.
+ await render(quality({ trust: trustRead({ score: 90 }), eeat: null }), { mode: 'send' });
+ expect(button('Continue to send')).toBeDefined();
+ await again();
+ // A category page whose products are still being read.
+ await render(quality({ trust: trustRead({ score: 90 }) }), {
+ mode: 'send',
+ pageType: 'category_page',
+ category: { items: [], status: 'reading' },
+ });
+ expect(button('Continue to send')).toBeDefined();
+ await again();
+ // The page's shopping links still being read against the catalog.
+ await render(quality({ trust: trustRead({ score: 90 }) }), {
+ mode: 'send',
+ shopping: 'reading',
+ });
+ expect(button('Continue to send')).toBeDefined();
+ expect(onContinue).not.toHaveBeenCalled();
+ });
+
+ it('asks on Send to CMS when something is missing, its links still being read, or Trust is under 60', async () => {
+ const fine = { trust: trustRead({ score: 90 }) };
+ await render(quality({ ...fine, author: null }), { mode: 'send' });
+ expect(button('Continue to send')).toBeDefined();
+ await act(async () => root.unmount());
+ root = createRoot(container);
+ await render(quality(fine), { mode: 'send', linksPending: 2 });
+ expect(button('Continue to send')).toBeDefined();
+ await act(async () => root.unmount());
+ root = createRoot(container);
+ await render(quality(fine), { mode: 'send', paste: { ...clean, placeholders: 1 } });
+ expect(button('Continue to send')).toBeDefined();
+ expect(onContinue).not.toHaveBeenCalled();
+ });
+
it('goes to what would raise Trust from Export too', async () => {
await render(quality(), { mode: 'export' });
await act(async () => button('Fix first')!.click());
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.tsx
index 109c109a1..d4c3d035e 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.tsx
@@ -1,8 +1,8 @@
'use client';
-import { useRef, useState } from 'react';
+import { useEffect, useId, useRef, useState } from 'react';
import { useTranslations } from 'next-intl';
-import { AlertTriangle, Check } from 'lucide-react';
+import { AlertTriangle, Check, ChevronDown } from 'lucide-react';
import { Button } from '@/components/ui/button';
import {
Dialog,
@@ -72,6 +72,11 @@ export interface ReadyToPaste {
* write one, from the page's facts only. Mark ready anyway is logged with
* the Trust the page had; on Export it goes on to Export, and on Send to CMS
* to the Send dialog (#1331). Rendered only while open.
+ *
+ * On Send to CMS, a page with nothing to ask about (Trust read and 60 or
+ * more, the authors and a category's products read, nothing missing,
+ * nothing still being read) goes straight on to the Send dialog, and the
+ * code, for a CMS that doesn't write it, is folded away.
*/
/** The below-60 warning, as each way on says what it does. */
const WARNING = { markReady: 'warning', export: 'warningExport', send: 'warningSend' } as const;
@@ -364,6 +369,44 @@ export function BeforePublish({
...(shopping ? [shoppingRow(t, shopping)] : []),
{ ...readyRow(t, paste, linksPending), fill: paste.placeholders > 0 },
];
+ // Nothing to ask about as Send opens it: straight on to the Send dialog.
+ // Only once all is read: Trust, the authors, a category's products and the
+ // shopping links not read yet may still have something to ask. A Trust
+ // read with no score has nothing to score (no figure, no dated source):
+ // nothing to ask.
+ const [skipped] = useState(
+ () =>
+ mode === 'send' &&
+ quality.trust !== null &&
+ !below &&
+ authorsRead &&
+ category?.status !== 'reading' &&
+ shopping !== 'reading' &&
+ rows.every((row) => row.state !== 'missing') &&
+ linksPending === 0 &&
+ !quality.claimsReading &&
+ !quality.pageReading,
+ );
+ // Once, as it opens: StrictMode runs an effect twice, and the Send dialog opens once.
+ const continued = useRef(false);
+ useEffect(() => {
+ if (!skipped || continued.current) return;
+ continued.current = true;
+ onContinue?.();
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- once, as it opens
+ }, [skipped]);
+ // The page goes to the CMS: the code is only for one that doesn't write it.
+ const [codeShown, setCodeShown] = useState(mode !== 'send');
+ const codeId = useId();
+ const codeRef = useRef<HTMLPreElement>(null);
+ // Show the JSON-LD takes the focus to the code it opens.
+ const focusCode = useRef(false);
+ useEffect(() => {
+ if (!codeShown || !focusCode.current) return;
+ focusCode.current = false;
+ codeRef.current?.focus();
+ }, [codeShown]);
+ if (skipped) return null;
return (
<Dialog open onOpenChange={(open) => !open && onClose()}>
@@ -478,21 +521,46 @@ export function BeforePublish({
</ul>
{jsonLd && (
<div className="space-y-1.5">
- <pre
- aria-label={t('jsonLd')}
- tabIndex={0}
- className="max-h-48 overflow-auto rounded-xl border bg-muted/40 px-3 py-2.5 font-mono text-[11.5px] leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]"
- >
- {jsonLd}
- </pre>
+ {mode === 'send' && (
+ <button
+ type="button"
+ aria-expanded={codeShown}
+ aria-controls={codeShown ? codeId : undefined}
+ className="inline-flex items-center gap-1 text-xs font-medium text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
+ onClick={() => {
+ focusCode.current = !codeShown;
+ setCodeShown(!codeShown);
+ }}
+ >
+ <ChevronDown
+ aria-hidden
+ className={cn('h-3.5 w-3.5 transition-transform', !codeShown && '-rotate-90')}
+ />
+ {t('showCode')}
+ </button>
+ )}
+ {codeShown && (
+ <pre
+ id={codeId}
+ ref={codeRef}
+ aria-label={t('jsonLd')}
+ tabIndex={0}
+ className="max-h-48 overflow-auto rounded-xl border bg-muted/40 px-3 py-2.5 font-mono text-[11.5px] leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]"
+ >
+ {jsonLd}
+ </pre>
+ )}
+ {/* Said folded too: the code that goes, or is copied, leaves it out. */}
{(article || itemListLd) && titleHasPlaceholder(title) && (
<p className="text-xs text-amber-700 dark:text-amber-300">
{t(itemListLd ? 'nameLeftOut' : 'headlineLeftOut')}
</p>
)}
- <p className="text-xs text-muted-foreground">
- {t(productLd ? 'productNote' : itemListLd ? 'itemListNote' : 'datesNote')}
- </p>
+ {codeShown && (
+ <p className="text-xs text-muted-foreground">
+ {t(productLd ? 'productNote' : itemListLd ? 'itemListNote' : 'datesNote')}
+ </p>
+ )}
</div>
)}
<DialogFooter className="gap-2 sm:justify-between">
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 70e0afe0c..5adbe4bd8 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
@@ -5923,9 +5923,22 @@ describe('the side panel', () => {
getContentDraft.mockResolvedValue(
draft({ pageType: 'blog_post', authorConfirmed: { real: true, profile: false } }),
);
+ // Trust reads once the brand's domains are in: until then Before you publish asks.
+ getDraftSources.mockResolvedValue({
+ data: {
+ prompts: [],
+ fanouts: [],
+ citedPages: [],
+ gscQueries: [],
+ brandDomains: ['acme.com'],
+ competitorDomains: [],
+ },
+ choices: [],
+ });
await renderPage();
await act(async () => button('Send to CMS')!.click());
- await act(async () => inDialog('Continue to send').click());
+ // Nothing for Before you publish to ask about: straight to the Send dialog.
+ expect(dialog()!.textContent).toContain('Meta description');
await act(async () => inDialog('Send').click());
// The CMS keeps its own author.
expect(sendPagesToCms).toHaveBeenCalledWith(