Skip to content

Enhance citation handling and improve dataset provenance features - #147

Merged
ritwikshanker merged 12 commits into
mainfrom
feature/chat-ui-fixes
Sep 8, 2026
Merged

ritwikshanker merged 12 commits into
mainfrom
feature/chat-ui-fixes

Conversation

@ritwikshanker

@ritwikshanker ritwikshanker commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces a new, paper-style citation system for datasets mentioned in AI-generated answers, enhancing both the user experience and citation accuracy. It also adds comprehensive tests for the new components and refines the UI for listing and interacting with cited datasets.

New dataset citation system:

  • Datasets in AI answers are now cited with bracketed numbers ([1], [2], etc.), each linking to a compact, interactive reference list beneath the answer. Clicking a number jumps to and highlights the corresponding dataset. The list shows repository, title, year, authors, and action buttons, and can be expanded for more details. [1] [2]
  • The "Cited from" strip summarizes which repositories the cited datasets come from, with counts for each.
  • Matomo analytics track clicks on citation markers and dataset links.

Component and UI updates:

  • Adds the CitedDatasets component to render the cited datasets list, handle marker jumps, and support hiding/showing the list.
  • Updates BotMessageBody to assign citation numbers across all text blocks, display markers, and show the new reference list.
  • Refines the CitationExport button to support a compact mode for use in list rows. [1] [2] [3]

Testing:

  • Adds tests for the new citation list (CitedDatasets.test.tsx) and for correct streaming marker placement in bot messages (BotMessageBody.test.tsx). [1] [2]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are confirmed runtime/safety issues in newly-touched code paths (date formatting robustness and un-sanitized backend-controlled link targets) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR refactors assistant-message rendering to support paper-style dataset citations: inline links gain stable numeric markers ([n]) and a dedicated “Datasets cited in this answer” reference list, while also improving provenance display and reusing dataset-card UI across search results and citation lists.

Changes:

  • Introduces per-message citation collection/numbering and a reference list UI (with jump-to-reference behavior).
  • Refactors dataset card components (details/actions/relevance) for reuse in the new citations list and inline citation pills.
  • Improves chat scrolling behavior during streaming so the viewport follows the newest streamed text rather than growing reference content.
File summaries
File Description
src/pages/ChatPage.tsx Adjusts streaming-follow scrolling and swaps in the new bot message body component.
src/pages/ChatPage.test.tsx Updates expectations to match numbered citations + reference list behavior.
src/lib/utils.ts Adds shared publication date extraction/formatting helpers.
src/lib/repoProvenance.ts Extends repository logo mapping and adds a single-source provenance helper for compact UIs.
src/lib/repoProvenance.test.ts Adds coverage for new repository logos and getProvenanceSource.
src/lib/datasetCitations.ts Adds citation collection/numbering across message text blocks.
src/lib/datasetCitations.test.ts Adds unit tests for citation numbering, de-duping, and streaming-incomplete links.
src/components/SearchResultItem.tsx Refactors card into reusable subcomponents and supports compact actions for list rows.
src/components/MessageMarkdown.tsx Adds citation marker rendering support and normalizes excessive blank lines.
src/components/MessageMarkdown.test.tsx Updates tests for new pill+marker behavior and blank-line normalization.
src/components/DatasetReference.tsx Changes inline citations from hover cards to source-link pills plus optional [n] jump markers.
src/components/CitedDatasets.tsx New reference list UI with expand/collapse, jump highlighting, and “Cited from” summary.
src/components/CitedDatasets.test.tsx Adds tests for list rendering, repository counts, expansion, hide/show, and jumping.
src/components/CitationExport.tsx Adds compact styling mode for list-row usage.
src/components/BotMessageBody.tsx New message body renderer that orders blocks and appends the per-message reference list.
src/components/BotMessageBody.test.tsx Adds coverage for the streaming-end anchor behavior.
CHANGELOG.md Documents the new citation/reference-list UX and tracked events.
Review details
  • Files reviewed: 17/18 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/DatasetReference.tsx Outdated
Comment thread src/components/SearchResultItem.tsx Outdated
Comment thread src/lib/utils.ts Outdated
Comment thread src/pages/ChatPage.tsx
@ritwikshanker
ritwikshanker merged commit f98518b into main Sep 8, 2026
6 checks passed
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.

2 participants