Skip to content

Citations: keep content visible during refetch instead of swapping the whole page to a skeleton #656

Closed

Description

@gkhngyk

Problem

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.

Evidence

Proposal

  • 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.

Activity

  1. added
    enhancement
    good first issue
    on Aug 7, 2026
  2. tomatotomata commented on Aug 7, 2026

    @tomatotomata

    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.

  3. gkhngyk commented on Aug 8, 2026

    @gkhngyk
    ContributorAuthor

    @tomatotomata that's exactly the right scope — assigned to you. Two pointers as you get into it:

    Keeping the PR limited to this page is right. Looking forward to it!

  4. gkhngyk commented on Aug 10, 2026

    @gkhngyk
    ContributorAuthor

    @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.

  5. gkhngyk commented on Aug 10, 2026

    @gkhngyk
    ContributorAuthor

    @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.

  6. added
    citations
    on Aug 12, 2026
  7. BharadwajKanneveti commented on Aug 20, 2026

    @BharadwajKanneveti
    Contributor

    @gkhngyk it is open for some time can I work on this ?

  8. gkhngyk commented on Aug 20, 2026

    @gkhngyk
    ContributorAuthor

    @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:

  9. gkhngyk commented on Aug 20, 2026

    @gkhngyk
    ContributorAuthor

    @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:

    The acceptance criteria are unchanged, with getCitationsTotal read as brandHasCitations in the third one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

citationsenhancementgood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions