Skip to content

fix(prompts): show prompt-level visibility rate instead of zero-diluted average score - #562

Merged
gkhngyk merged 3 commits into
mainfrom
fix/prompt-visibility-rate-column
Jul 30, 2026
Merged

gkhngyk merged 3 commits into
mainfrom
fix/prompt-visibility-rate-column

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

The All Prompts Visibility column averaged visibility_score across all runs in the last 30 days, so every run where the brand didn't appear entered the average as 0. Heavily-mentioned prompts were dragged down to misleading single digits — e.g. a prompt with 310 mentions and 234 citations showed 21. This is the same dilution the Insights headline had before the Visibility Rate switch (#490, #493); this column was the last surface still on the old formula.

The column now shows the prompt-level Visibility Rate: the share of runs (last 30d, chatgpt-shopping excluded per #155) with ≥1 brand mention or citation — the same run-visibility rule and rounding used by insights_aggregates and the topic detail page, so all surfaces speak the same language.

  • Migration 00037: prompt_visibility_summaries gains visible_runs (rate numerator) and avg_visibility_visible (average score across visible runs only); avg_visibility kept for compatibility. Return type changes, so DROP + CREATE as in 00034. Already applied to the hosted database (backward-compatible — currently deployed code reads fields by name).
  • Web: the cell renders {rate}% with the bar scaled to the rate; the tooltip explains it — "Appeared in X of Y runs (30d) · avg score when visible: Z". Sorting by the column uses the rate. CSV export gains visibility_rate_30d and visible_runs_30d while keeping the old columns.

Real-data spot checks after the change:

Prompt (mentions / citations) Old avg score New rate Avg when visible
310 / 234 21 37.1% (69/186 runs) 57
174 / 118 52 83.3% (35/42 runs) 62
152 / 42 9 13.6% (25/184 runs) 66

Related issue

Follow-up to the Visibility Rate alignment work in #490 / #493.

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. Open Prompts → All Prompts for a brand with tracked results.
  2. The Visibility column shows a percentage; hover a value — the tooltip shows the run counts and the average score across visible runs.
  3. A prompt with many mentions spread across some of its runs shows its appearance share (e.g. 37%) instead of a near-zero averaged score.
  4. Sort by the column and export CSV — both follow the rate.

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

@gkhngyk
gkhngyk merged commit 5f2bbbd into main Jul 30, 2026
3 checks passed
@gkhngyk
gkhngyk deleted the fix/prompt-visibility-rate-column branch July 30, 2026 16:23
gkhngyk pushed a commit that referenced this pull request Jul 31, 2026
…iluted average (#568)

getPromptPerformance and getTopicPerformance averaged visibility_score over
all runs, letting zero-visibility runs dilute heavily-mentioned prompts/topics
into misleading single digits — the same defect #562 already fixed for the
All Prompts tab. Both now rank/report by visibility rate (share of runs with
a mention or citation), matching getPromptVisibilitySummaries' rounding.

Both scans were also un-paginated, so PostgREST silently capped them at 1000
rows on busy brands (the #430/#464 defect family); they now page in 1000-row
batches like the existing citation-evidence scan.

Rendering (detail page + PDF) shows the rate with a % sign, falling back to
the legacy avgVisibility/100 cell for reports generated before this shipped —
mirroring the competitor table's existing visibilityRate fallback. The AI
executive-summary prompt is updated with the same distinction so generated
prose doesn't misquote avgVisibility as a percentage.

Closes #564

Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

1 participant