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
Insights & Reports: *Change deltas silently switch to absolute counts on a zero base but always render with a % suffix #520
InsightsSummary.mentionsChange / citationsChange (web/src/lib/actions/tracking.ts) are percentage deltas except when either window is zero, where the formula falls back to an absolute difference:
Every consumer renders the value with an unconditional % suffix — the Insights KPI cards (DeltaBadge), the report viewer's Delta, and the PDF's DeltaText. So a brand going 0 → 354 mentions shows "+354%" in three surfaces, when the truth is "+354 mentions (new)". The mixed semantics also can't be narrated correctly by the report's AI summary (#514 fixes the prompt for the common percentage case, but the model cannot know which meaning applies to a given value).
Fix direction
Make the field's meaning unambiguous instead of guessing at render time. The least invasive shape:
Keep *Change as the percentage delta and set it to null when there is no meaningful base (prev = 0), and
Expose the raw previous-period counts (prevMentions, prevCitations) on InsightsSummary so consumers can render the zero-base case honestly (e.g. a "new" badge or "+354" without the % suffix) and the report snapshot carries values the AI summary can narrate safely.
Alternative shapes are fine if they keep one meaning per field — the requirement is that no consumer can render an absolute count with a % suffix.
Consumers to update together (all read the same struct, so they must land in one PR): Insights KPI cards, report viewer Delta, report PDF DeltaText, and the report summary prompt's description of the fields (coordinate with #514). Old report snapshots store the current mixed-meaning values — the viewer/PDF fallback for them should keep today's rendering rather than reinterpreting immutable data.
Acceptance criteria
A brand with prev = 0 and cur > 0 never shows a % suffix for that delta on Insights, the report viewer, or the PDF.
Percentage deltas keep rendering exactly as today when both windows are non-zero.
Reports generated before the change render unchanged.
yarn lint, yarn typecheck and yarn format:check pass from web/.
Activity
abdullah91111 commentedon Jul 23, 2026
on it
abdullah91111 commentedon Jul 23, 2026
http://github.com/ansvisor/ansvisor/pull/521