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): keep New content's choices still while its Overview lands, and stay on it until the agent's editor opens (#1621)

Cihaned34f0c26f57
diff --git a/web/src/components/content/new-content-dialog.test.tsx b/web/src/components/content/new-content-dialog.test.tsx
index a6aec0563..8562e6220 100644
--- a/web/src/components/content/new-content-dialog.test.tsx
+++ b/web/src/components/content/new-content-dialog.test.tsx
@@ -129,6 +129,7 @@ const OPTIONS = {
let container: HTMLDivElement;
let root: Root;
+const onOpenChange = vi.fn();
async function render(siteType: SiteType = 'b2b', preset: DialogPreset | null = null) {
await act(async () => {
@@ -136,7 +137,7 @@ async function render(siteType: SiteType = 'b2b', preset: DialogPreset | null =
<NextIntlClientProvider locale="en" messages={messages}>
<NewContentDialog
open
- onOpenChange={vi.fn()}
+ onOpenChange={onOpenChange}
brandId="b1"
siteType={siteType}
onSent={onSent}
@@ -181,6 +182,7 @@ beforeEach(() => {
startAgentWriting.mockReset();
agentWriteRequest.mockReset().mockResolvedValue({ sources: 'kept', rules: [] });
onSent.mockReset();
+ onOpenChange.mockReset();
toast.warning.mockReset();
push.mockReset();
toast.error.mockReset();
@@ -229,9 +231,13 @@ describe('New content', () => {
await render();
// A single column no wider than the dialog: content can't widen it. No
// taller than the window either: it scrolls, its buttons kept in view.
+ // Held at the top: what lands later grows it downwards.
const dialog = document.querySelector('[data-slot="dialog-content"]')!;
expect(dialog.className).toContain('grid-cols-[minmax(0,1fr)]');
- expect(dialog.className).toContain('max-h-[calc(100dvh-2rem)]');
+ expect(dialog.className).toContain('max-h-[88dvh]');
+ expect(dialog.className).toContain('top-[6dvh]');
+ expect(dialog.className).toContain('translate-y-0');
+ expect(dialog.className).not.toContain('top-1/2');
expect(dialog.className).toContain('overflow-y-auto');
expect(document.querySelector('[data-slot="dialog-footer"]')!.className).toContain('sticky');
@@ -919,6 +925,15 @@ describe('New content', () => {
expect(button('Open editor')).toBeDefined();
});
+ it('asks who does it before the Overview, which grows as it lands', async () => {
+ await startNewPage();
+ const who = document.querySelector('[aria-labelledby="start-who"]')!;
+ const overview = [...document.querySelectorAll('label')].find(
+ (l) => l.textContent === 'Overview',
+ )!;
+ expect(who.compareDocumentPosition(overview) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ });
+
it('hands the draft to the Content Agent, and opens the editor to watch it work', async () => {
startAgentWriting.mockResolvedValue({ started: true });
await startNewPage();
@@ -939,6 +954,8 @@ describe('New content', () => {
// At once, no toast to click: the editor shows the agent at work.
expect(push).toHaveBeenCalledWith('/dashboard/content/editor/d9');
expect(toast.success).not.toHaveBeenCalled();
+ // The dialog stays until the editor opens: no page under it meanwhile.
+ expect(onOpenChange).not.toHaveBeenCalledWith(false);
});
it('aims the agent at a pasted page’s own length (F)', async () => {
@@ -982,6 +999,7 @@ describe('New content', () => {
expect(onSent).toHaveBeenCalled();
// Nothing to watch: the editor isn't opened, the toast offers the draft.
expect(push).not.toHaveBeenCalled();
+ expect(onOpenChange).toHaveBeenCalledWith(false);
});
it('says the draft is the person’s to write when the agent is busy with another', async () => {
diff --git a/web/src/components/content/new-content-dialog.tsx b/web/src/components/content/new-content-dialog.tsx
index cbf1a60b8..7ce3685e4 100644
--- a/web/src/components/content/new-content-dialog.tsx
+++ b/web/src/components/content/new-content-dialog.tsx
@@ -534,8 +534,9 @@ export function NewContentDialog({
/**
* Agent: the Content Agent does the page in the background — a new page
* written, an existing one's suggestions left — and the editor opens at
- * once, showing the agent at work until the page is there to review. It
- * stays in the Library as a draft if it can't start.
+ * once, showing the agent at work until the page is there to review; the
+ * dialog stays until it does. It stays in the Library as a draft if it
+ * can't start.
*/
const sendToAgent = async (id: string, bodyHtml: string | undefined) => {
const openDraft = {
@@ -564,12 +565,14 @@ export function NewContentDialog({
console.error('Failed to hand the draft to the Content Agent:', err);
started = { error: 'failed' };
}
- changeOpen(false);
onSent?.();
if ('error' in started) {
+ changeOpen(false);
toast.error(t(`start.agentErrors.${started.error}`), { action: openDraft });
return;
}
+ // As Me does: the dialog stays, its button busy, until the editor shows
+ // the agent at work, rather than the page under it for a few seconds.
router.push(contentEditorPath(id));
};
@@ -612,9 +615,11 @@ export function NewContentDialog({
{/*
One column no wider than the dialog: a long title or pick truncates
instead of widening it. No taller than the window: Start scrolls,
- its buttons kept in view.
+ its buttons kept in view. Held at the top, not centred: what Start
+ reads after it opens (the Overview) grows it downwards, and the
+ choices above don't move.
*/}
- <DialogContent className="max-h-[calc(100dvh-2rem)] grid-cols-[minmax(0,1fr)] overflow-y-auto sm:max-w-2xl">
+ <DialogContent className="top-[6dvh] max-h-[88dvh] translate-y-0 grid-cols-[minmax(0,1fr)] overflow-y-auto sm:max-w-2xl">
{start ? (
<>
<DialogHeader>
@@ -665,23 +670,11 @@ export function NewContentDialog({
</p>
)}
</div>
- {overlapKey && (
- <OverlapCheck
- read={overlapRead?.key === overlapKey ? overlapRead : null}
- choice={start.choice}
- given={start.givenPage ?? null}
- givenCited={start.source.kind === 'prompt'}
- onChoose={(choice) => {
- optimizeOnce.current = false;
- setStart(withChoice(start, choice, siteType));
- }}
- onRetry={() => {
- optimizeOnce.current = false;
- setOverlapRead(null);
- setOverlapAttempt((n) => n + 1);
- }}
- />
- )}
+ {/*
+ Who does it comes before the Overview: the Overview is read
+ after the dialog opens and grows as it lands, and nothing the
+ person may be about to click sits under it.
+ */}
<div className="space-y-2">
<Label id="start-who">{t('who.label')}</Label>
<div
@@ -743,6 +736,23 @@ export function NewContentDialog({
</div>
)}
</div>
+ {overlapKey && (
+ <OverlapCheck
+ read={overlapRead?.key === overlapKey ? overlapRead : null}
+ choice={start.choice}
+ given={start.givenPage ?? null}
+ givenCited={start.source.kind === 'prompt'}
+ onChoose={(choice) => {
+ optimizeOnce.current = false;
+ setStart(withChoice(start, choice, siteType));
+ }}
+ onRetry={() => {
+ optimizeOnce.current = false;
+ setOverlapRead(null);
+ setOverlapAttempt((n) => n + 1);
+ }}
+ />
+ )}
<DialogFooter className="sticky -bottom-4 z-10 bg-muted">
<Button variant="ghost" onClick={() => setStart(null)} disabled={opening}>
<ArrowLeft className="h-4 w-4" />