Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.
fix(seo-cockpit): apply the Phase 2 and 3 review
Agrici Danielab747999dfd0
diff --git a/plugins/seo-cockpit/README.md b/plugins/seo-cockpit/README.mdindex 4860f87..dbaa841 100644--- a/plugins/seo-cockpit/README.md+++ b/plugins/seo-cockpit/README.md@@ -29,7 +29,7 @@ What is logged: only calls that succeeded and have a price in the cost table. Aseo audit example.com 3 running, 9 done findings 9 spend $0.42 4m12s```-It starts from the `/seo audit <url>` prompt, or from the first file written into a `<domain>-audit/` folder (so an audit asked for in plain words is caught too). Agents count as running when spawned and done when their Agent call returns. Spend is what the guard logged during the audit. The band yields to Claude Code's surveys, has a hide button, and clears at your next prompt after the audit ends.+It starts from the `/seo audit <url>` prompt or command, or from the first file written into a `<domain>-audit/` folder (so an audit asked for in plain words is caught too). Agents count as running when spawned and done when they finish (a background agent when its own turn ends). Other mods' bands stay visible below this one. A reload mid-audit keeps the band. Spend is what the guard logged during the audit. The band yields to Claude Code's surveys, has a hide button, and clears at your next prompt after the audit ends.**Receipt.** When the audit writes `audit-data.json`, one line appears under Claude's answer:@@ -41,7 +41,7 @@ seo audit example.com: score 72/100 | weakest Schema 40, Content 55 | 17 age**Compaction.** If the conversation is compacted mid-audit, the summary is asked to keep the output folder, which agents finished and which are running, and the findings files written.-**Visual cockpit** (`/seo-cockpit`). A pane with six views of the data claude-seo already collects. Keys 1 to 6 pick a view, `r` loads it, `e` exports HTML, `x` closes. Nothing is fetched until you press `r`, and no view calls a paid API.+**Visual cockpit** (`/seo-cockpit`). A pane with six views of the data claude-seo already collects. The pane opens with focus: keys 1 to 6 pick a view, `r` loads it, `e` exports HTML, `x` closes, Esc returns to the prompt. Nothing is fetched until you press `r`, and no view calls a paid API.| View | Shows | Source ||---|---|---|@@ -101,7 +101,6 @@ Auto-update is off by default for third-party marketplaces. Run `claude plugin u- **Ask before rules:** a call your permission rules would deny can still raise its cost question first.- **The band and the pane draw in the terminal and the desktop app,** not in the VS Code chat panel or `claude -p`. The receipt line is plain text and shows wherever the answer does; the cockpit falls back to the HTML dashboard.- **The Maps view needs a saved grid.** Grids from before this release were only drawn in the chat; run the scan again to save one.-- **Background agents** return at once, so they count as done when started. claude-seo's audit runs its agents in the foreground.## Status@@ -110,7 +109,7 @@ The kit tests in `tests/` are written against the Claude Code 2.1.288 typings bu- type-check (`tsc`, strict)- `claude plugin validate --strict`- the brain's static scan (reach L2, no critical or high flags)-- 70 end-to-end scenarios run through a stand-in for the hook chain against the real claude-seo scripts and an isolated ledger (Search Console, CrUX and drift from fixtures, so no Google account was called)+- 79 end-to-end scenarios run through a stand-in for the hook chain against the real claude-seo scripts and an isolated ledger (Search Console, CrUX and drift from fixtures, so no Google account was called)- the 47 pure-logic tests (`logic`, `audit-logic`, `cockpit-logic`), run with a minimal stand-in for the kit's `describe`, `test` and `expect`- the HTML export rendered in Chromium, light and darkdiff --git a/plugins/seo-cockpit/hooks/lib/audit.ts b/plugins/seo-cockpit/hooks/lib/audit.tsindex 2a5fc48..fd47852 100644--- a/plugins/seo-cockpit/hooks/lib/audit.ts+++ b/plugins/seo-cockpit/hooks/lib/audit.ts@@ -9,7 +9,7 @@import { usd } from './verdict'-export type AgentRun = { type: string; state: 'running' | 'done' | 'failed'; startMs: number; endMs?: number }+export type AgentRun = { type: string; state: 'running' | 'done' | 'failed'; startMs: number; endMs?: number; agentId?: string }export type Audit = {domain: stringdiff --git a/plugins/seo-cockpit/hooks/register.ts b/plugins/seo-cockpit/hooks/register.tsindex 4d46131..9c1a752 100644--- a/plugins/seo-cockpit/hooks/register.ts+++ b/plugins/seo-cockpit/hooks/register.ts@@ -1,7 +1,7 @@import type { EngineInterface, On, PluginOptions, ResultOf } from 'claude-code'import { auditFromPrompt, bandText, compactInstructions, economyModel, isSeoAgent, noteWrite, receiptText, type Audit } from './lib/audit'-import { htmlPage } from './lib/charts'+import { COLORS, htmlPage } from './lib/charts'import { doctorText, spendText } from './lib/format'import { classify, type PaidCall } from './lib/paid'import { candidatesOf, joinPath, latestVersion, MARKER } from './lib/root'@@ -234,13 +234,48 @@ function stopTicker(ctx: Ctx): void {ctx.stopTicker = null}+/** The band's clock needs redrawing only while the band shows a running audit. */+function syncTicker($: EngineInterface, ctx: Ctx): void {+ const audit = ctx.audit++ if (ctx.isBandOn && !ctx.isBandHidden && audit !== null && audit.finishMs === null) {+ startTicker($, ctx)+ } else {+ stopTicker(ctx)+ }+}++/** Sets the audit, redraws, and keeps a copy in the store so a reload mid-audit does not lose it. */+function setAudit($: EngineInterface, ctx: Ctx, audit: Audit | null): void {+ ctx.audit = audit+ syncTicker($, ctx)+ $.ui.invalidate('ui.render')+ void $.store.set('audit', audit).catch(() => undefined)+}+/** Starts following a new audit and shows the band again. */function follow($: EngineInterface, ctx: Ctx, audit: Audit): void {- ctx.audit = auditctx.isBandHidden = falsectx.isReceiptShown = false- startTicker($, ctx)- $.ui.invalidate('ui.render')+ setAudit($, ctx, audit)+}++/** An audit older than this with no result is treated as abandoned. */+const STALE_MS = 3 * 60 * 60 * 1000++/** After a reload, picks up an audit that was still running. */+async function restoreAudit($: EngineInterface, ctx: Ctx): Promise<void> {+ if (ctx.audit !== null) {+ return+ }++ const saved = (await $.store.get('audit').catch(() => null)) as Audit | null++ if (saved !== null && typeof saved === 'object' && typeof saved.domain === 'string' && saved.finishMs === null && Date.now() - saved.startMs < STALE_MS) {+ ctx.audit = saved+ syncTicker($, ctx)+ $.ui.invalidate('ui.render')+ }}/** Runs a claude-seo script through its managed runtime (for scripts that need its packages) and parses the JSON it prints. */@@ -295,6 +330,17 @@ async function shown($: EngineInterface, path: string | null): Promise<string> {return path.startsWith(`${cwd}/`) ? path.slice(cwd.length + 1) : path}+/** The store key for a tab's last result: per working folder and property, so one project's data never shows in another. */+async function cacheKey($: EngineInterface, ctx: Ctx, tab: TabId): Promise<string> {+ return `tab:${tab}:${await $.session.cwd()}:${ctx.site}`+}++const isModel = (value: unknown): value is TabModel => {+ const m = value as Partial<TabModel> | null++ return typeof m === 'object' && m !== null && typeof m.heading === 'string' && Array.isArray(m.kpis) && Array.isArray(m.charts) && Array.isArray(m.tables) && Array.isArray(m.notes)+}+async function readJson($: EngineInterface, path: string): Promise<unknown> {try {return JSON.parse(await $.fs.read(path))@@ -378,7 +424,7 @@ async function loadTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<void>const model = await buildTab($, ctx, tab)ctx.pane.models[tab] = model- await $.store.set(`tab:${tab}`, model).catch(() => undefined)+ await $.store.set(await cacheKey($, ctx, tab), model).catch(() => undefined)} finally {ctx.pane.isLoading = falsectx.pane.model = ctx.pane.models[ctx.pane.tab] ?? null@@ -391,10 +437,10 @@ async function pickTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<void>ctx.pane.tab = tabif (ctx.pane.models[tab] === undefined) {- const cached = await $.store.get(`tab:${tab}`).catch(() => undefined)+ const cached = await $.store.get(await cacheKey($, ctx, tab)).catch(() => undefined)- if (typeof cached === 'object' && cached !== null && 'heading' in cached) {- ctx.pane.models[tab] = cached as TabModel+ if (isModel(cached)) {+ ctx.pane.models[tab] = cached}}@@ -416,7 +462,7 @@ async function exportHtml($: EngineInterface, ctx: Ctx, loadAll: boolean): Promireturn model === undefined ? [] : [{ ...model, source: `${model.source} · fetched ${model.fetchedAt}`, notes: model.error === null ? model.notes : [model.error, ...model.notes] }]})const cwd = await $.session.cwd()- const path = joinPath(cwd, `seo-cockpit-${stamp().replace(/[: ]/g, '-')}.html`)+ const path = joinPath(cwd, `seo-cockpit-${new Date().toISOString().slice(0, 19).replace(/[:T]/g, '-')}.html`)await $.fs.write(path, htmlPage('SEO Cockpit', `Generated ${stamp()} by seo-cockpit from claude-seo data`, sections))ctx.pane.exported = path@@ -433,12 +479,13 @@ async function cockpitCommand($: EngineInterface, ctx: Ctx, args: string): Promiawait pickTab($, ctx, ctx.pane.tab)- const opened = await $.ui.open({ id: PANE_ID, title: 'SEO Cockpit' })+ // Focus, so the pane's keys work at once; Esc gives focus back to the prompt.+ const opened = await $.ui.open({ id: PANE_ID, title: 'SEO Cockpit', focus: true, closeOnEscape: true })if (opened.isPlaced) {ctx.pane.isOpen = true- return { text: 'seo-cockpit: pane open. Keys 1 to 6 pick a view, r loads it, e exports HTML, x closes.' }+ return { text: 'seo-cockpit: pane open. Keys 1 to 6 pick a view, r loads it, e exports HTML, x closes, Esc returns to the prompt.' }}// No pane here (the VS Code chat panel, a narrow terminal): the HTML page is the cockpit.@@ -550,10 +597,20 @@ export function register(on: On, options: PluginOptions) {if (audit !== null) {follow($, ctx, audit)- } else if (ctx.audit !== null && ctx.audit.finishMs !== null) {- // A finished audit's band stays up until the next prompt.- ctx.audit = null- $.ui.invalidate('ui.render')+ } else if (ctx.audit !== null && (ctx.audit.finishMs !== null || Date.now() - ctx.audit.startMs > STALE_MS)) {+ // A finished audit's band stays up until the next prompt; an abandoned one goes too.+ setAudit($, ctx, null)+ }++ return next(e)+ })++ // A slash command may reach the engine as a command run rather than prompt text; observe both.+ on('command.run', { command: ['seo', 'claude-seo:seo'] }, async ($, e, next) => {+ const audit = auditFromPrompt(`/seo ${e.args}`, Date.now())++ if (audit !== null && (ctx.audit === null || ctx.audit.domain !== audit.domain || ctx.audit.finishMs !== null)) {+ follow($, ctx, audit)}return next(e)@@ -564,26 +621,35 @@ export function register(on: On, options: PluginOptions) {return next(e)}- if (ctx.audit !== null && ctx.audit.finishMs === null) {- ctx.audit = { ...ctx.audit, agents: { ...ctx.audit.agents, [e.tool_use_id]: { type: e.subagentType, state: 'running', startMs: Date.now() } } }- $.ui.invalidate('ui.render')+ const isFollowing = ctx.audit !== null && ctx.audit.finishMs === null++ if (ctx.audit !== null && isFollowing) {+ setAudit($, ctx, { ...ctx.audit, agents: { ...ctx.audit.agents, [e.tool_use_id]: { type: e.subagentType, state: 'running', startMs: Date.now() } } })}const model = ctx.isEconomy && e.model === undefined ? economyModel(e.subagentType) : null+ const result = await next(model === null ? e : { ...e, model })+ const run = ctx.audit?.agents[e.tool_use_id]- return next(model === null ? e : { ...e, model })+ // The agent's id lets its own turn end close it, which a background agent needs.+ if (ctx.audit !== null && run !== undefined && result.agentId !== undefined) {+ setAudit($, ctx, { ...ctx.audit, agents: { ...ctx.audit.agents, [e.tool_use_id]: { ...run, agentId: result.agentId } } })+ }++ return result})- // A foreground Agent call returns when its subagent is done.- on('tool.call', { tool: ['Agent', /^Task$/] }, async ($, e, next) => {+ // A foreground Agent call returns when its subagent is done; a background one returns at launch.+ on('tool.call', { tool: 'Agent' }, async ($, e, next) => {const result = await next(e)const run = ctx.audit?.agents[e.tool_use_id]+ const status = (result.result as { status?: unknown } | undefined)?.status+ const isLaunchOnly = status === 'async_launched' || status === 'remote_launched'- if (ctx.audit !== null && run !== undefined) {+ if (ctx.audit !== null && run !== undefined && run.state === 'running' && !isLaunchOnly) {const state = result.deny !== undefined || result.isError === true ? 'failed' : 'done'- ctx.audit = { ...ctx.audit, agents: { ...ctx.audit.agents, [e.tool_use_id]: { ...run, state, endMs: Date.now() } } }- $.ui.invalidate('ui.render')+ setAudit($, ctx, { ...ctx.audit, agents: { ...ctx.audit.agents, [e.tool_use_id]: { ...run, state, endMs: Date.now() } } })}return result@@ -602,8 +668,7 @@ export function register(on: On, options: PluginOptions) {if (before === null || before.finishMs !== null) {follow($, ctx, after)} else {- ctx.audit = after- $.ui.invalidate('ui.render')+ setAudit($, ctx, after)}}}@@ -615,27 +680,38 @@ export function register(on: On, options: PluginOptions) {const result = await next(e)const audit = ctx.audit+ if (e.agentId !== undefined) {+ // A subagent finished: close its run (the only signal a background agent gives).+ const entry = audit === null ? undefined : Object.entries(audit.agents).find(([, run]) => run.agentId === e.agentId && run.state === 'running')++ if (audit !== null && entry !== undefined) {+ setAudit($, ctx, { ...audit, agents: { ...audit.agents, [entry[0]]: { ...entry[1], state: 'done', endMs: Date.now() } } })+ }++ return result+ }+// The receipt goes under the main answer, once, when the audit's data file exists.- if (e.agentId !== undefined || audit === null || audit.finishMs !== null || audit.score === null || ctx.isReceiptShown) {+ if (audit === null || audit.finishMs !== null || audit.score === null || ctx.isReceiptShown) {return result}const now = Date.now()- ctx.audit = { ...audit, finishMs: now }ctx.isReceiptShown = true- stopTicker(ctx)- $.ui.invalidate('ui.render')+ setAudit($, ctx, { ...audit, finishMs: now })const receipt = receiptText(audit, now)+ // `next` resolves to the answer itself; any other text is shown beneath it. Keep another mod's line, never the answer.+ const theirs = result.text !== '' && result.text !== e.answer ? result.text : ''- return { ...result, text: result.text ? `${result.text}\n${receipt}` : receipt }+ return { ...result, text: theirs === '' ? receipt : `${theirs}\n${receipt}` }})on('session.compact', async ($, e, next) => {const audit = ctx.audit- if (audit === null || audit.finishMs !== null) {+ if (e.agentId !== undefined || audit === null || audit.finishMs !== null) {return next(e)}@@ -651,21 +727,30 @@ export function register(on: On, options: PluginOptions) {const { Box, Text, Button } = $.ui.resolve(e)const columns = Math.max(20, Math.floor(e.props.bodyColumns) - 10)+ // Other mods' bands sit below ours rather than being replaced.+ const theirs = await next(e)return Box({- flexDirection: 'row',- columnGap: 1,+ flexDirection: 'column',children: [- Text({ color: audit.finishMs === null ? 'cyan' : 'green', children: [bandText(audit, Date.now(), columns, ctx.isEconomy)] }),- Button({- key: 'seo-cockpit-hide',- label: 'hide',- plain: true,- onPress: () => {- ctx.isBandHidden = true- $.ui.invalidate('ui.render')- },+ Box({+ flexDirection: 'row',+ columnGap: 1,+ children: [+ Text({ color: audit.finishMs === null ? COLORS.blue : COLORS.good, children: [bandText(audit, Date.now(), columns, ctx.isEconomy)] }),+ Button({+ key: 'seo-cockpit-hide',+ label: 'hide',+ plain: true,+ onPress: () => {+ ctx.isBandHidden = true+ syncTicker($, ctx)+ $.ui.invalidate('ui.render')+ },+ }),+ ],}),+ theirs,],})})@@ -682,8 +767,9 @@ export function register(on: On, options: PluginOptions) {Box: table.Box,Text: table.Text,Button: table.Button,- ...('Link' in table && { Link: table.Link }),- ...('Svg' in table && { Svg: table.Svg }),+ ...('Markdown' in table && { Markdown: table.Markdown }),+ // Every table is completed with every element name, so `'Svg' in table` holds on the terminal too, where an Svg draws nothing.+ ...(e.surface !== 'terminal' && 'Svg' in table && { Svg: table.Svg }),}ctx.pane.isOpen = true@@ -708,6 +794,7 @@ export function register(on: On, options: PluginOptions) {on('session.start', async ($, e, next) => {await registerCommands($)+ await restoreAudit($, ctx)return next(e)})diff --git a/plugins/seo-cockpit/hooks/views/pane.ts b/plugins/seo-cockpit/hooks/views/pane.tsindex 90162a1..7a58485 100644--- a/plugins/seo-cockpit/hooks/views/pane.ts+++ b/plugins/seo-cockpit/hooks/views/pane.ts@@ -12,7 +12,7 @@ import type { Elements, RenderElement } from 'claude-code'import { barRow, endsOf, rankColor, sparkRow, svgOf, type Chart } from '../lib/charts'import { TABS, type TabId, type TabModel } from '../lib/tabs'-export type Kit = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'> & Partial<Pick<Elements['terminal'], 'Link'>> & { Svg?: Elements['desktop']['Svg'] }+export type Kit = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'> & Partial<Pick<Elements['terminal'], 'Markdown'>> & { Svg?: Elements['desktop']['Svg'] }export type PaneState = {tab: TabId@@ -97,7 +97,8 @@ export function paneView(kit: Kit, state: PaneState, columns: number, actions: Pconst tabs = Box({flexDirection: 'row',columnGap: 1,- children: TABS.map(tab => Button({ key: `tab-${tab.id}`, label: `${tab.id === state.tab ? '▸' : ''}${tab.key} ${tab.label}`, hotkey: tab.key, plain: true, onPress: () => actions.pick(tab.id) })),+ // A plain button with a hotkey draws as "1: label", so the label carries no key of its own.+ children: TABS.map(tab => Button({ key: `tab-${tab.id}`, label: `${tab.id === state.tab ? '▸ ' : ''}${tab.label}`, hotkey: tab.key, plain: true, onPress: () => actions.pick(tab.id) })),})const body: RenderElement[] = []const model = state.model@@ -129,13 +130,14 @@ export function paneView(kit: Kit, state: PaneState, columns: number, actions: P}const footer: RenderElement[] = [- Button({ key: 'refresh', label: 'r Refresh', hotkey: 'r', plain: true, onPress: actions.refresh }),- Button({ key: 'export', label: 'e Export HTML', hotkey: 'e', plain: true, onPress: actions.exportHtml }),- Button({ key: 'close', label: 'x Close', hotkey: 'x', plain: true, onPress: actions.close }),+ Button({ key: 'refresh', label: 'Refresh', hotkey: 'r', plain: true, onPress: actions.refresh }),+ Button({ key: 'export', label: 'Export HTML', hotkey: 'e', plain: true, onPress: actions.exportHtml }),+ Button({ key: 'close', label: 'Close', hotkey: 'x', plain: true, onPress: actions.close }),]if (state.exported !== null) {- footer.push(kit.Link !== undefined ? kit.Link({ href: `file://${encodeURI(state.exported)}`, label: 'open export' }) : Text({ dimColor: true, children: [state.exported] }))+ // A Link takes only https (or http://localhost) and refuses the whole tree otherwise; Markdown links may use file:.+ footer.push(kit.Markdown !== undefined ? kit.Markdown({ text: `[open export](file://${encodeURI(state.exported)})` }) : Text({ dimColor: true, children: [state.exported] }))}return Box({ flexDirection: 'column', rowGap: 0, children: [tabs, Box({ flexDirection: 'column', marginTop: 1, children: body }), Box({ flexDirection: 'row', columnGap: 2, marginTop: 1, children: footer })] })diff --git a/plugins/seo-cockpit/tests/audit.test.ts b/plugins/seo-cockpit/tests/audit.test.tsindex 272a3db..53b3e9c 100644--- a/plugins/seo-cockpit/tests/audit.test.ts+++ b/plugins/seo-cockpit/tests/audit.test.ts@@ -13,7 +13,7 @@ const prompt = (text: string) => ({ text, wait: false, origin: { kind: 'composer// The kit's inputs for these events carry engine fields a test does not need; the casts keep the tests readable.const spawn = (id: string, subagentType: string) =>({ tool_use_id: id, prompt: 'p', description: 'd', subagentType, provider: { plugin: 'claude-seo', tier: 'user' }, parentModel: 'claude-opus-5-5' }) as never-const turnDone = () => ({ turnId: 't1', text: 'Audit complete.', durationMs: 1000, isAborted: false, reason: 'answer' }) as never+const turnDone = () => ({ turnId: 't1', answer: 'Audit complete.', durationMs: 1000, isAborted: false, reason: 'answer' }) as never/** The engine's own answers at the bottom of each event the audit hooks pass on. */function engine(on: Parameters<typeof worldOf>[0]) {@@ -25,7 +25,8 @@ function engine(on: Parameters<typeof worldOf>[0]) {return { model: e.model ?? 'inherit' }})- on('turn.complete', () => ({ text: '' }))+ // As the engine answers: the turn's own answer text.+ on('turn.complete', ($, e) => ({ text: (e as unknown as { answer: string }).answer }))on('session.compact', ($, e) => {seen.instructions.push(e.instructions)@@ -58,6 +59,8 @@ describe('audit band and receipt', () => {expect(result.text).toContain('score 72/100')expect(result.text).toContain('weakest Schema 40')+ // The receipt alone: the answer is not repeated beneath itself.+ expect(result.text).not.toContain('Audit complete.')expect(world.ran.filter(tool => tool === 'Write').length).toBe(2)})@@ -68,7 +71,19 @@ describe('audit band and receipt', () => {await $.tool.call({ tool: 'Write', file_path: '/work/a.com-audit/audit-data.json', content: DATA })expect((await $.turn.complete(turnDone())).text).toContain('score 72/100')- expect((await $.turn.complete(turnDone())).text).toBe('')+ expect((await $.turn.complete(turnDone())).text).toBe('Audit complete.')+ })++ test('other mods\' bands stay visible under ours', async ($, on) => {+ mock.clock(on)+ worldOf(on)+ engine(on)+ await $.prompt.submit(prompt('/seo audit example.com'))++ const ui = await $.ui.mount({ ...BAND, surface: 'terminal' })++ expect(await ui.find({ type: 'Text', text: /seo audit example\.com/ })).toBeDefined()+ expect(await ui.find({ type: 'Text', text: 'drawn by Claude Code' })).toBeDefined()})test('with no audit the band is Claude Code\'s own', async ($, on) => {diff --git a/plugins/seo-cockpit/tests/cockpit.test.ts b/plugins/seo-cockpit/tests/cockpit.test.tsindex 378e3d5..f8c1138 100644--- a/plugins/seo-cockpit/tests/cockpit.test.ts+++ b/plugins/seo-cockpit/tests/cockpit.test.ts@@ -1,4 +1,4 @@-import { describe, expect, test } from 'claude-code/testing'+import { describe, expect, mock, test } from 'claude-code/testing'import { command, worldOf } from './fixtures/world'@@ -10,7 +10,7 @@ describe('cockpit', () => {const opened: string[] = []on('ui.open', ($, e) => {- opened.push(e.id)+ opened.push(`${e.id}${e.focus === true ? ' focused' : ''}`)return { value: { isPlaced: true } } as never})@@ -20,7 +20,7 @@ describe('cockpit', () => {const result = await $.command.run(command('seo-cockpit'))const ui = await $.ui.mount({ ...PANE, surface: 'terminal' })- expect(opened).toEqual(['seo-cockpit'])+ expect(opened).toEqual(['seo-cockpit focused'])expect(result.text).toContain('pane open')expect(await ui.find({ type: 'Text', text: /Press r to load/ })).toBeDefined()expect(world.runs).toEqual([])@@ -33,7 +33,6 @@ describe('cockpit', () => {on('ui.open', () => ({ value: { isPlaced: false, reason: 'no pane here' } }) as never)on('session.cwd', () => ({ value: '/work' }))- on('fs.list', () => ({ value: [] }))on('fs.write', ($, e) => {written.push(e.path)@@ -46,4 +45,31 @@ describe('cockpit', () => {expect(written.length).toBe(1)expect(written[0]).toMatch(/^\/work\/seo-cockpit-.*\.html$/)})++ test('charts are text in the terminal and SVG on the desktop', async ($, on) => {+ const day = (i: number) => new Date(Date.UTC(2026, 6, 3) + i * 86_400_000).toISOString().slice(0, 10)+ const gsc = { property: 'sc-domain:a.com', error: null, rows: Array.from({ length: 60 }, (_, i) => ({ keys: [day(i)], date: day(i), query: 'q', clicks: i, impressions: 10 * i, ctr: 1, position: 5 })) }++ // runtime.py run <script> ...: the fixture keys on the subcommand, `run`.+ worldOf(on, { scripts: { run: { stdout: gsc } } })+ on('ui.open', () => ({ value: { isPlaced: true } }) as never)+ on('session.cwd', () => ({ value: '/work' }))+ on('store.get', () => ({ value: undefined }))+ on('store.set', () => ({ value: undefined }))+ on('ui.render', () => ({ type: 'Text', props: {}, children: ['engine'] }) as never)+ mock.clock(on)++ await $.command.run(command('seo-cockpit'))++ const terminal = await $.ui.mount({ ...PANE, surface: 'terminal' })++ await terminal.press({ key: 'refresh' })+ expect(await terminal.find({ type: 'Text', text: /Clicks per day/ })).toBeDefined()+ expect(await terminal.find({ type: 'Svg' })).toBeUndefined()+ await terminal.unmount()++ const desktop = await $.ui.mount({ ...PANE, surface: 'desktop' })++ expect(await desktop.find({ type: 'Svg' })).toBeDefined()+ })})