Repository navigation
Description
Problem
Insights now leads with the prompt-level Visibility Rate (#490), but two surfaces still display the all-rows score average, so the same entity shows contradictory numbers depending on the page:
- Competitors page (
web/src/app/[locale]/(dashboard)/dashboard/competitors/page.tsx) — the competitor cards showentry.avgVisibilityScoreas a percentage. A competitor at 57% on the Insights leaderboard can read ~5% here, side by side in the same product. - Topics pages (
web/src/app/[locale]/(dashboard)/dashboard/topics/page.tsxandtopics/[id]) — the Best/Weakest topic KPIs, the topic table, the CSV export and the topic detail's competitor table all show per-topic score averages, diluted by platform count exactly like the old brand-level number.
Fix
Competitors page — pure UI mapping, no backend change: CompetitorComparisonEntry already carries visibilityRate, visiblePrompts and promptCount since #490. Show the rate on the cards (with appeared in X/Y prompts, mirroring the Insights leaderboard rows) instead of the score average.
Topics — compute a per-topic rate: distinct prompts in the topic with at least one answer mentioning or citing the brand ÷ distinct prompts in the topic that produced results in the window (appeared = mention_count > 0 OR citation_count > 0, chatgpt-shopping excluded — same rules as visible_prompt_stats, see web/src/lib/actions/tracking.ts). web/src/lib/actions/topic.ts already fetches the raw rows with prompt_id, mention_count and citation_count, so the rate is computable in the existing aggregation loop — no new RPC. Use it for the topic table's visibility column, the Best/Weakest KPIs and the CSV export; the topic detail's competitor table should apply the same same-denominator rule (competitor rates divide by the topic's prompt count).
Keep the score average available where it adds depth (e.g. secondary column or tooltip) but the headline number on both surfaces must be the rate, matching Insights for the same window and filters.
Acceptance criteria
- A competitor's percentage on the Competitors page equals its Insights leaderboard rate for the same period.
- Topic visibility percentages are prompt-level rates; a topic whose every prompt surfaced the brand reads 100%, one with no appearances reads 0%.
- CSV export headers/values reflect the new rate (rename the column if needed).
- Brand and competitor rates on any topic surface share the same denominator.
yarn lint,yarn typecheck,yarn format:checkpass fromweb/.
Getting started
Depends on #490 — start after it merges. See CONTRIBUTING.md for setup. Comment here to claim the issue before opening a PR.
Activity
feat(topics): switch the Topics overview to prompt-level Visibility R…
gkhngyk commentedon Jul 24, 2026
Status update — about half of this shipped in #499: the Topics overview page now uses the prompt-level rate everywhere (table column, Best/Weakest KPIs and the CSV export's
visibility_ratecolumn).Remaining scope for this issue:
competitors/page.tsx) — still renderentry.avgVisibilityScore; switch the headline tovisibilityRatewith anappeared in X/Y promptssub-line. Pure UI mapping — the entry already carriesvisibilityRate,visiblePromptsandpromptCount.topics/[id]/page.tsx) — the headline KPI still showssummary.avgVisibilityScoreand the Competitor Comparison table still shows per-competitor score averages. Both should move to the rate, with brand and competitor rates sharing the same denominator (the topic's prompt count).#499 and the Insights leaderboard are working reference implementations of the exact pattern. Comment here to claim.
feat(web): show the prompt-level visibility rate on competitor cards …