Enhance citation handling and improve dataset provenance features - #147
Conversation
…treaming behavior
…for MDDB and DataverseLV
There was a problem hiding this comment.
🟡 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.
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:
Component and UI updates:
CitedDatasetscomponent to render the cited datasets list, handle marker jumps, and support hiding/showing the list.BotMessageBodyto assign citation numbers across all text blocks, display markers, and show the new reference list.CitationExportbutton to support a compact mode for use in list rows. [1] [2] [3]Testing:
CitedDatasets.test.tsx) and for correct streaming marker placement in bot messages (BotMessageBody.test.tsx). [1] [2]