Repository navigation
fix(prompts): show prompt-level visibility rate instead of zero-diluted average score - #562
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The All Prompts Visibility column averaged
visibility_scoreacross 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-shoppingexcluded per #155) with ≥1 brand mention or citation — the same run-visibility rule and rounding used byinsights_aggregatesand the topic detail page, so all surfaces speak the same language.00037:prompt_visibility_summariesgainsvisible_runs(rate numerator) andavg_visibility_visible(average score across visible runs only);avg_visibilitykept 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).{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 gainsvisibility_rate_30dandvisible_runs_30dwhile keeping the old columns.Real-data spot checks after the change:
Related issue
Follow-up to the Visibility Rate alignment work in #490 / #493.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)