Skip to content

feat(mentions): add the Mentions overview tab - #1116

Merged
gkhngyk merged 10 commits into
ansvisor:mainfrom
cihan-gyk:feature/mentions-overview
Oct 17, 2026
Merged

gkhngyk merged 10 commits into
ansvisor:mainfrom
cihan-gyk:feature/mentions-overview

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Third of six PRs for Mentions & Sentiment: the Overview tab (MS-06), as in the mockup. It reads everything from mentions_overview (#1115) in one call, so opening the tab or changing a filter never calls an LLM.

Stacked on #1115, which is stacked on #1114. The diff includes both of their commits until they merge. Please merge #1114, then #1115, then this one. This PR is the one that makes the page show figures.

What the tab shows, top-down

  • Summary line: written from the aggregates by a fixed template, and it says so with the window and the responses it rests on. Example: "Net sentiment is +34 (↓ 6 vs the previous 30 days). Most of the drop is on Gemini (−18). AI usually names Ansvisor next to Profound and Peec AI."
    • The platform is named only when both windows have 20+ mentions on it and it moved the same way as the total.
    • Under 20 mentions it reads "Net sentiment is −50 (low sample: 2 mentions)", with no change, like the KPI cards.
    • The mockup's theme and descriptor clauses ("limited integrations", "open-source") need the V1.5 classifier and are left out.
  • KPI cards:
    • Total mentions (Δ%);
    • Mention rate (Δ points, "of N tracked responses");
    • Prompts with mentions (Δ%, "of N tracked prompts", with a fill bar);
    • Net sentiment (Δ, the positive/neutral/negative split bar with its legend and n).
    • Under 20 responses a rate is "Low sample" and shows no change (spec §2).
    • Recommendation rate stays hidden until V1.5.
  • Mentions & sentiment over time: a daily trend with a Mentions / Mention rate / Net sentiment toggle.
    • Days without responses are filled in, so the axis is even.
    • Each point's tooltip gives its n and marks "Low sample".
    • The 24h view reads answers rather than whole days, so it explains that a trend needs two days or more.
  • By AI platform: logo, mentions, rate, sentiment split and net with its change.
    • A platform with negative net sentiment is tinted.
    • A note appears when platforms are 40+ points apart ("Platforms disagree: ChatGPT is +54 but Gemini is −6.").
    • Under 20 mentions a row is marked "Low sample", with no colour and no change.
  • Competitor framing:

"Frequently mentioned with" moves to the Perception tab (PR 5), where the mockup has it, so the same co-mention counts aren't shown twice here.

Code

  • mentions/_overview.tsx loads the tab:
    • it waits 250 ms after the last filter change, so typing in the search box reads once;
    • a newer read wins over one still on its way, and the last figures stay dimmed meanwhile;
    • another brand's figures are never shown under the active brand's name.
  • Components: _headline, _overview-kpis, _trend-card / _trend-chart (recharts, loaded on demand), _platform-table, _competitor-table, _sentiment-split.
  • lib/mentions-headline.ts: what the summary says (net, change, the platform behind it, companions) and when platforms disagree, kept apart from the wording and tested.
  • lib/mentions-overview.ts:
    • the window's UTC days;
    • relativeChange;
    • mentionTrend, which fills in the days without responses.
  • insights/_kpi-cards.tsx: MetricCard is exported, and it takes an optional footer in place of its sparkline. Insights renders as before.
  • Strings are under mentions.overview in en.json.

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. Apply 00157 and run the backfill from feat(mentions): add daily mention rollups and the Mentions overview read #1115.
  2. Open Mentions in the sidebar. The Overview shows the last 30 days. Check that:
    • the summary's figures match the cards;
    • the cards match the platform and competitor tables.
  3. In the trend, switch to Net sentiment and hover a point: the day, its value, its n and "Low sample" under 20.
  4. Choose 24h. The trend explains it needs two days, and with fewer than 20 mentions the summary says "low sample" with no change.
  5. Pick a platform, topic or search: every figure narrows, and the URL keeps the filters.
  6. Switch the brand in the sidebar: the skeleton shows until that brand's figures arrive.
  7. Check dark mode, and 1024px, where the cards sit two by two.

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:

  • yarn test passes: 895 tests, 18 of them new.
    • lib/mentions-headline.test.ts: the mockup's story (+34, ↓ 6, Gemini −18, Profound and Peec AI), a flat change, an empty window, low samples, and disagreement.
    • mentions/_overview.test.tsx:
      • the summary's exact wording, including low sample and never named;
      • the cards' values and changes;
      • the platform table's rows, tint and note;
      • the competitor table;
      • the tab's debounce, empty state, custom range without dates, unavailable data and failed reads.
    • lib/mentions-overview.test.ts: relativeChange and mentionTrend.
  • yarn build passes (with CI's Stripe placeholder).
  • In the browser, on the demo brand with 00157 applied and backfilled: 30d, 24h, the three trend metrics and the tooltip, in light and dark, at 1440, 1280 and 1024px. Nothing is cut off at 1280; at 1024 the cards sit 2 × 2.

🤖 Generated with Claude Code

cihan-gyk and others added 3 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]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk the Overview tab for Mentions & Sentiment, the third of six PRs. It is stacked on #1115 (data layer), which is stacked on #1114 (page shell). Please merge them in that order; after #1115, apply 00157 and run its backfill so this tab has figures.

@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 17, 2026
@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 Overview tab reads mentions_overview (00157, applied). Tested on the full Mentions chain; CI was green on this tree.

@gkhngyk
gkhngyk merged commit cab6f2b 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