Skip to content

feat(action-center): show on Analyze competitor content what the competitor pages AI cites have that yours doesn't (learning C1) - #1720

Merged
gkhngyk merged 18 commits into
ansvisor:mainfrom
cihan-gyk:feature/competitor-page-features-ui
Oct 29, 2026
Merged

gkhngyk merged 18 commits into
ansvisor:mainfrom
cihan-gyk:feature/competitor-page-features-ui

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Learning C1, web: the action drawer shows what "Analyze competitor content" found.

Stacked on #1718. Review the last 2 commits (eabf96e, 4902376). Until #1718 merges, Files changed also shows its server change. Merge order: #1718 → this PR → C2 brief → C2 Improve. There's no migration of its own (00369 is in #1718).

When the task has run, its row in the drawer's Tasks shows the findings above the task's text:

  • The title: "What the pages AI cites instead of yours have".
  • The gaps, for example "FAQ schema — on 2 of 3 of their pages, not on yours". When none of the brand's pages was read, the line drops "not on yours".
    • Your page passes every check… when there's no gap.
    • Only one of their pages was read… when there are too few pages to compare.
  • The pages read are links: host and path, word count, and how many answers cited each page.
  • Your page is a link, or a line saying it wasn't cited or couldn't be read.
  • When nothing was compared, it shows the reason instead: no prompts, no page cited, or none readable. The task stays open for a person.
  • A note says how the pages were read, and how many couldn't be.

Details:

  • TASK_COLUMNS adds output. taskFromRow parses it only for analyze_competitor_content, with parseCompetitorFindings.
    • The parser is defensive. A page needs an http(s) URL to be shown, counts are cleaned, and an unknown reason is dropped.
    • External links use rel="noopener noreferrer".
    • TASK_COLUMNS is also read by the MCP action export, so competitorFindings shows up there for this task as well.
  • The strings are in en.json under actionCenter.actionsPage.drawer.task.competitor. Check names come from the API (Site Audit's rubric labels), as on the Site Audit report.
  • It uses only theme tokens (text-muted-foreground, bg-current), with no fixed colors.
  • There are no new buttons, so no read-only guard is needed.

Where people see it: Action Center › Actions › open an action with an "Analyze competitor content" task › Tasks › expand that task.

Related issue

Agentic learning report, phase C (C1). No GitHub issue.

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. Run the task as in feat(action-center): read the competitor pages AI answers cite and say what they have that the brand's page doesn't (learning C1) #1718's steps. Then open the action in the Action Center and expand "Analyze competitor content".
  2. To see the other states, set the task's output by hand:
    • {"competitorPages":[],"gaps":[],"reason":"none_cited"} shows the reason.
    • One page with "compared": false shows "Only one of their pages was read".
  3. cd web && npx vitest run src/components/action-center/task-detail.test.tsx src/lib/action-center/competitor-findings.test.ts

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

What was run:

🤖 Generated with Claude Code

cihan-gyk and others added 15 commits October 28, 2026 10:15
…y what they have that the brand's page doesn't

Learning C1, part 1 (server). "Analyze competitor content" was a step for
a person: nothing looked at the pages AI engines cite where the brand isn't
named, so "why do they win?" went unanswered.

- competitor-pages.js: from the brand's own tracked answers for the
  action's prompts over 14 days, the competitors' most cited pages, then
  pages cited where the brand isn't named (3 an action), and the brand's
  own page cited there. Each is read free (safe-fetch, public addresses
  only, never Scrape.do) and run through Site Audit's checks that read the
  page alone (15: structure, FAQ, schema, statistics, dates, length…). The
  result: each page's passing checks and the checks at least half the
  competitor pages pass that the brand's page doesn't.
- 00369 cited_page_features: the checks' statuses and word count per brand
  and page, never the page's text; reused for 14 days; a brand reads at
  most 12 pages a day (config competitorPages). Service role only; applied
  on the dev DB.
- The task gets the tool competitor_page_features, so the nightly runner
  carries it out (reading a public page changes nothing, no approval). A
  run with every read for the day spent leaves the task for the next night
  (retryLater: recorded as blocked, task untouched).
- No AI summary, no paid scraping (user decision 2). The guide says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…etitor pages AI cites have that yours doesn't

Learning C1, part 2 (web). The task now carries what the nightly read found
(part 1); the action drawer shows it when the task is opened.

- Task rows read `output`; Analyze competitor content's is parsed
  defensively (competitor-findings.ts: pages read, the brand's page, the
  gaps, pages left for tomorrow, why nothing was compared).
- TaskDetailView shows "What the pages AI cites instead of yours have":
  each gap as "FAQ schema — on 2 of 3 of their pages, not on yours" (the
  check's name as Site Audit's rubric gives it), the pages read with their
  words and how many answers cited them, the brand's page, and a note that
  only what the checks found is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… there is nothing to compare, and read every page of an action the same night

Review fixes before the PR (learning C1, server):

- An action that names no prompts (8 of the 9 plans with this task) reads
  its topics' prompts (topicPromptIds, shared with basket-metrics), else
  the brand's tracked prompts (at most 50), instead of ending on
  "no_prompts".
- No prompts, no page cited, or none readable no longer completes the
  task: ReadLaterError carries why as the task's output and retryDays (7);
  runTask keeps it on the open task with retryAfter, and the nightly sweep
  passes the task over until then without it taking a place under the
  ceiling.
- An action's pages are all read the same night or none: with fewer reads
  left than pages to read, nothing is read and the task waits for the next
  night. No more partial runs ("capped" is gone).
- yourPageStatus says whether the brand's page was read, not cited, or
  couldn't be read.
- A page with under 500 characters of text (a consent wall, a page drawn
  by script) is unreadable.
- An unreadable page is kept as { unreadable: true }: it counts against the
  day's reads and isn't read again while fresh. A row that can't be written
  is logged, not counted as unreadable.
- Gaps need at least two competitor pages ("compared"); a check is a gap on
  at least half of them.
- robots.txt: a site whose robots.txt shuts AnsvisorBot (or every crawler)
  out of the whole site isn't read, nor one whose robots.txt can't be read
  (RFC 9309); path rules aren't read yet (robotsGroups).
- 00369: the unreadable row shape in a comment (no schema change).
- The guide: the task is carried out by Ansvisor, not waiting for
  approval; what it reads, the two-page minimum, robots.txt and the weekly
  retry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…f theirs is too few, or yours couldn't be read

Review fixes before the PR (learning C1, web), after the server's:

- The "N more pages wait for tomorrow's reads" line is gone: an action's
  pages are now read the same night or not at all, so nothing is capped.
- With one competitor page read, the task says it takes at least two to
  compare, instead of "Your page passes…".
- The brand's page that couldn't be read says so, rather than "None of
  your pages was cited".
- "at least half of their pages" in the no-gap line, as the server counts;
  the no-prompts and none-cited reasons say what they now mean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s without Supabase

FEATURE_CHECKS, pageContext, pageFeatures, featureGaps and
MIN_PAGE_CHARACTERS move from competitor-pages.js to page-features.js,
which reads no database. competitor-pages.js loads the supabase admin
client, whose config exits when the SUPABASE_* env is absent (as in CI),
so a pure module that needs only the checks (the brief, Improve) would
take every test file reaching it down with it. competitor-pages.js
re-exports them, so its imports keep working; their tests move next to
the new module, with no supabase mock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…page-features

# Conflicts:
#	supabase/schema.sql
A page of tens of thousands of empty elements held the server for a
minute: removing scripts and styles before reading the text spliced
each out of its parent, and readability's block find was quadratic in
the elements it started from. Both are now one walk over the page,
with the same words and blocks as before.

@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. This PR's own diff, web only, needs no change. take-1720 (61fa49b) is this head d6fa59e with take-1718 merged in, so the stack carries #1718's fix. Merge it after #1718.

What I checked:

  • Reading the output. parseCompetitorFindings takes action_tasks.output (written only by the service role) and keeps only well-formed pages. A page link must start with http(s)://, so a javascript: URL can't reach href. The check keys go through the rubric's labels, and the reason codes (no_prompts, none_cited, unreadable, one page, your page unreadable) each have their own English line.
  • The query. TASK_COLUMNS adds output, read under the members' existing action_tasks policy. No new embed.
  • Copy. "What the pages AI cites instead of yours have", "on 2 of 3 of their pages, not on yours" and "One page of theirs is too few to compare" read well, and the plurals are right.
  • No migration, no API change. If the web part ships before the API, the drawer shows nothing new (the output is empty).
  • Tests. On main merged with the whole stack: task-detail.test.tsx and competitor-findings.test.ts pass, web tsc is clean, and subscription-guard-coverage.test.ts passes. There are no new server actions or write routes.
  • Merge. Clean on main 72f602f.

@gkhngyk
gkhngyk merged commit 9333a32 into ansvisor:main Oct 29, 2026
4 of 5 checks passed
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 29, 2026
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