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
feat(content): put the editor's tags on a second line, and keep the side panel's tabs in sight, Rules first (#1347)
Cihan49ccdf3c67a6
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 316b5c4a5..185a87b98 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -3666,6 +3666,7 @@"label": "Side panel","show": "Show side panel","hide": "Hide side panel",+ "openTab": "Open {tab} in the side panel","tabs": {"impact": "Impact","brief": "Brief",@@ -3864,7 +3865,6 @@}},"rulesChip": "Rules {met}/{total}",- "rulesChipShort": "{met}/{total}","rulesChipHint": "Rules this page meets now. Open the Rules tab.","rules": {"set": "Rule set",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 a9e9472a1..612783b0d 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@@ -70,7 +70,7 @@ import { HtmlBlock, copyToClipboard } from './_html-block';import { OwnCopies, ownCopyHtml } from './_own-copies';import { PageTypeMenu } from './_page-type-menu';import { ruleStatusText, type AgentFix } from './_rules-tab';-import { EditorSidePanel, useSidePanelOpen } from './_side-panel';+import { EditorPanelRail, EditorSidePanel, useSidePanelOpen, type PanelTab } from './_side-panel';import {AgentSuggestions,acceptInto,@@ -192,8 +192,13 @@ export function DraftEditor({const [dragging, setDragging] = useState(false);const dragDepth = useRef(0);const [panelOpen, togglePanel] = useSidePanelOpen();- // The header's rules chip opens the panel on Rules.- const [tabRequest, setTabRequest] = useState<{ tab: 'rules'; n: number } | null>(null);+ // The header's rules chip opens the panel on Rules, and the closed panel's+ // strip on the tab picked there.+ const [tabRequest, setTabRequest] = useState<{ tab: PanelTab; n: number } | null>(null);+ const openPanelTab = (tab: PanelTab) => {+ if (!panelOpen) togglePanel();+ setTabRequest((prev) => ({ tab, n: (prev?.n ?? 0) + 1 }));+ };const editor = useEditor({extensions: [@@ -793,21 +798,78 @@ export function DraftEditor({return (<div className="flex min-h-0 flex-1 flex-col">- {/* One line at any width: the title shortens, the tags give way on a- narrow window, and the save state and Mark ready never move. */}- <header className="flex items-center gap-2.5 border-b px-4 py-2.5">- <Link- href={CONTENT_LIBRARY_PATH}- aria-label={t('back')}- title={t('back')}- className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })}- >- <ArrowLeft className="h-4 w-4" />- </Link>- <h1 className="min-w-0 truncate text-sm font-medium" title={title.trim() || undefined}>- {title.trim() || t('untitled')}- </h1>- <div className="hidden shrink-0 items-center gap-2 lg:flex">+ {/* Two lines: the title and what you do with the page on top, which+ stays light (the title shortens, the save state and Mark ready never+ move), and the page's tags under the title, all of them at any width. */}+ <header className="border-b px-4 pt-2.5 pb-2">+ <div className="flex items-center gap-2.5">+ <Link+ href={CONTENT_LIBRARY_PATH}+ aria-label={t('back')}+ title={t('back')}+ className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })}+ >+ <ArrowLeft className="h-4 w-4" />+ </Link>+ <h1 className="min-w-0 truncate text-sm font-medium" title={title.trim() || undefined}>+ {title.trim() || t('untitled')}+ </h1>+ <div className="ml-auto flex shrink-0 items-center gap-3">+ <SaveIndicator state={autosave.state} onRetry={() => void autosave.retry()} />+ <HistoryMenu+ draftId={draft.id}+ disabled={+ htmlSource !== null+ ? t('history.htmlOpen')+ : restoring+ ? t('history.restoring')+ : null+ }+ onRestore={(version, label) => void restoreVersion(version, label)}+ />+ <Button+ variant="outline"+ size="sm"+ onClick={copyPageHtml}+ title={t('copyHtmlHint')}+ aria-label={t('copyHtml')}+ >+ <Copy className="h-3.5 w-3.5" />+ <span className="hidden xl:inline">{t('copyHtml')}</span>+ </Button>+ <Button+ size="sm"+ // A page that can't be saved can't be marked ready; the save state says why.+ disabled={+ !canMarkReady ||+ marking ||+ autosave.state === 'conflict' ||+ autosave.state === 'too_large'+ }+ onClick={markReady}+ >+ {marking ? (+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ ) : (+ !canMarkReady && <Check className="h-3.5 w-3.5" />+ )}+ {t('markReady')}+ </Button>+ <Button+ variant="ghost"+ size="icon-sm"+ aria-pressed={panelOpen}+ aria-label={panelOpen ? t('panel.hide') : t('panel.show')}+ title={panelOpen ? t('panel.hide') : t('panel.show')}+ onClick={togglePanel}+ className={cn(panelOpen && 'bg-muted')}+ >+ <PanelRight className="h-4 w-4" />+ </Button>+ </div>+ </div>+ {/* Lined up under the title (the back button's 28px and the 10px gap). */}+ <div className="mt-1.5 flex flex-wrap items-center gap-2 pl-[38px]"><PageTypeMenubrandId={draft.brandId}siteType={draft.siteType}@@ -818,97 +880,31 @@ export function DraftEditor({onPick={(type) => void pickPageType(type)}/><DraftMethodBadge method={draft.method} />- </div>- <span className="shrink-0"><DraftStatusBadge status={status} />- </span>- <button- type="button"- onClick={() => {- if (!panelOpen) togglePanel();- setTabRequest((prev) => ({ tab: 'rules', n: (prev?.n ?? 0) + 1 }));- }}- title={t('rulesChipHint')}- aria-label={t('rulesChip', { met: rules.met, total: rules.total })}- className={cn(- 'inline-flex shrink-0 items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium',- rules.total > 0 && rules.met === rules.total- ? 'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-300'- : 'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300',- )}- >- <span aria-hidden className="h-1.5 w-1.5 rounded-full bg-current" />- {/* Short on a narrow window, so the header stays one line. */}- <span aria-hidden className="hidden xl:inline">- {t('rulesChip', { met: rules.met, total: rules.total })}- </span>- <span aria-hidden className="xl:hidden">- {t('rulesChipShort', { met: rules.met, total: rules.total })}- </span>- </button>- {/* Wide windows only: the page's green lines show them anyway, and- the header stays one line at 1024px. */}- {citedCount > 0 && (- <span- title={t('cited.chipHint')}- className="hidden shrink-0 items-center gap-1.5 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-xs font-medium text-emerald-700 xl:inline-flex dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-300"- >- <span aria-hidden className="h-1.5 w-1.5 rounded-full bg-current" />- {t('cited.chip', { count: citedCount })}- </span>- )}- <div className="ml-auto flex shrink-0 items-center gap-3">- <SaveIndicator state={autosave.state} onRetry={() => void autosave.retry()} />- <HistoryMenu- draftId={draft.id}- disabled={- htmlSource !== null- ? t('history.htmlOpen')- : restoring- ? t('history.restoring')- : null- }- onRestore={(version, label) => void restoreVersion(version, label)}- />- <Button- variant="outline"- size="sm"- onClick={copyPageHtml}- title={t('copyHtmlHint')}- aria-label={t('copyHtml')}- >- <Copy className="h-3.5 w-3.5" />- <span className="hidden xl:inline">{t('copyHtml')}</span>- </Button>- <Button- size="sm"- // A page that can't be saved can't be marked ready; the save state says why.- disabled={- !canMarkReady ||- marking ||- autosave.state === 'conflict' ||- autosave.state === 'too_large'- }- onClick={markReady}- >- {marking ? (- <Loader2 className="h-3.5 w-3.5 animate-spin" />- ) : (- !canMarkReady && <Check className="h-3.5 w-3.5" />+ <button+ type="button"+ onClick={() => openPanelTab('rules')}+ title={t('rulesChipHint')}+ aria-label={t('rulesChip', { met: rules.met, total: rules.total })}+ className={cn(+ 'inline-flex h-5 shrink-0 items-center gap-1.5 rounded-full border px-2 text-xs font-medium',+ rules.total > 0 && rules.met === rules.total+ ? 'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-300'+ : 'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300',)}- {t('markReady')}- </Button>- <Button- variant="ghost"- size="icon-sm"- aria-pressed={panelOpen}- aria-label={panelOpen ? t('panel.hide') : t('panel.show')}- title={panelOpen ? t('panel.hide') : t('panel.show')}- onClick={togglePanel}- className={cn(panelOpen && 'bg-muted')}>- <PanelRight className="h-4 w-4" />- </Button>+ <span aria-hidden className="h-1.5 w-1.5 rounded-full bg-current" />+ {t('rulesChip', { met: rules.met, total: rules.total })}+ </button>+ {citedCount > 0 && (+ <span+ title={t('cited.chipHint')}+ className="inline-flex h-5 shrink-0 items-center gap-1.5 rounded-full border border-emerald-200 bg-emerald-50 px-2 text-xs font-medium text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-300"+ >+ <span aria-hidden className="h-1.5 w-1.5 rounded-full bg-current" />+ {t('cited.chip', { count: citedCount })}+ </span>+ )}</div></header>@@ -1041,7 +1037,7 @@ export function DraftEditor({</div>{attachments.ui}</div>- {panelOpen && (+ {panelOpen ? (<EditorSidePaneldraft={draft}title={title}@@ -1052,6 +1048,8 @@ export function DraftEditor({tabRequest={tabRequest}agentFix={agentFix}/>+ ) : (+ <EditorPanelRail onOpen={openPanelTab} />)}</div>diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsxindex 816542417..a62b6d4dd 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx@@ -44,15 +44,45 @@ export function useSidePanelOpen(): [boolean, () => void] {return [open, toggle];}-const PANEL_TABS = ['impact', 'brief', 'sources', 'rules'] as const;+// Rules first: what to act on before anything else (the user's call over the+// spec's Impact-first order); the panel opens on it.+const PANEL_TABS = ['rules', 'brief', 'sources', 'impact'] as const;export type PanelTab = (typeof PANEL_TABS)[number];+/**+ * The panel's tabs while it is closed, down the editor's right edge, so the+ * panel is never out of sight (it starts closed on a narrow window). A tab+ * opens the panel on it.+ */+export function EditorPanelRail({ onOpen }: { onOpen: (tab: PanelTab) => void }) {+ const t = useTranslations('contentEditor.editor.panel');+ return (+ <nav+ aria-label={t('label')}+ className="flex w-9 shrink-0 flex-col items-center gap-1 border-l bg-card py-2"+ >+ {PANEL_TABS.map((value) => (+ <button+ key={value}+ type="button"+ onClick={() => onOpen(value)}+ title={t('openTab', { tab: t(`tabs.${value}`) })}+ className="rounded-md px-1.5 py-2.5 text-xs font-medium text-muted-foreground transition-colors [writing-mode:vertical-rl] hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none"+ >+ {t(`tabs.${value}`)}+ </button>+ ))}+ </nav>+ );+}+/*** The editor's right panel (Content Editor spec v2 §6), 400px beside the page.* The spec's tabs are Impact · Chat · Brief · Sources · Rules; each joins the* panel with the update that makes it work: Impact (CE-016), Brief (CE-007),- * Sources (CE-008) and Rules (CE-009). A tab opened once stays mounted, so switching back- * keeps it as it was. The brief and the sources are the editor's one read+ * Sources (CE-008) and Rules (CE-009). Rules comes first and the panel opens+ * on it; each other tab mounts (and reads) when first opened, and stays+ * mounted, so switching back keeps it as it was. The brief and the sources are the editor's one read* (useDraftReads), which the rules check against too: Sources' "Rebuild with* selection" and Impact's "Use lost prompts" rebuild the brief, and open it.*/@@ -81,8 +111,8 @@ export function EditorSidePanel({agentFix?: AgentFix;}) {const t = useTranslations('contentEditor.editor.panel');- const [tab, setTab] = useState<PanelTab>('impact');- const [opened, setOpened] = useState<Set<PanelTab>>(() => new Set(['impact']));+ const [tab, setTab] = useState<PanelTab>('rules');+ const [opened, setOpened] = useState<Set<PanelTab>>(() => new Set(['rules']));const page = useRef<PageNow>({ title, html: bodyHtml, length: rules.length });const sourcesNow = useRef(reads.sources);useEffect(() => {@@ -131,14 +161,6 @@ export function EditorSidePanel({</TabsList></Tabs><div className="min-h-0 flex-1 overflow-y-auto px-4 py-4">- <div hidden={tab !== 'impact'}>- <ImpactTab- brandId={draft.brandId}- pageUrl={draft.sourceUrl}- rebuilding={rebuilding}- onUseLostPrompts={(promptIds) => void rebuild({ addPrompts: promptIds })}- />- </div>{briefOpened && (<div hidden={tab !== 'brief'}><BriefTab@@ -180,6 +202,16 @@ export function EditorSidePanel({/></div>)}+ {opened.has('impact') && (+ <div hidden={tab !== 'impact'}>+ <ImpactTab+ brandId={draft.brandId}+ pageUrl={draft.sourceUrl}+ rebuilding={rebuilding}+ onUseLostPrompts={(promptIds) => void rebuild({ addPrompts: promptIds })}+ />+ </div>+ )}</div></aside>);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 4f59a286d..ddf2070a6 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@@ -170,6 +170,17 @@ const button = (name: string) =>(b) => b.getAttribute('aria-label') === name || b.textContent === name,);+/** Picks one of the side panel's tabs. */+async function pickTab(name: string) {+ const tab = [...container.querySelectorAll<HTMLElement>('aside [role="tab"]')].find(+ (el) => el.textContent === name,+ )!;+ await act(async () => {+ tab.dispatchEvent(new MouseEvent('pointerdown', { bubbles: true }));+ tab.click();+ });+}+beforeEach(() => {container = document.createElement('div');document.body.appendChild(container);@@ -218,10 +229,14 @@ describe('the content editor', () => {expect(getContentDraft).toHaveBeenCalledWith('d1');const header = container.querySelector('header')!;expect(header.querySelector('h1')!.textContent).toBe('Pipeline forecasting');- expect(header.textContent).toContain('Feature page');- expect(header.textContent).toContain('Optimize');- expect(header.textContent).toContain('In review');expect(header.textContent).toContain('Saved');+ // The page's tags on a line of their own, under the title.+ const [top, tags] = header.children;+ expect(top.textContent).not.toContain('In review');+ expect(tags.textContent).toContain('Feature page');+ expect(tags.textContent).toContain('Optimize');+ expect(tags.textContent).toContain('In review');+ expect(tags.textContent).toMatch(/Rules \d+\/\d+/);expect(container.querySelector('a[href="/dashboard/content/library"]')).not.toBeNull();// The page's text, against a feature page's 3,000-character target.@@ -1367,14 +1382,40 @@ describe('the side panel', () => {await act(async () => button('Show side panel')!.click());expect(panel()!.getAttribute('aria-label')).toBe('Side panel');- expect(panel()!.textContent).toContain('Impact');+ // Rules first, what to act on; Impact reads only once it is picked.+ expect(panel()!.querySelector('[role="tab"][aria-selected="true"]')?.textContent).toBe('Rules');+ expect(getContentImpact).not.toHaveBeenCalled();+ await pickTab('Impact');// The page the draft optimizes, over 30 days.expect(getContentImpact).toHaveBeenCalledWith('b1', 'https://acme.example.com/pricing', 30);expect(getContentResults).toHaveBeenCalledWith('b1', 'https://acme.example.com/pricing', 30);expect(button('Hide side panel')!.getAttribute('aria-pressed')).toBe('true');});- it('opens Sources only when its tab is picked, and keeps Impact as it was', async () => {+ it('keeps its tabs down the right edge while closed, and opens on the one picked', async () => {+ getContentDraft.mockResolvedValue(draft());+ window.innerWidth = 1024;+ await renderPage();+ expect(panel()).toBeNull();+ const rail = () => container.querySelector('nav[aria-label="Side panel"]');+ const tabs = [...rail()!.querySelectorAll('button')];+ expect(tabs.map((b) => b.textContent)).toEqual(['Rules', 'Brief', 'Sources', 'Impact']);+ expect(tabs[2].getAttribute('title')).toBe('Open Sources in the side panel');++ await act(async () => tabs[2].click());+ expect(panel()!.querySelector('[role="tab"][aria-selected="true"]')?.textContent).toBe(+ 'Sources',+ );+ expect(rail()).toBeNull();+ expect(localStorage.getItem('aeo:content-editor-panel')).toBe('1');++ // Closed again from the header, the strip is back.+ await act(async () => button('Hide side panel')!.click());+ expect(panel()).toBeNull();+ expect(rail()).not.toBeNull();+ });++ it('opens Sources only when its tab is picked, and reads Impact only when it is', async () => {getDraftSources.mockResolvedValue({data: {prompts: [],@@ -1405,7 +1446,7 @@ describe('the side panel', () => {// The draft's H1 carries the fan-out's words.expect(panel()!.textContent).toContain('pipeline forecasting');expect(panel()!.textContent).toContain('H1');- expect(getContentImpact).toHaveBeenCalledTimes(1);+ expect(getContentImpact).not.toHaveBeenCalled();});it('rebuilds the brief from Sources and opens it', async () => {@@ -1442,22 +1483,13 @@ describe('the side panel', () => {window.innerWidth = 1440;await renderPage();- const pick = async (name: string) => {- const tab = [...panel()!.querySelectorAll<HTMLElement>('[role="tab"]')].find(- (el) => el.textContent === name,- )!;- await act(async () => {- tab.dispatchEvent(new MouseEvent('pointerdown', { bubbles: true }));- tab.click();- });- };expect([...panel()!.querySelectorAll('[role="tab"]')].map((el) => el.textContent)).toEqual([- 'Impact',+ 'Rules','Brief','Sources',- 'Rules',+ 'Impact',]);- await pick('Sources');+ await pickTab('Sources');await act(async () => button('Rebuild with selection')!.click());expect(rebuildDraftBrief).toHaveBeenCalledWith('d1', 'b1', {@@ -1475,7 +1507,7 @@ describe('the side panel', () => {expect(panel()!.textContent).toContain('Win forecasting searches');// The rules check against the brief just rebuilt, without a reload.- await pick('Rules');+ await pickTab('Rules');expect([...panel()!.querySelectorAll<HTMLInputElement>('input')].map((input) => input.value),).toContain('forecast accuracy, pipeline');@@ -1777,6 +1809,7 @@ describe('the side panel', () => {getContentDraft.mockResolvedValue(draft({ method: 'create' }));window.innerWidth = 1440;await renderPage();+ await pickTab('Impact');// A new page: nothing to measure yet.expect(panel()!.textContent).toContain('This draft is a new page, not live yet');expect(getContentImpact).not.toHaveBeenCalled();