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
fix(action-center): show the measured result in an action's history (#1079)
Cihan9cedd514daa5
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 4f95b580f..1a3663ac5 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -716,7 +716,8 @@"task_ran": "{task} — carried out automatically ({tool})","task_run_failed": "{task} — the automatic attempt failed; it needs doing by hand","task_awaiting_approval": "{task} — waiting for your approval before it reaches outside Ansvisor",- "position_outcome_recorded": "{measurable, plural, =0 {30-day result: not enough data to compare positions} other {30-day result: position improved on {improved} of # platforms}}"+ "position_outcome_recorded": "{measurable, plural, =0 {30-day result: not enough data to compare positions} other {30-day result: position improved on {improved} of # platforms}}",+ "outcome_measured": "{outcome, select, improved {Result: metrics improved after this action closed} declined {Result: metrics declined after this action closed} no_meaningful_change {Result: no meaningful change in metrics after this action closed} not_measurable {Result: could not be measured} other {Result measured}}"},"taskText": "Task text","renameTask": "Rename task",diff --git a/web/src/components/action-center/action-drawer.tsx b/web/src/components/action-center/action-drawer.tsxindex 68a50b08d..e897c442c 100644--- a/web/src/components/action-center/action-drawer.tsx+++ b/web/src/components/action-center/action-drawer.tsx@@ -474,6 +474,9 @@ export function ActionDrawer({// A task someone added or renamed is named in their// own words, as they typed it.title: String(event.data.title ?? ''),+ // The validation sweep's verdict once the action+ // closed: improved, declined, and so on.+ outcome: String(event.data.outcome ?? ''),})}</p><p className="text-xs text-muted-foreground">diff --git a/web/src/lib/action-center/display.test.ts b/web/src/lib/action-center/display.test.tsindex dd7098926..5fab50f71 100644--- a/web/src/lib/action-center/display.test.ts+++ b/web/src/lib/action-center/display.test.ts@@ -1,4 +1,4 @@-import { readFileSync } from 'node:fs';+import { readdirSync, readFileSync } from 'node:fs';import { join } from 'node:path';import { createTranslator } from 'next-intl';import { describe, expect, it } from 'vitest';@@ -227,10 +227,11 @@ describe('eventTaskText', () => {});/**- * Every event the server actions write to an action's trail is a line in the- * drawer's History tab, and an event with no message there shows next-intl's- * missing-message text instead. The events are read from the server actions'- * own source, so one added there without copy fails here, not in the drawer.+ * Every event written to an action's trail is a line in the drawer's History+ * tab, and an event with no message there shows next-intl's missing-message+ * text instead. The events are read from the source that writes them — the+ * server actions and the Node server's Action Center engine — so one added+ * there without copy fails here, not in the drawer.*/describe('History events', () => {const source = readFileSync(join(__dirname, '../actions/action-center.ts'), 'utf8');@@ -238,6 +239,18 @@ describe('History events', () => {(match) => match[1],);+ // The engine writes through a `logEvent(actionId, 'event', …)` helper or+ // inserts the row itself with `event: 'event'`.+ const engineDir = join(__dirname, '../../../../server/src/lib/action-center');+ const written = readdirSync(engineDir, { recursive: true, encoding: 'utf8' })+ .filter((file) => file.endsWith('.js') && !file.endsWith('.test.js'))+ .flatMap((file) => [+ ...readFileSync(join(engineDir, file), 'utf8').matchAll(+ /logEvent\(\s*[\w.]+,\s*'(\w+)'|event: '(\w+)'/g,+ ),+ ])+ .map((match) => match[1] ?? match[2]);+const tPage = createTranslator({locale: 'en',messages,@@ -255,9 +268,10 @@ describe('History events', () => {improved: 1,measurable: 2,title: 'Ask the agency',+ outcome: 'improved',};- const eventText = (event: string) =>- tPage(`drawer.events.${event}` as Parameters<typeof tPage>[0], values);+ const eventText = (event: string, data: Partial<typeof values> = {}) =>+ tPage(`drawer.events.${event}` as Parameters<typeof tPage>[0], { ...values, ...data });/** A pattern that stopped matching would pass every check below by* checking nothing. */@@ -267,10 +281,43 @@ describe('History events', () => {);});- it.each(logged)('has a History line for %s', (event) => {+ it('reads the events the Node server writes', () => {+ expect(written).toEqual(+ expect.arrayContaining([+ 'created',+ 'signals_linked',+ 'task_ran',+ 'task_run_failed',+ 'task_awaiting_approval',+ 'position_outcome_recorded',+ 'outcome_measured',+ ]),+ );+ });++ it.each([...new Set([...logged, ...written])])('has a History line for %s', (event) => {expect(() => eventText(event)).not.toThrow();});+ /** The validation sweep records one of four verdicts, and each reads in+ * words — "after this action closed", never "because of it". */+ it.each([+ ['improved', 'Result: metrics improved after this action closed'],+ ['declined', 'Result: metrics declined after this action closed'],+ ['no_meaningful_change', 'Result: no meaningful change in metrics after this action closed'],+ ['not_measurable', 'Result: could not be measured'],+ ])('says what the measurement found: %s', (outcome, text) => {+ expect(eventText('outcome_measured', { outcome })).toBe(text);+ });++ /** A verdict this build has no words for still reads as a result. */+ it('reads an unknown or missing verdict as a plain result', () => {+ expect(eventText('outcome_measured', { outcome: 'pending_measurement' })).toBe(+ 'Result measured',+ );+ expect(eventText('outcome_measured', { outcome: '' })).toBe('Result measured');+ });+/** A task someone added or renamed is named as they typed it. */it('names the task in its own words', () => {expect(eventText('task_added')).toBe('Task added: “Ask the agency”');