Skip to content

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.

feat(seo-cockpit): fall back to the last site used when a folder shows none

Agrici Danielca646db9252a
diff --git a/plugins/seo-cockpit/hooks/register.ts b/plugins/seo-cockpit/hooks/register.ts
index c713582..c5636f5 100644
--- a/plugins/seo-cockpit/hooks/register.ts
+++ b/plugins/seo-cockpit/hooks/register.ts
@@ -381,10 +381,21 @@ async function resolveHost($: EngineInterface, ctx: Ctx): Promise<void> {
}
const setting = ctx.pageUrl || ctx.site
- const host = chooseTarget(setting, ctx.typed, inferred)
+ let host = chooseTarget(setting, ctx.typed, inferred)
+ let source: PaneState['hostSource'] = host === null ? null : hostOf(setting) !== null ? 'setting' : ctx.typed !== null && hostOf(ctx.typed) !== null ? 'typed' : 'folder'
+
+ // Nothing here says which site: use the last one seen anywhere, and say so.
+ if (host === null) {
+ const last = await $.store.get('target:last').catch(() => undefined)
+
+ host = typeof last === 'string' ? hostOf(last) : null
+ source = host === null ? null : 'last'
+ } else {
+ void $.store.set('target:last', host).catch(() => undefined)
+ }
ctx.pane.host = host
- ctx.pane.hostSource = host === null ? null : hostOf(setting) !== null ? 'setting' : ctx.typed !== null && hostOf(ctx.typed) !== null ? 'typed' : 'folder'
+ ctx.pane.hostSource = source
}
/** Builds one source's model from claude-seo's own scripts and files. Free: no paid API is called. */
diff --git a/plugins/seo-cockpit/hooks/views/pane.ts b/plugins/seo-cockpit/hooks/views/pane.ts
index 3d97eef..baec4d2 100644
--- a/plugins/seo-cockpit/hooks/views/pane.ts
+++ b/plugins/seo-cockpit/hooks/views/pane.ts
@@ -29,7 +29,7 @@ export type PaneState = {
loading: ReadonlySet<TabId>
/** The site the cockpit is about, and where that came from. */
host: string | null
- hostSource: 'setting' | 'typed' | 'folder' | null
+ hostSource: 'setting' | 'typed' | 'folder' | 'last' | null
/** The last HTML export, as a file path. */
exported: string | null
}
@@ -129,14 +129,15 @@ function footer(kit: Kit, state: PaneState, isFocused: boolean, actions: PaneAct
/** The Overview: which site, then one line per source; missing data stays visible with its fix. */
export function overviewView(kit: Kit, state: PaneState, columns: number, isFocused: boolean, actions: PaneActions): RenderElement {
const { Box, Text, Button } = kit
- const where = { setting: 'from /config', typed: 'typed here', folder: 'from this folder', none: '' }[state.hostSource ?? 'none']
+ const where = { setting: 'from /config', typed: 'typed here', folder: 'from this folder', last: 'last used', none: '' }[state.hostSource ?? 'none']
const children: RenderElement[] = [
// Row 1 carries no controls: the engine draws its close mark at the right edge.
Text({ children: [Text({ bold: true, children: [cut(state.host ?? 'No site yet', Math.max(10, columns - 24))] }), Text({ dimColor: true, children: [where === '' ? '' : ` ${where}`] })] }),
]
- if (state.host === null && kit.Input !== undefined) {
- children.push(kit.Input({ key: 'target', label: 'Site', placeholder: 'example.com', submitLabel: 'go', autoFocus: true, onSubmit: value => actions.setTarget(value) }))
+ // No site, or only the last one used elsewhere: offer the field to set this folder's own.
+ if ((state.host === null || state.hostSource === 'last') && kit.Input !== undefined) {
+ children.push(kit.Input({ key: 'target', label: 'Site', placeholder: state.host ?? 'example.com', submitLabel: 'go', ...(state.host === null && { autoFocus: true }), onSubmit: value => actions.setTarget(value) }))
}
const labelWidth = Math.max(...ROWS.map(row => row.label.length))
diff --git a/plugins/seo-cockpit/tests/cockpit.test.ts b/plugins/seo-cockpit/tests/cockpit.test.ts
index 992b7bb..08a643b 100644
--- a/plugins/seo-cockpit/tests/cockpit.test.ts
+++ b/plugins/seo-cockpit/tests/cockpit.test.ts
@@ -78,6 +78,24 @@ describe('cockpit', () => {
expect(await ui.find({ key: 'target' })).toBeDefined()
})
+ test('in a folder with no audit, the last site used anywhere is shown, and can be changed', async ($, on) => {
+ worldOf(on)
+ on('session.cwd', () => ({ value: '/elsewhere' }))
+ on('store.get', ($, e) => ({ value: e.key === 'target:last' ? 'claude-seo.md' : undefined }))
+ on('store.set', () => ({ value: undefined }))
+ on('ui.status', () => ({ value: undefined }))
+ on('ui.open', () => ({ value: { isPlaced: true } }) as never)
+ on('ui.render', () => ({ type: 'Text', props: {}, children: ['engine'] }) as never)
+ mock.clock(on)
+
+ expect((await $.command.run(command('seo-cockpit'))).text).toBe('Cockpit open for claude-seo.md.')
+
+ const ui = await $.ui.mount({ ...NARROW, surface: 'terminal' })
+
+ expect(await ui.find({ type: 'Text', text: /last used/ })).toBeDefined()
+ expect(await ui.find({ key: 'target' })).toBeDefined()
+ })
+
test('with no pane on screen, it writes the HTML dashboard instead', async ($, on) => {
worldOf(on)