Skip to content

feat(action-center): send a page from its Site Audit report to the Action Center (learning D2) - #1709

Merged
gkhngyk merged 11 commits into
ansvisor:mainfrom
cihan-gyk:feature/audit-to-action-center
Oct 28, 2026
Merged

gkhngyk merged 11 commits into
ansvisor:mainfrom
cihan-gyk:feature/audit-to-action-center

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Learning D2: send a page from its Site Audit report straight to the Action Center. Until now a report showed what a page fails, but the only way into the Action Center was the nightly pass, a day later and grouped with other pages.

  • Server (lib/action-center/from-audit.js, POST /api/action-center/audits { brandId, auditId }): the audit is read again within the brand (completed, its page and score) with its failing checks (a fail, and a warning for JSON-LD validity only, as the page check reads them) and their Site Audit names. One Fix action a page (deduped on the page; an open one is returned instead), high impact below the low-score line, F01's task plan, the page and its checks as the target (what a re-audit reads), measured on the page, scored as a site fix. 404 for another brand's audit, 409 not_completed / nothing_to_fix, and 409 newer_audit (with the newer audit's id) when the page has been audited since, so an old report can't open an action for checks that already pass. Two sends at once settle on one action (23505).
  • Web: "Send to Action Center" in the report's header once it fails a check; the toast opens the action (or the one already open), or links to the latest report on newer_audit. The action drawer shows the report link, the page and the checks that failed when it was sent (AuditPageContext). audit_page joins the action kinds.
  • Docs: Site Audit and Action Center guides (how the action is judged: by the page audited again after it closes, through A2, already on main).

Related issue

None (agentic learning, Phase D).

Type of change

  • feat — New feature

How to test

  1. Open Site Audit, a completed report with failing checks: "Send to Action Center" is in the header.
  2. Click it: a toast with the action's AC number and Open; the action has the page, the failing checks and a link back to the report.
  3. Click it again: "Already in the Action Center" with Open, no second action.
  4. Audit the same page again, then send from the OLD report: "This page has a newer audit" with Open the latest report.
  5. A report with nothing failing shows no button.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • Server: npm run lint, npm test (263 files, 3,643 tests) pass
  • Web: yarn lint (0 errors), yarn typecheck, yarn build pass; yarn test 475 of 477 files pass — the two others (Content Editor page, Library) time out under a loaded machine and pass alone with a longer timeout; this PR touches neither
  • Tests added (from-audit, the route, the drawer context, the report's send)
  • Screenshot: in the batched local test session
  • npm run version:check (fails on main too: docker-compose images 0.2.0)

🤖 Generated with Claude Code

cihan-gyk and others added 8 commits October 28, 2026 11:42
…tion Center as a Fix action

Learning D2. A Site Audit report showed what a page fails, but the only way
to the Action Center was the nightly pass, a day later and grouped with
other pages. A person can now send the page from its report at once.

- server from-audit.js: the audit read again within the brand (completed,
  its page and score), its failing checks (a fail, and a warning for
  JSON-LD validity only, as the page check reads them) with their names;
  one Fix action a page (dedup on the page), impact high below the
  low-score line, F01's plan, the page and its checks as its target (what
  an audit run again reads), measured on the page (basket kinds), scored
  as a site fix (priority sentByHand). 404 for another brand's audit, 409
  not completed or nothing to fix.
- POST /api/action-center/audits { brandId, auditId }.
- Web: "Send to Action Center" on the report's header once it fails a
  check, with a toast that opens the action (or the one already open);
  audit_page joins the action kinds ("Fix the issues Site Audit found on
  /path", "the page fails N checks"), its no-signals note in the drawer.
- Docs: the Site Audit and Action Center guides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion-center

# Conflicts:
#	server/src/lib/action-center/priority.test.js
#	web/messages/en.json
#	web/src/components/action-center/action-drawer.tsx
#	web/src/lib/action-center/display.test.ts
…ction sent from Site Audit

An audit_page action's drawer only said it had no detection signals, so the
person had to find the report again to see what to fix. Its Overview tab
now shows where it came from with a link to the audit report, the page, and
the checks it failed when sent, named by the labels Site Audit gave them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ge audited since

A report stays open at its own URL after the page is audited again, and
sending it named the checks the page failed then, some of them maybe fixed
since. The server now looks for a later completed audit of the same page
(the Pages list's page key of final_url, else url) and refuses with 409
newer_audit and the latest audit's id; the report's toast says so and opens
the latest report.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o the Action Center

POST /api/action-center/audits had no route test. It now pins what the
route lets through and how it answers: 400 for an invalid id, 403
not_in_workspace, 201 created and 200 already open, 404, and 409
nothing_to_fix, not_completed and newer_audit with the page's latest audit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… explains it

- Site Audit guide: the paragraph on sending one page moves from after the
  closing card into "How audits feed the Action Center". It says the action
  is judged like a nightly Site Audit fix, by the page audited again since
  it closed (learning A2, ansvisor#1689, on main), and by its metrics until then.
- The report's section says what a second send does (a notice naming the
  open action with Open, not the action opened) and that only a page's
  latest report can be sent.
- Action Center guide: the two Site Audit rows of "Sending work to the
  Action Center" become one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ot-applicable check for a Site Audit send

The test's brand had no Site Audit source, so F01's analyze_site_audit and
validate_technical_fix left the plan and the test, checking only that some
task was planned, didn't notice. Its brand now has its audits and the test
names the five tasks in order. It also covers two sends at once (the
insert refused by the open-action index returns the other send's action;
another refusal fails) and a check that is not applicable to the page,
which is neither sent nor enough to send.

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

mintlify Bot commented Oct 28, 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 1c76943.

Approve preview

cihan-gyk and others added 2 commits October 28, 2026 20:26
…hich the route file now uses

The Products route (ansvisor#1642) guards itself with requireFeature, so the router doesn't load in a test whose plan-guard mock has none. The audits route test gets the same pass-through stub as the pages and content-drafts tests on main.

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

Copy link
Copy Markdown
Collaborator Author

Merged main (cfd8a35): audit_page sits beside the new shopping_product/shopping_category kinds (validate.js, routes, 73 kinds), and the audits route test now stubs requireFeature like main's sibling tests.

@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

Sending a page from its Site Audit report reads the audit again on the server within the brand, refuses an older report of a page audited since, and returns the open action on a second send, including when two sends arrive at once. The action then works with what is already on main: the re-audit check (A2), the page task check and the basket measurement all read payload.targets[].checks and payload.pages, and this payload has both.

What I checked

  • Access. POST /api/action-center/audits validates both ids, runs assertBrandAccess before any read, and reads the audit with .eq('brand_id', brandId), so another brand's audit gets a 404. Any member can send, as with the other "Send to Action Center" routes. It is a POST, so a read-only workspace is refused by the subscription middleware before it reaches the route, and the web shows that refusal's message in the toast.
  • What is sent. The failing checks come from audit_signal_results, not from the client. The server's failing() and the web's failingChecks() match each other and match the inverse of passes() in audit-recheck.js (a fail, or a warning on JSON-LD validity only). nothing_to_fix, not_completed and newer_audit (with latestAuditId) reach the toast with their codes.
  • Dedup. The key is audit_page:<opportunityKey(url)>, under actions_active_dedup_idx (00084). An open action is returned with a 200. When two sends race, the loser gets a 23505 and re-reads the winner's action.
  • Judging and measuring. audit_page was added to the basket kinds in validate.js (citations and AI-referred sessions on the page). auditRecheck is not tied to a kind, so a closed action is judged by the page's next audit. priority.js scores it as a person-sent site fix. The task writer treats it like the other sent kinds.
  • Web. The button shows only on a completed report with something failing. The toasts cover created, already open, a newer audit (with "Open the latest report") and other refusals. The drawer's AuditPageContext reads the payload defensively. ACTION_KINDS grew to 73 and display copy was added. The English copy reads well.
  • Docs. The Site Audit and Action Center guides match the behaviour.
  • Merge. Merges clean on 2391b43 (#1710). No migrations.
  • Tests. Server: the five touched suites pass (100 tests), and the full suite passes (269 files, 3,725 tests). Web: the four new or touched test files pass (213 tests), as do the audit and action-center folders (34 files). tsc --noEmit is clean. ESLint shows 0 errors (one existing warning in the report page). Prettier is clean on the touched code files.

Follow-ups (not blocking)

  1. newerAuditOf uses readAllRpcRows to read every completed audit of the brand newer than the report, then matches the page in JS. On an older report of a brand with scheduled audits, one click can read thousands of rows (the cap is 100,000) to answer one yes/no question. Two cheaper options: stop at the first page of rows that contains a match, or narrow the query to the page's address (url / final_url) and keep the JS key check as the final word.
  2. A page can have both a nightly Site Audit Fix action (F01/F03/F10) and an audit_page action open at once, because they use different dedup keys. Worth a line in the drawer, or a check against the nightly action's targets, if people send pages that are already in a nightly fix.
  3. If the web ships before the API that has /api/action-center/audits, the button gets a 404 and shows "Couldn't send to the Action Center" with a server error. Deploy the API with the web, or before it.

@gkhngyk
gkhngyk merged commit fe7ace3 into ansvisor:main Oct 28, 2026
1 of 2 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