You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Topic detail: visibility trend chart still uses the legacy raw-average score, contradicting the headline score #685
On the topic detail page the headline Visibility Score and the Visibility Trend chart come from two different scoring systems:
The headline uses the current AI Visibility Score blend (computeAiVisibilityScore — mention/citation/position, same formula as the Insights headline): web/src/lib/actions/topic.ts#L399-L413
The legacy function's own comments admit the problem — "this JS path is used by the older codepath" and "realistic daily averages for a low-visibility brand sit in the 0.3–1.5 band". Result: a topic can show a headline score of ~12 while its trend line crawls near 1 — the chart looks broken and understates the topic badly.
Fix
The new-formula daily series already exists and already supports topic scoping: the visibility_rate_trend RPC (migration 00039) takes p_topic_id and covers brand + competitors. Point the topic detail's trend (the getVisibilityTrend(brandId, { topicId }) call in getTopicDetail) at that path — the same way the Insights page already consumes it (tracking.ts#L2246-L2303).
Second legacy caller worth migrating in the same sweep (or a follow-up): the Reports trend section at web/src/lib/actions/reports.ts#L991 — reports pair that trend with new-formula KPIs, so they carry the same mismatch. If both are migrated, getVisibilityTrend has no callers left and can be removed. (The MCP/agent surface computes its own aggregates and is out of scope here.)
Acceptance criteria
The topic trend chart's latest-day value sits on the same scale as the headline Visibility Score (blend formula), not the raw all-answers average.
Competitor series on the chart uses the same formula as the brand series.
Reports trend either migrated alongside or tracked in a follow-up.
Activity
fix: topic detail trend chart & reports trend now use the AI Visibili…