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
Citations: keep content visible during refetch instead of swapping the whole page to a skeleton #656
The Citations page has a single isLoading flag, and while it is true the entire content — KPI cards, tables, tab counts — is replaced by CitationsSkeleton. That happens on every load, not just the first one: changing the date range or any filter blanks the page and re-renders it from grey boxes. On slow loads this reads as "the page reset" rather than "your data is updating", and all context (scroll position, which numbers were on screen) is lost.
The Insights page already solves this correctly and the pattern just needs to be copied.
Derive isRefetching = isLoading && data !== null on the Citations page.
Show CitationsSkeleton only when isLoading && data === null (true first load).
During a refetch, keep the existing content rendered, dim it (opacity-60), and show the same floating Loader2 spinner Insights uses.
While at it: getCitationsTotal is called inside loadData on every filter change (page.tsx#L886-L888), but it is a brand-level constant used only for the has-any-citations empty state. Fetch it once per brand instead.
Acceptance criteria
First load of the page still shows the skeleton.
Changing the date range or any filter keeps the current data on screen, dimmed, with a spinner — no skeleton, no layout jump.
getCitationsTotal runs once per brand, not on every filter change.
I traced the proposed change to the Citations page's initial-load versus refetch state. I was thinking of keeping the current data mounted during filter refetches, showing the existing Insights-style dimmed loading state, and moving getCitationsTotal out of the refetch path so it runs once per brand. I would add focused coverage for first load, refetch, and the empty-state total. Does that scope match what you want for #656? I would keep the PR limited to this page and disclose AI assistance.
@tomatotomata one more thing worth considering while you're in here.
#684 is still unassigned and lands on the exact same code you're changing: loadData and the effect that calls it (citations/page.tsx:878-920). It's a small bug — navigating away mid-load fires a "Failed to load citation data" toast on whatever page you land on, because the catch treats an aborted request as a real failure and the effect has no cleanup. The fix is a cancelled flag in the effect plus skipping the toast when the request was cancelled.
Since you're already restructuring that function for the refetch state, folding #684 in would be less work than two rebases against each other — and the cancellation guard is a natural companion to "keep the old data mounted", since both are about a refetch that's no longer relevant. Happy to assign it to you if you want it; equally fine to leave it separate and we'll find another taker.
No pressure on timing either way — just flagging it before the two collide.
@tomatotomata heads-up: since #684 was still unassigned and small, we've taken it ourselves — #696. It adds a generation guard to loadData so an aborted request stops toasting and stale responses can't overwrite newer data.
That should make your change smaller rather than conflict with it: the cancellation half is done, so #656 is now just the initial-load-vs-refetch rendering (skeleton only on first load, dimmed content + spinner afterwards) plus moving getCitationsTotal out of the refetch path. If #696 merges first, a rebase should be trivial; if you already have work in progress, say so and we'll hold it.
@tomatotomata reassigning after twelve quiet days; nothing personal, and you're welcome back on any of the open issues.
Two pointers:
The pattern to mirror is isRefetching in insights/page.tsx — stale content stays mounted at 60% opacity with a small floating spinner, and the skeleton is kept for the true first load only.
@BharadwajKanneveti one correction to the description before you start — the page has moved under it since it was written (#696, #742, #744, #748), so every line reference in the issue body is stale, and one function no longer exists.
getCitationsTotal is gone.perf(citations): aggregate the overview in Postgres instead of downloading it #744 replaced it with brandHasCitations, called at #L921. Same problem under a new name: it takes only the brand id, feeds nothing but the has-any-citations empty state, and still runs on every filter change. Hoisting it out of the refetch path is still worth doing.
The acceptance criteria are unchanged, with getCitationsTotal read as brandHasCitations in the third one.
Activity
tomatotomata commentedon Aug 7, 2026
I traced the proposed change to the Citations page's initial-load versus refetch state. I was thinking of keeping the current data mounted during filter refetches, showing the existing Insights-style dimmed loading state, and moving
getCitationsTotalout of the refetch path so it runs once per brand. I would add focused coverage for first load, refetch, and the empty-state total. Does that scope match what you want for #656? I would keep the PR limited to this page and disclose AI assistance.gkhngyk commentedon Aug 8, 2026
@tomatotomata that's exactly the right scope — assigned to you. Two pointers as you get into it:
isRefetchingpattern to mirror is in insights/page.tsx#L1349 and #L1482-L1489.loadData(cancellation guard for a spurious toast) — if it lands first, rebase on top of it; if you get there first, no need to absorb its scope.Keeping the PR limited to this page is right. Looking forward to it!
gkhngyk commentedon Aug 10, 2026
@tomatotomata one more thing worth considering while you're in here.
#684 is still unassigned and lands on the exact same code you're changing:
loadDataand the effect that calls it (citations/page.tsx:878-920). It's a small bug — navigating away mid-load fires a "Failed to load citation data" toast on whatever page you land on, because the catch treats an aborted request as a real failure and the effect has no cleanup. The fix is acancelledflag in the effect plus skipping the toast when the request was cancelled.Since you're already restructuring that function for the refetch state, folding #684 in would be less work than two rebases against each other — and the cancellation guard is a natural companion to "keep the old data mounted", since both are about a refetch that's no longer relevant. Happy to assign it to you if you want it; equally fine to leave it separate and we'll find another taker.
No pressure on timing either way — just flagging it before the two collide.
gkhngyk commentedon Aug 10, 2026
@tomatotomata heads-up: since #684 was still unassigned and small, we've taken it ourselves — #696. It adds a generation guard to
loadDataso an aborted request stops toasting and stale responses can't overwrite newer data.That should make your change smaller rather than conflict with it: the cancellation half is done, so #656 is now just the initial-load-vs-refetch rendering (skeleton only on first load, dimmed content + spinner afterwards) plus moving
getCitationsTotalout of the refetch path. If #696 merges first, a rebase should be trivial; if you already have work in progress, say so and we'll hold it.BharadwajKanneveti commentedon Aug 20, 2026
@gkhngyk it is open for some time can I work on this ?
gkhngyk commentedon Aug 20, 2026
@BharadwajKanneveti yours — thanks for picking it up, and for #742.
@tomatotomata reassigning after twelve quiet days; nothing personal, and you're welcome back on any of the open issues.
Two pointers:
isRefetchingin insights/page.tsx — stale content stays mounted at 60% opacity with a small floating spinner, and the skeleton is kept for the true first load only.loadDatahas changed since this was written: fix(citations): don't toast a load failure after leaving the page #696 added a generation guard, and perf(citations): aggregate the overview in Postgres instead of downloading it #744 replaced the scan with three RPC calls. Rebase on main before you start rather than after.gkhngyk commentedon Aug 20, 2026
@BharadwajKanneveti one correction to the description before you start — the page has moved under it since it was written (#696, #742, #744, #748), so every line reference in the issue body is stale, and one function no longer exists.
Current
main:loadDatastarts at #L908, not L878.getCitationsTotalis gone. perf(citations): aggregate the overview in Postgres instead of downloading it #744 replaced it withbrandHasCitations, called at #L921. Same problem under a new name: it takes only the brand id, feeds nothing but the has-any-citations empty state, and still runs on every filter change. Hoisting it out of the refetch path is still worth doing.The acceptance criteria are unchanged, with
getCitationsTotalread asbrandHasCitationsin the third one.