Skip to content

feat(prompts): Top Sources card on the prompt detail page - #495

Merged
gkhngyk merged 3 commits into
mainfrom
feature/prompt-detail-top-sources
Jul 21, 2026
Merged

gkhngyk merged 3 commits into
mainfrom
feature/prompt-detail-top-sources

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Top Sources card to the prompt detail page (/dashboard/prompts/[id]), answering "which sources do AI platforms cite when answering this prompt?" — the per-prompt counterpart of the citations page.

  • getPromptDetail now aggregates the prompt's already-loaded results by cited domain and by normalized URL (query/fragment and trailing slash stripped), using the same classifyDomain / extractHostname helpers, rounding, and row shape as getCitationsOverview, so both pages always agree on a domain's name, category, and usage. Adds two additive fields to PromptDetailData: topSources and topSourceUrls.
  • The card sits at the end of the page, below Platform Results, with Domains (N) / URLs (N) tabs styled like the citations Sources card: favicon, category badge (you / competitor / editorial / ...), per-provider dots, usage bar, citation count, and the citations-style pager (100 rows per page, continuous rank). Hidden when the prompt has no citations.
  • Shared extraction, no behavior change on the citations page:
    • DomainFavicon, CategoryBadge, PlatformsCell, UsageBar → components/citations/source-cells.tsx
    • TablePager, usePagination, PAGE_SIZE → components/table-pager.tsx (the reset-on-filter-change logic now uses the adjust-state-during-render pattern instead of a ref write, which the react-hooks/refs lint rule rejects)

Related issue

—

Type of change

  • feat — New feature

How to test

  1. Open a prompt detail page (/dashboard/prompts/<id>) for a prompt with tracking results.
  2. Scroll below Platform Results — the Top Sources card shows the Domains tab: rank, favicon, domain, category badge, provider dots, usage %, citation count.
  3. Switch to the URLs tab — rows show the page title linking to the URL, with domain + category badge beneath, deduped by normalized URL.
  4. With more than 100 rows, the pager appears (Previous/Next, continuous rank across pages).
  5. Cross-check a domain against /dashboard/citations (same period ≈ all time): category and look should match.
  6. A prompt with no citations shows no card; the citations page itself is unchanged.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

gkhngyk added 3 commits July 21, 2026 16:00
Aggregates the prompt's already-loaded results by cited domain in
getPromptDetail (same classification, rounding and row shape as the
citations overview) and renders a Top Sources table between the KPI row
and Platform Results: favicon, category badge, per-provider dots, usage
bar and citation count, with a top-10 preview and show-all toggle.

The shared cells (DomainFavicon, CategoryBadge, PlatformsCell, UsageBar)
moved from the citations page into components/citations/source-cells.tsx
so both pages render domains identically.
…elow Platform Results

URL rows aggregate with the same normalization as the citations overview
(strip query/fragment and trailing slash) and render like the citations
URLs tab: title link, domain, category badge, provider dots, usage bar
and citation count. Both tabs keep the top-10 preview with a show-all
toggle, and the card now sits at the end of the page.
Replace the show-all toggle with the citations-style TablePager (100
rows per page, continuous rank across pages). TablePager and
usePagination moved from the citations page into components/table-pager
so both pages share one implementation; the reset-on-key-change logic
now uses the adjust-state-during-render pattern instead of a ref write,
which the react-hooks/refs lint rule rejects.
@gkhngyk
gkhngyk merged commit 1af4cf7 into main Jul 21, 2026
4 checks passed
@gkhngyk
gkhngyk deleted the feature/prompt-detail-top-sources branch July 21, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant