Skip to content

feat(mentions): send mentions to the Action Center and suggest content - #1118

Merged
gkhngyk merged 21 commits into
ansvisor:mainfrom
cihan-gyk:feature/mentions-drawer-actions
Oct 17, 2026
Merged

gkhngyk merged 21 commits into
ansvisor:mainfrom
cihan-gyk:feature/mentions-drawer-actions

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Fifth Mentions & Sentiment PR: the response drawer's actions and the table's multi-select (MS-08). The answers behind a sentiment problem can now become work: sent to the Action Center with their quotes as evidence, or turned into a content suggestion for their prompt.

Stacked on #1117 → #1116 → #1115 → #1114. The diff includes their commits until they merge. Please merge them in order, then this one.

"Sentiment is wrong" (the override, logged and counted everywhere) follows in its own PR: it changes the sentiment figures on Insights too, so it is easier to review alone.

Send to Action Center

One or more answers naming the brand become one mention_review action.

  • Server (POST /api/mentions/action → lib/action-center/from-mentions.js), following the four person-sent flows (Content, Improve, topic gap, topic opportunity):
    • Answers read again. It reads the answers again from prompt_results: only the brand's own answers that name it count, and anything else sent is ignored.
    • Category and impact. The action is Protect when any answer is negative, Growth otherwise. Impact follows the negative share: half or more is high, any is medium, none is low.
    • Tasks. It gets F08's review plan (fix_brand_inconsistency), the definition written for how AI describes a brand, without its entity-signal audit, since the answers are the evidence:
      1. Inspect the mention contexts.
      2. Analyze the citations.
      3. Identify the pages.
      4. Strengthen the brand descriptions.
      5. Publish.
      6. Validate the mentions.
      7. Measure the outcome.
    • Payload.
      • Counts: the answers, the negatives and the prompts.
      • The platforms.
      • Up to 10 answers quoted as evidence: prompt, platform, date, sentiment and the excerpt the person saw.
      • The prompts as targets.
    • Baseline: the selection's sentiment (positive, negative, net).
    • Dedup: the same answers sent again return the open action, keyed on the answers actually found, with the race handled as in the other flows.
    • Measurement: validate.js measures the action on the answers' prompts once done, like the other person-sent kinds.
  • Action Center (web):
    • The kind is registered.
    • Its title names the prompt ("Improve how AI describes you for "…"") or the number of prompts.
    • The drawer gets a Mentions context: the source with a link back, the counts, and the answers quoted when sent.
    • The Signals tab explains why there are none.

Suggest content

The drawer's Suggest content runs the Prompts page's existing flow (PROMPT-006) for the answer's prompt. It keeps that flow's checks and the toasts open what was made:

  • an open suggestion that already answers the prompt is returned instead of writing a new one;
  • the monthly content quota applies;
  • the job is followed to its end.

Multi-select

  • Ticking. Each row's Prompt cell has a box, so the Prompt column stays pinned, and the header box ticks the whole page.
  • Bar. Ticked answers show a bar: "N answers selected · Send to Action Center · Clear".
  • Reset. A new page or filter starts with none ticked, and the selection clears once sent.

Export of the selection comes with Export CSV (PR 6).

Related issue

None.

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 server and web from this branch (the server for /api/mentions/action).
  2. Open Mentions → Mentions and filter Sentiment → Negative. Tick two answers and click Send to Action Center.
  3. In the toast, click Open. The action is Protect with a priority (High for two negatives). Its title names the prompt.
    • The Overview shows the answers quoted.
    • Tasks shows the 7 review tasks.
  4. Back on Mentions, open an answer and click Send to Action Center twice. The second time says "Already in the Action Center" and names the same action.
  5. Suggest content in the drawer writes a suggestion for the prompt, or opens the one that already exists. This uses the monthly content quota.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): no errors; the 7 warnings are in files this PR does not touch
  • 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 and npm test (1301) pass.
    • lib/action-center/from-mentions.test.js:
      • the action from the answers as stored, where a non-mention is ignored and doesn't change the dedup key;
      • category, impact and baseline;
      • evidence excerpts cut to 400 characters;
      • the open action returned;
      • the winner of a race returned;
      • 404 without mentions.
    • routes/mentions-action.test.js: validation, membership, and 201/200.
    • validate.test.js: a Mentions action is measured on its prompts' basket.
  • web: yarn test (921) and yarn build pass.
    • display.test.ts: the kind's titles, description and no-signals tag.
    • lib/actions/mentions.test.ts: the call with the excerpts, and errors returned.
    • mentions/_mentions-tab.test.tsx: ticking (it doesn't open the drawer), the bar, sending the selection and clearing it, and the drawer's send ("Already in…") and suggest.
  • In the browser, with this branch's server on a side port in development mode (no jobs or cron):
    • sent two negative answers: Protect / High, 7 tasks, evidence quoted;
    • sent one answer twice: "Already in the Action Center";
    • light and dark checked.
    • The test actions were deleted afterwards.
    • Suggest content was checked by tests only, so as not to spend content quota.

🤖 Generated with Claude Code

cihan-gyk and others added 5 commits October 17, 2026 09:13
…iment page shell

Mentions & Sentiment (MS-05) gets its sidebar item, "Mentions" with a New
pill and a speech-bubble icon, directly above Citations, its sibling
concept. Once Topics moves into Prompts, it sits between Prompts and
Citations.

/dashboard/mentions has the page's title and description, its V1 tabs
(Overview, Mentions, Perception; Sentiment and Fact-check stay hidden until
built) and the filter bar every tab shares: date range (30 days by default,
as in the mockup), AI platform, country, topic and a search over prompts,
brands and phrases. Tab and filters live in the URL, so a refresh or a
shared link restores the view. The tabs' figures and charts arrive with the
next PRs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The data layer for Mentions & Sentiment (MS-03/04), built from what
tracking already stores on each answer: mention_count, mention_position,
competitor_mentions and the answer's sentiment toward the brand. Opening
the page or changing a filter never calls an LLM.

Migration 00157 adds two daily rollups:
- mentions_prompt_daily (day x prompt x platform x region): answers, the
  answers naming the brand, occurrences, positive and negative mentions,
  and the brand's positions;
- mentions_competitor_daily: answers naming each competitor, and those
  naming the brand too.
refresh_mentions_daily rebuilds them (service role only), and
mentions_overview reads a window and the one before it, filtered by
platform, region, topic and a prompt search: under two days from the
answers, longer windows from whole UTC days. It is security definer with
the organization check made explicit.

The server refreshes the rollups with the Insights and Citations ones,
when a run stamps and in the nightly sweep, and
scripts/backfill-mentions-daily.js fills a brand's history. The web gets
getMentionsOverview, the Overview's metrics (mention rate, the sentiment
split with neutral kept, net sentiment, low sample under 20 mentions,
average position) and the filters-to-query helper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Overview tab of Mentions & Sentiment (MS-06), as in the mockup:

- a summary line written from the aggregates by a fixed template (net
  sentiment and its change, the platform behind most of it, the
  competitors named beside you), never an LLM;
- KPI cards: Total mentions, Mention rate, Prompts with mentions and Net
  sentiment with its split and n; under 20 responses a rate is a low
  sample and shows no change;
- a daily trend with a Mentions / Mention rate / Net sentiment toggle;
- a by-platform table with the sentiment split, net and its change, and
  a note when platforms disagree;
- competitor framing: mentions, rate and same-answer counts, with
  sentiment for your brand only.

MetricCard is exported from the Insights cards and takes a footer in
place of its sparkline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Mentions tab of Mentions & Sentiment (MS-07/MS-08, read-only V1):

- migration 00158 adds mentions_list: the answers naming the brand in
  mentions_overview's window, a page of 100 at a time, filtered by
  sentiment and by a competitor named in the same answer (or none),
  sorted newest, oldest, by co-mentions or most negative, and grouped by
  prompt or platform; security definer with the organization check;
- listMentions cuts each answer to the passage around the brand's first
  mention on the server (lib/mention-match.ts matches names as tracking
  does), and getMentionResponse reads one answer for the drawer;
- the table pins its header and Prompt column, marks your brand in
  violet and competitors in grey, and keeps its controls in the URL;
- the drawer shows the prompt, platform and model, country, date,
  sentiment, position and topic, the excerpt, the competitors named,
  the full stored answer with the names marked, and its citations typed
  as on the Citations page, with Copy and View prompt.

The search box now says it searches prompts, as both tabs do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The response drawer's actions and the Mentions table's multi-select
(MS-08):

- Send to Action Center: one or more answers naming the brand become one
  mention_review action. The server reads the answers again (only the
  brand's own mentions count), files them as Protect when any is negative
  (Growth otherwise) with impact from the negative share, plans F08's
  review tasks, quotes the answers as evidence, keeps the selection's
  sentiment as the baseline, and measures the action on the answers'
  prompts once done. The same answers sent again return the open action.
  POST /api/mentions/action, lib/action-center/from-mentions.js.
- The Action Center knows the kind: its title names the prompt (or the
  number of prompts), and the drawer shows the answers quoted when sent.
- Suggest content runs the Prompts page's flow for the answer's prompt,
  with its quota and existing-suggestion checks.
- The table ticks answers on the page and sends them together.

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

Copy link
Copy Markdown
Collaborator Author

@gkhngyk the Mentions drawer's actions: Send to Action Center (a new person-sent mention_review kind, measured like the other sent kinds), Suggest content, and multi-select. Stacked on #1117 → #1116 → #1115 → #1114; please merge them in that order. It touches the server (new POST /api/mentions/action), so the server needs a deploy with it.

@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 17, 2026
mentions_list joined the answers to the brand's prompts first, and the
planner walked each prompt's whole history: 8.8 s for 30 days of the
largest brand, past the 8 s timeout, so the table failed on its default
range. It now reads the window's mentions first, through a partial index
on mention_count > 0, then joins the prompts: 1.8 s for 30 days, 2.9 s
for 90.

Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 17, 2026

@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.

Reviewed. The send route checks brand access and keeps only the brand's own answers that name it, deduplicated per answer set. Merged main into the branch: the drawer keeps the task imports beside MentionReviewContext, and the mention_review branch gets its own separator like the others (the same resolution as the upstream merge on this branch).

@gkhngyk
gkhngyk merged commit b8a71ce into ansvisor:main Oct 17, 2026
4 of 5 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