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(action-center): give Check now its own rate bucket, its own words for each task it can't check, and show it only where the API checks (#1683)

Cihan58b313cae3a5
diff --git a/server/src/lib/action-center/task-checks.js b/server/src/lib/action-center/task-checks.js
index e82ab7ab6..5b05f9389 100644
--- a/server/src/lib/action-center/task-checks.js
+++ b/server/src/lib/action-center/task-checks.js
@@ -127,6 +127,19 @@ export function checkKind(task) {
return text(d.change?.after) ? 'text' : null;
}
+/**
+ * Why a task has no check here, by what it lacks, as Check now says it
+ * (en.json checkNot): no page, a written task with no new text to look
+ * for, or a library task checked elsewhere (a Site Audit fix, by the next
+ * audit).
+ */
+function uncheckable(task) {
+ const d = task.details ?? {};
+ if (d.check === 'auto' && !text(d.url)) return 'no_address';
+ if (d.check === 'auto' && !task.task_key) return 'no_change_text';
+ return 'not_checkable';
+}
+
/** A name's last label that is a file's, not a domain's: "pricing.html" is a page. */
const FILE_ENDINGS = new Set([
'html',
@@ -561,7 +574,7 @@ async function checkShoppingTask(task, action, { fetch, now }) {
*/
export async function runTaskCheck(read, action, { fetch = fetchPage, now = new Date() } = {}) {
const kind = checkKind(read);
- if (!kind) return { reason: 'not_checkable' };
+ if (!kind) return { reason: uncheckable(read) };
if (!OPEN.includes(read.status)) return { reason: 'not_open' };
if (kind === 'shoppingLinks') return checkShoppingTask(read, action, { fetch, now });
const d = read.details ?? {};
@@ -574,14 +587,14 @@ export async function runTaskCheck(read, action, { fetch = fetchPage, now = new
const task = { ...read, details: claim, updated_at: now.toISOString() };
const domains = await brandDomains(action.brand_id);
const url = pageAddress(d.url, storedHost(domains[0]));
- if (!url) return { reason: 'not_checkable' };
+ if (!url) return { reason: 'no_address' };
let auditChecks = [];
if (kind === 'structuredData' || kind === 'crawlers') {
auditChecks = await auditChecksFor(task.action_id, url);
// Raised from the bot logs (a cited page crawlers never read): robots.txt
// can't say it's fixed. Its try is kept (the claim), so the sweep goes on to others.
if (kind === 'crawlers' && !auditChecks.includes('ai-bot-access')) {
- return { reason: 'not_checkable' };
+ return { reason: 'from_bot_logs' };
}
}
diff --git a/server/src/lib/action-center/task-checks.test.js b/server/src/lib/action-center/task-checks.test.js
index 358b8416e..bf99fcfea 100644
--- a/server/src/lib/action-center/task-checks.test.js
+++ b/server/src/lib/action-center/task-checks.test.js
@@ -557,7 +557,7 @@ describe('runTaskCheck', () => {
// No address can be made: still tried.
const typed = task({ details: { check: 'auto', url: 'not an address' } });
const fetch = fetchOf({});
- expect(await runTaskCheck(typed, action, { fetch, now })).toEqual({ reason: 'not_checkable' });
+ expect(await runTaskCheck(typed, action, { fetch, now })).toEqual({ reason: 'no_address' });
expect(lastWrite().payload.details.autoCheck).toEqual({ triedAt: at });
expect(fetch).not.toHaveBeenCalled();
// Claimed by another run meanwhile (the task changed since it was read): left to it.
@@ -674,7 +674,7 @@ describe('runTaskCheck', () => {
const fetch = fetchOf({ [PAGE]: html('x') });
ops = [];
expect(await runTaskCheck(crawl, action, { fetch, now })).toEqual({
- reason: 'not_checkable',
+ reason: 'from_bot_logs',
});
expect(fetch).not.toHaveBeenCalled();
expect(lastWrite().payload.details.autoCheck).toEqual({
@@ -752,6 +752,19 @@ describe('runTaskCheck', () => {
expect(
await runTaskCheck(task({ task_key: 'fix_technical_issue' }), action, { fetch }),
).toEqual({ reason: 'not_checkable' });
+ // A written task with no new text, and a task with no page, each by its own reason (#1565 C8).
+ expect(
+ await runTaskCheck(
+ task({ task_key: null, details: { check: 'auto', url: '/pricing' } }),
+ action,
+ {
+ fetch,
+ },
+ ),
+ ).toEqual({ reason: 'no_change_text' });
+ expect(
+ await runTaskCheck(task({ details: { check: 'auto', url: '' } }), action, { fetch }),
+ ).toEqual({ reason: 'no_address' });
expect(await runTaskCheck(task({ status: 'completed' }), action, { fetch })).toEqual({
reason: 'not_open',
});
diff --git a/server/src/middleware/rate-limiter.js b/server/src/middleware/rate-limiter.js
index b780d0ff6..3b0a193fe 100644
--- a/server/src/middleware/rate-limiter.js
+++ b/server/src/middleware/rate-limiter.js
@@ -101,6 +101,20 @@ export const claimsLimiter = rateLimit({
},
});
+// Check now (AC-010): a task's page fetched again on a click, from a bucket
+// of its own, so it doesn't use up the editor's page reads (an AI-cost route).
+export const taskCheckLimiter = rateLimit({
+ windowMs: 15 * 60 * 1000,
+ max: 30,
+ keyGenerator: apiLimiterKey,
+ standardHeaders: true,
+ legacyHeaders: false,
+ message: {
+ success: false,
+ message: 'Too many requests, please try again later.',
+ },
+});
+
// Quality's page read (CE-049): the editor asks after saves, a minute apart
// at most, from a bucket of its own.
export const pageReadLimiter = rateLimit({
diff --git a/server/src/routes/action-center.js b/server/src/routes/action-center.js
index 1d4f6a96e..22ef4f3d8 100644
--- a/server/src/routes/action-center.js
+++ b/server/src/routes/action-center.js
@@ -22,7 +22,7 @@ import {
} from '../lib/action-center/from-traffic-pages.js';
import { sendContentDraftToActionCenter } from '../lib/action-center/from-content-draft.js';
import { runTaskCheck } from '../lib/action-center/task-checks.js';
-import { pageReadLimiter } from '../middleware/rate-limiter.js';
+import { taskCheckLimiter } from '../middleware/rate-limiter.js';
const router = Router();
@@ -247,7 +247,7 @@ export async function checkTaskNow(taskId, userId) {
}
/** POST /api/action-center/tasks/:id/check */
-router.post('/tasks/:id/check', pageReadLimiter, async (req, res) => {
+router.post('/tasks/:id/check', taskCheckLimiter, async (req, res) => {
const id = signalIdSchema.safeParse(req.params.id);
if (!id.success) return res.status(400).json({ error: 'Invalid task id' });
try {
diff --git a/web/messages/en.json b/web/messages/en.json
index 49d26f6c6..2cc67848b 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -1363,6 +1363,9 @@
"checkMissing": "Checked: {missing}",
"checkNot": {
"not_checkable": "This task isn't checked on its page: a Site Audit fix is checked by your next audit.",
+ "no_address": "This task's URL isn't a page's address. Edit it to a full address, or a path on the brand's site.",
+ "no_change_text": "This task has no new text to look for on the page. Add it under Change, or check the task yourself.",
+ "from_bot_logs": "This crawler fix came from your bot logs, and robots.txt can't show it's done. Mark it done once crawlers read the page.",
"not_open": "This task is already done or skipped.",
"no_answer": "Couldn't read the page. Try again later.",
"changed": "The task changed while it was checked. Try again.",
diff --git a/web/src/components/action-center/action-drawer.tsx b/web/src/components/action-center/action-drawer.tsx
index 375656c33..65b7262cb 100644
--- a/web/src/components/action-center/action-drawer.tsx
+++ b/web/src/components/action-center/action-drawer.tsx
@@ -92,6 +92,7 @@ import { contentEditorPath } from '@/lib/content/drafts';
import { RegenerateTasks, taskWriterEnabled } from './regenerate-tasks';
import {
hasTaskSpec,
+ pageCheckable,
withTemplateDoneWhen,
withoutTemplateDoneWhen,
type TaskDetailsEdit,
@@ -732,11 +733,10 @@ export function ActionDrawer({
webhook: webhookReady,
onSend: (to) => void sendTask(task.id, taskText(task, tTasks), to),
}}
- // An open task checked automatically, with its page (AC-010).
+ // An open task the API checks on its page (AC-010).
check={
(task.status === 'todo' || task.status === 'in_progress') &&
- task.details?.check === 'auto' &&
- task.details.url
+ pageCheckable(task, action.kind)
? { onCheck: () => void checkTask(task.id), busy: checking === task.id }
: undefined
}
diff --git a/web/src/lib/action-center/task-details.test.ts b/web/src/lib/action-center/task-details.test.ts
index 05bf0ebd3..20dcebd83 100644
--- a/web/src/lib/action-center/task-details.test.ts
+++ b/web/src/lib/action-center/task-details.test.ts
@@ -1,5 +1,10 @@
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
import {
+ PAGE_CHECKED_TASKS,
+ pageCheckable,
+ type ActionTaskDetails,
TASK_DETAIL_LIMITS,
cleanTaskDetailsEdit,
isTaskDetailsEdit,
@@ -298,3 +303,42 @@ describe('where a task was sent', () => {
).toEqual({ content: null, webhook: null });
});
});
+
+describe('pageCheckable', () => {
+ const auto = (over: Partial<ActionTaskDetails> = {}) =>
+ ({ check: 'auto', url: '/pricing', change: null, ...over }) as ActionTaskDetails;
+
+ it('checks a library task the API reads on its page, or a written one with its new text', () => {
+ expect(pageCheckable({ taskKey: 'refresh_content', details: auto() })).toBe(true);
+ expect(
+ pageCheckable({ taskKey: null, details: auto({ change: { before: null, after: 'New' } }) }),
+ ).toBe(true);
+ });
+
+ it('leaves out a Site Audit fix, a written task without new text, and a task with no page', () => {
+ expect(pageCheckable({ taskKey: 'fix_meta_description', details: auto() })).toBe(false);
+ expect(pageCheckable({ taskKey: null, details: auto() })).toBe(false);
+ expect(pageCheckable({ taskKey: 'refresh_content', details: auto({ url: ' ' }) })).toBe(false);
+ expect(pageCheckable({ taskKey: 'refresh_content', details: auto({ check: 'manual' }) })).toBe(
+ false,
+ );
+ });
+
+ it('keeps Check now on a shopping links task, which has no new text (#1616)', () => {
+ expect(pageCheckable({ taskKey: null, details: auto() }, 'shopping_links')).toBe(true);
+ expect(pageCheckable({ taskKey: null, details: auto() }, 'content_draft')).toBe(false);
+ expect(
+ pageCheckable({ taskKey: null, details: auto({ check: 'manual' }) }, 'shopping_links'),
+ ).toBe(false);
+ });
+
+ it("lists the API's checked tasks, no more and no fewer", () => {
+ const server = readFileSync(
+ join(__dirname, '../../../../server/src/lib/action-center/task-checks.js'),
+ 'utf8',
+ );
+ const block = server.match(/export const CHECKS = Object\.freeze\(\{([^}]*)\}\)/)![1];
+ const keys = [...block.matchAll(/^\s*([a-z_]+):/gm)].map((m) => m[1]);
+ expect([...PAGE_CHECKED_TASKS].sort()).toEqual(keys.sort());
+ });
+});
diff --git a/web/src/lib/action-center/task-details.ts b/web/src/lib/action-center/task-details.ts
index 4094224a7..97f964f7b 100644
--- a/web/src/lib/action-center/task-details.ts
+++ b/web/src/lib/action-center/task-details.ts
@@ -280,3 +280,40 @@ export function cleanTaskDetailsEdit(
role: clip(edit.role, TASK_DETAIL_LIMITS.role),
};
}
+
+/**
+ * The library tasks the API checks on their page (AC-010): its CHECKS'
+ * keys (server/src/lib/action-center/task-checks.js). Change both together.
+ */
+export const PAGE_CHECKED_TASKS: readonly string[] = [
+ 'publish_content',
+ 'fix_broken_target',
+ 'fix_structured_data',
+ 'fix_crawler_access',
+ 'optimize_content',
+ 'refresh_content',
+ 'strengthen_reference_asset',
+ 'strengthen_entity_content',
+ 'improve_cta_path',
+];
+
+/**
+ * Whether Check now can check a task here, as the API's checkKind reads it:
+ * checked Automatic, with a page, and a library task it checks on its page
+ * or a written one with its new text. A Site Audit fix is checked by the
+ * next audit instead. A shopping links action's task (`actionKind`
+ * 'shopping_links') is checked on its draft by the shopping check, with no
+ * new text to look for.
+ */
+export function pageCheckable(
+ task: {
+ taskKey: string | null;
+ details: ActionTaskDetails | null;
+ },
+ actionKind?: string,
+): boolean {
+ const d = task.details;
+ if (d?.check !== 'auto' || !d.url?.trim()) return false;
+ if (task.taskKey) return PAGE_CHECKED_TASKS.includes(task.taskKey);
+ return actionKind === 'shopping_links' || Boolean(d.change?.after);
+}