Skip to content

feat(action-center): give the Action Center's own tasks their Done when, how they're checked and their page (AC-010, part 3) - #1564

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/ac-010-template-fields
Oct 27, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/ac-010-template-fields

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

AC-010 ("Done when" on every task), part 3 of 4: the Action Center's own tasks get Done when, How we check and their page.

Stacked on #1561 (it uses the fields #1561 adds). Independent of #1562.

The nightly engine's library tasks are the ones people see today. They carry no details: only a title from their template. As decided for the rollout, they now get their AC-010 fields from that template and stay visible. Part 2's review queue is for agent-written tasks only.

How we check, and the page (server/.../tasks/templates.js), written into a library task's details when it's planned:

  • auto: the page is fetched again, or a Site Audit runs. For the 12 tasks that change a page: optimize, refresh, strengthen, internal links, CTA, publish, the crawler/structured-data/broken-page/technical fixes and their re-check.
  • rerun: the prompts run again. For the 9 visibility, mention, citation, share-of-voice, platform, country, competitor and third-party-citation checks, and the outcome measure.
  • manual: the person confirms. For the 7 brief, draft, outreach, contribution and third-party-status tasks.
  • Excluded:
    • the three tasks measured from a data window (GA4 key events, Search Console clicks, AI-referred visits), because none of the three checks fits them;
    • the analysis Ansvisor does itself, which the task writer drops anyway.
  • URL, for a task that changes a page, when the action is about exactly one page:
    • a sent action's one page, as a full URL (a draft's, an opportunity's, a traffic page's);
    • otherwise a page target counted once (a full URL, or a path from the traffic signals).
    • Never the whole-site sentinel (site).
    • Never an opportunity with a new page among its assets: its one existing page isn't the new page's.
    • The internal-links task gets none, since its links go on other pages.
  • The details are marked source: 'template'.
  • A test keeps the list whole: every task a person or an agent does, and every validation but the data-window ones, has a check.

Done when, in the reader's language (web/messages/en.json, actionCenter.taskDoneWhen.<task key>).

  • It's product copy, as a library task's title is, so it isn't stored with the row.
  • withTemplateDoneWhen gives a library task its template's Done when until someone writes one. The drawer, the exports (Copy Data, CSV, Excel) and MCP get_action (in English) read it there.
  • So the tasks of existing actions show their Done when too.
  • Saving the task's form with the template's Done when unchanged keeps it the template's (withoutTemplateDoneWhen), as an unchanged title does. It isn't stored as the person's English text.
  • A server test checks that every task with a check has its sentence in en.json, and that no sentence names a task that doesn't exist.
  • The sentences say what each task closes on. Optimize and refresh also close when their draft is marked ready in the Content Editor, as CE-022 completes them. The validations read "above the baseline", as validate.js counts improvement.

Wiring.

  • planTasks adds each task's details, and the seven places that write library tasks (generate.js and the from-*.js sent kinds) write them.
  • No migration: details is the jsonb from 00121.

The task writer still writes over untouched plans.

  • Until now, any details on a library task made the plan "touched", which would have stopped the nightly writer on every new action.
  • isTouched now reads a template's details as no one's work, unless the task was sent (details.sent).
  • An edit in the drawer drops the template mark (updateTaskDetails), so an edited task counts as the person's, as before.

Not here.

  • Tasks of existing actions get no check or URL until they're planned again; they show their Done when.
  • The action_task.sent webhook still sends done_when only for a task that has its own.
  • Part 4 adds the automatic checks.

Related issue

AC-010 (roadmap), part 3 of 4. Stacked on #1561.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd server && npx vitest run src/lib/action-center/tasks src/lib/action-center/generate.test.js src/lib/action-center/task-writer/index.test.js
  2. cd web && yarn vitest run src/lib/actions/task-details-edit.test.ts
  3. On a local stack, let the nightly generator create an action, or create one from Content (Send to Action Center). Its tasks show Done when and How we check, plus the URL on a one-page action.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run: server npm run format, npm run lint, npm test (226 files, 2,901 tests); web yarn test (427 files, 4,091 tests) and yarn build, all pass.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 26, 2026 21:37
…d how we check it, and have the task writer fill them (AC-010)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…en, how they're checked and their page (AC-010, part 3)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 880cd08.

Approve preview

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups.
It merges with #1561 and #1562 once 00293 is fixed (#1562's review), so the series goes out together.

What I checked:

  • Own change. origin/pr/1561..origin/pr/1564, one commit. That covers templates.js, planTasks, the seven writers, isTouched, the drawer, the exports, MCP get_action, updateTaskDetails, en.json and the docs.
  • The page each sender puts in. It comes from the action's own payload, and only from data the brand already has:
    • an opportunity's asset pages come from the brand's site_pages;
    • a draft's is its source_url (http(s), at most 2,048 characters, which 00207 checks);
    • a traffic page's is the primary domain plus the path from ai_traffic_pages.
    • Topic gaps, topic opportunities and mentions target prompts, so they get no URL.
    • An opportunity that has a new page, or an earned asset, among its assets gets none either. Earned assets are stored with decision: 'create'.
    • site never passes PAGE_ADDRESS.
  • On prod:
    • About 80 of roughly 800 open actions are about one page.
    • 57 actions have a single full-URL page target. All of them are on a brand domain, and the longest is 256 characters.
  • Existing tasks. Nothing is backfilled or re-planned, so nothing is duplicated:
    • generate.js only adds details to the insert, and dedup_key stays definition.id.
    • title_params doesn't change, so the counts that 00244/00245's action_count_drift read don't move.
    • No SQL function reads action_tasks.details.
  • The task writer.
    • isTouched reads source: 'template' as untouched unless details.sent is set. markSent merges into the details, so a sent task keeps its mark and counts as touched.
    • keepsTask still replaces an untouched library task.
    • An edit in the drawer drops source, and the undefined key isn't written.
    • updateTaskDetails is the only code path that writes a library task's details.
  • Webhook and exports. Every change adds data and renames nothing:
    • action_task.sent already had url and check (#1561). For a library task they now carry values.
    • Copy Data, CSV and Excel keep their columns; Done when gets filled from the template.
    • In MCP get_action, a library task's details can now be an object where it was null.
  • Speed. PAGE_ADDRESS is anchored, and its two alternatives start differently. On 100 KB inputs it runs in under 0.5 ms. The other new loops go over arrays that are already bounded.
  • Tests. I put #1561's source back under this branch's tests, and four of them fail: the plan, generate, from-traffic-pages and isTouched cases. The web tests call functions and fields that don't exist without the change. All of the PR's server and web tests pass on the head.
  • Merge.
    • Through a temp base, #1561 squashed onto main (main's tree, parents 83f7588 and main), it merges clean. The result equals the PR's own diff, and CI passes.
    • With #1562 merged first, web/messages/en.json conflicts: both add a block after actionTasks. Keep both, reviewPage and then taskDoneWhen. task-writer/index.js, its test and the docs merge on their own.
  • Before and after the API deploy.
    • The web part goes out on merge. Every library task with a template shows its Done when right away, existing ones included: in the drawer, in Copy Data, CSV and Excel, and in MCP.
    • The old API writes no details, so new tasks show only that.
    • Once the API is deployed, new library tasks also show How we check, plus the URL on a one-page action.
    • Nothing checks a task automatically until part 4. A task still closes by hand, or through a draft marked ready or a publish, as today.

Follow-ups:

  1. Internal links on F10 (server/src/lib/action-center/tasks/templates.js:28, web/messages/en.json:2385).
    • F10 (fix_internal_connectivity) comes from Site Audit's Internal linking check. That check counts the links on the audited page itself (audit/signals/structure.js:61-77, classifyLinks), so F10's links go on that page.
    • The template gives the task no URL, and its Done when ("The pages that should link to it do") points the other way. All 3 open F10 actions are one-page.
    • The task's title already says "Add internal links around {targets}". Give it the action's page and a Done when that reads both ways:
      add_internal_links: { check: 'auto', page: true },
      "add_internal_links": "The page links to related pages, and the pages that should link to it do, fetched again"
    • On an opportunity's one optimized page, the links also go around that page, so the URL fits there too. The templates test's "a link task none" case changes with it.
  2. "Automatic" with no page to fetch (templates.js:22-34, :93).
    • About 9 actions in 10 aren't about one page. Their page-change tasks will read "How we check: Automatic: we fetch the page again" with no URL, and no check can fetch anything for them.
    • Write auto on the page-fetch tasks only when there's a URL, and manual otherwise. The two that a Site Audit checks (fix_technical_issue, validate_technical_fix) keep auto.
      /** Checked by a new Site Audit, which needs no one page. */
      const SITE_AUDIT = new Set(['fix_technical_issue', 'validate_technical_fix']);
      const url = template.page ? onePage(payload) : null;
      const check =
        template.check === 'auto' && !url && !SITE_AUDIT.has(taskKey) ? 'manual' : template.check;
    • Or keep auto, and have part 4 report "no page to fetch" for these tasks. Either way, say which one in the PR.
  3. The outcome task isn't a re-run (templates.js:45, en.json:2401).
    • validate.js measures measure_action_outcome over the window after the action closes, on the action's KPIs.
    • For an action raised from traffic signals, or sent from AI Traffic's Pages, those KPIs include AI-referred visits (ai_referral_traffic), which no prompt run measures.
    • Treat it like the three window tasks: no check, and a Done when that names no KPI, e.g. "Measured over the days after the action closes, against its baseline". The docs line's exception then also covers AI visits (docs/guides/action-center.mdx:84).
  4. onePage guards (templates.js:70-82).
    • Accept a full URL only on one of the brand's domains, with ownDomainMatcher as task-send.js does. Load the domains once per brand in generateActionsForBrand.
      • Site Audit takes any address, and the nightly audit signals read every page the brand has audited. So one low-scoring page from another site could become a fix task's URL.
      • None does on prod today.
    • Return null when payload.contentExists === false. MCP accepts a source_url on a create draft, and that page would become the URL on publish_content.
    • Don't count an earned asset as a new page (a?.decision === 'create' && a?.channel !== 'earned'). An owned page plus an earned asset then keeps the owned page's URL.
    • Drop an address longer than 500 characters, the drawer's TASK_DETAIL_LIMITS.url, rather than storing it.
  5. The webhook's Done when (server/src/lib/action-center/task-send.js:319).
    • The drawer, the exports and MCP show the template's Done when, but action_task.sent sends done_when: null for the same task.
    • Have the web send the Done when it shows along with title, and use it when the task has none of its own.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups.
It merges with #1561 and #1562 once 00293 is fixed (#1562's review), so the series goes out together.

What I checked:

  • Own change. origin/pr/1561..origin/pr/1564, one commit. That covers templates.js, planTasks, the seven writers, isTouched, the drawer, the exports, MCP get_action, updateTaskDetails, en.json and the docs.
  • The page each sender puts in. It comes from the action's own payload, and only from data the brand already has:
    • an opportunity's asset pages come from the brand's site_pages;
    • a draft's is its source_url (http(s), at most 2,048 characters, which 00207 checks);
    • a traffic page's is the primary domain plus the path from ai_traffic_pages.
    • Topic gaps, topic opportunities and mentions target prompts, so they get no URL.
    • An opportunity that has a new page, or an earned asset, among its assets gets none either. Earned assets are stored with decision: 'create'.
    • site never passes PAGE_ADDRESS.
  • On prod:
    • About 80 of roughly 800 open actions are about one page.
    • 57 actions have a single full-URL page target. All of them are on a brand domain, and the longest is 256 characters.
  • Existing tasks. Nothing is backfilled or re-planned, so nothing is duplicated:
    • generate.js only adds details to the insert, and dedup_key stays definition.id.
    • title_params doesn't change, so the counts that 00244/00245's action_count_drift read don't move.
    • No SQL function reads action_tasks.details.
  • The task writer.
    • isTouched reads source: 'template' as untouched unless details.sent is set. markSent merges into the details, so a sent task keeps its mark and counts as touched.
    • keepsTask still replaces an untouched library task.
    • An edit in the drawer drops source, and the undefined key isn't written.
    • updateTaskDetails is the only code path that writes a library task's details.
  • Webhook and exports. Every change adds data and renames nothing:
    • action_task.sent already had url and check (#1561). For a library task they now carry values.
    • Copy Data, CSV and Excel keep their columns; Done when gets filled from the template.
    • In MCP get_action, a library task's details can now be an object where it was null.
  • Speed. PAGE_ADDRESS is anchored, and its two alternatives start differently. On 100 KB inputs it runs in under 0.5 ms. The other new loops go over arrays that are already bounded.
  • Tests. I put #1561's source back under this branch's tests, and four of them fail: the plan, generate, from-traffic-pages and isTouched cases. The web tests call functions and fields that don't exist without the change. All of the PR's server and web tests pass on the head.
  • Merge.
    • Through a temp base, #1561 squashed onto main (main's tree, parents 83f7588 and main), it merges clean. The result equals the PR's own diff, and CI passes.
    • With #1562 merged first, web/messages/en.json conflicts: both add a block after actionTasks. Keep both, reviewPage and then taskDoneWhen. task-writer/index.js, its test and the docs merge on their own.
  • Before and after the API deploy.
    • The web part goes out on merge. Every library task with a template shows its Done when right away, existing ones included: in the drawer, in Copy Data, CSV and Excel, and in MCP.
    • The old API writes no details, so new tasks show only that.
    • Once the API is deployed, new library tasks also show How we check, plus the URL on a one-page action.
    • Nothing checks a task automatically until part 4. A task still closes by hand, or through a draft marked ready or a publish, as today.

Follow-ups:

  1. Internal links on F10 (server/src/lib/action-center/tasks/templates.js:28, web/messages/en.json:2385).
    • F10 (fix_internal_connectivity) comes from Site Audit's Internal linking check. That check counts the links on the audited page itself (audit/signals/structure.js:61-77, classifyLinks), so F10's links go on that page.
    • The template gives the task no URL, and its Done when ("The pages that should link to it do") points the other way. All 3 open F10 actions are one-page.
    • The task's title already says "Add internal links around {targets}". Give it the action's page and a Done when that reads both ways:
      add_internal_links: { check: 'auto', page: true },
      "add_internal_links": "The page links to related pages, and the pages that should link to it do, fetched again"
    • On an opportunity's one optimized page, the links also go around that page, so the URL fits there too. The templates test's "a link task none" case changes with it.
  2. "Automatic" with no page to fetch (templates.js:22-34, :93).
    • About 9 actions in 10 aren't about one page. Their page-change tasks will read "How we check: Automatic: we fetch the page again" with no URL, and no check can fetch anything for them.
    • Write auto on the page-fetch tasks only when there's a URL, and manual otherwise. The two that a Site Audit checks (fix_technical_issue, validate_technical_fix) keep auto.
      /** Checked by a new Site Audit, which needs no one page. */
      const SITE_AUDIT = new Set(['fix_technical_issue', 'validate_technical_fix']);
      const url = template.page ? onePage(payload) : null;
      const check =
        template.check === 'auto' && !url && !SITE_AUDIT.has(taskKey) ? 'manual' : template.check;
    • Or keep auto, and have part 4 report "no page to fetch" for these tasks. Either way, say which one in the PR.
  3. The outcome task isn't a re-run (templates.js:45, en.json:2401).
    • validate.js measures measure_action_outcome over the window after the action closes, on the action's KPIs.
    • For an action raised from traffic signals, or sent from AI Traffic's Pages, those KPIs include AI-referred visits (ai_referral_traffic), which no prompt run measures.
    • Treat it like the three window tasks: no check, and a Done when that names no KPI, e.g. "Measured over the days after the action closes, against its baseline". The docs line's exception then also covers AI visits (docs/guides/action-center.mdx:84).
  4. onePage guards (templates.js:70-82).
    • Accept a full URL only on one of the brand's domains, with ownDomainMatcher as task-send.js does. Load the domains once per brand in generateActionsForBrand.
      • Site Audit takes any address, and the nightly audit signals read every page the brand has audited. So one low-scoring page from another site could become a fix task's URL.
      • None does on prod today.
    • Return null when payload.contentExists === false. MCP accepts a source_url on a create draft, and that page would become the URL on publish_content.
    • Don't count an earned asset as a new page (a?.decision === 'create' && a?.channel !== 'earned'). An owned page plus an earned asset then keeps the owned page's URL.
    • Drop an address longer than 500 characters, the drawer's TASK_DETAIL_LIMITS.url, rather than storing it.
  5. The webhook's Done when (server/src/lib/action-center/task-send.js:319).
    • The drawer, the exports and MCP show the template's Done when, but action_task.sent sends done_when: null for the same task.
    • Have the web send the Done when it shows along with title, and use it when the task has none of its own.

@gkhngyk
gkhngyk merged commit 55b49e7 into ansvisor:main Oct 27, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants