feat: add generalized document sources sidebar (THU-608)#1002
Conversation
Bring the citations "Sources" sidebar prototyped on the OUP demo branch into the product, decoupled from OUP/Deepset specifics. - New citations sidebar (desktop right slide-over / mobile bottom sheet) listing a message's document citations as rich rows: title, "<author>, in <source>" subtitle, page indicator, and a 0–1 relevance signal-strength indicator. - CitationsSidebarProvider mounted in app.tsx; opened on demand from inline citation badges (document citations) and a footer "show sources" button. Web-link citations keep the existing inline popover. - citation-utils (haystackRefToSource + buildMessageCitations dedup) replaces the inline document-citation building in text-part, so badges and the sidebar share one source of truth. - Extend HaystackReferenceMeta + DocumentCitationSource with optional title/bookTitle/sourceUrl/contributors/score (Haystack pipeline outputs; additive, no breaking change). Decoupled from the demo: dropped the OUP citation analytics, the text-[var(--oup-accent)] colors, and the hardcoded placeholder publication year. Per product decision the sidebar opens ON DEMAND only — the demo's auto-open-on-response-complete behavior is intentionally not ported. Tests: 277/277 chat-component tests pass; typecheck clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Semgrep Security ScanNo security issues found. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b1f0d93. Configure here.
| } | ||
| seen.add(ref.fileId) | ||
| sources.push(haystackRefToSource(ref, sources.length === 0)) | ||
| } |
There was a problem hiding this comment.
Wrong page after dedupe
Medium Severity
buildMessageCitations keeps only the first Haystack reference per fileId, but inline badges still represent later [N] markers for other pages. Opening the sidebar from a later marker highlights the row yet the row (and document viewer fallback) still use the first marker’s pageNumber and sideview id.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b1f0d93. Configure here.
PR Metrics
Updated Thu, 18 Jun 2026 18:22:25 GMT · run #1949 |


What
Brings the citations "Sources" sidebar prototyped on the OUP demo branch into the product, decoupled from OUP/Deepset specifics.
<author>, in <source>subtitle, page indicator, and a 0–1 relevance signal-strength indicator.CitationsSidebarProvidermounted inapp.tsx; opened on demand from inline citation badges (document citations) and a footer "show sources" button. Web-link citations keep the existing inline popover.citation-utils(haystackRefToSource+buildMessageCitationsdedup) replaces the inline document-citation building intext-part.tsx, so badges and the sidebar share one source of truth.HaystackReferenceMeta+DocumentCitationSourcewith optionaltitle/bookTitle/sourceUrl/contributors/score(Haystack pipeline outputs; additive, no breaking change).Decoupled from the demo
trackCitation*).text-[var(--oup-accent)]colors to theme defaults.Design note
Citation rendering is intentionally bifurcated: document citations → sidebar, web-link citations → existing inline popover.
CitationRowis document-shaped. Unifying web sources into the sidebar would be a follow-up design pass.Test
citation-badge/text-partsuites — no regressions). New tests:citation-row,citation-utils,citations-sidebar. Typecheck clean.Closes THU-608
🤖 Generated with Claude Code
Note
Low Risk
Additive chat UI and optional metadata fields; link opening uses existing safe-URL and content-view paths, with no auth or persistence changes.
Overview
Adds a document citations sidebar (desktop right panel / mobile bottom sheet) so users can browse a message’s Haystack sources as rich rows—title, author/book subtitle, page, and relevance bars—opened only on demand (not auto-open on reply complete).
Wiring:
CitationsSidebarProviderwraps the app; assistant messages get a footer Show sources control when deduped document citations exist. Inline document citation chips open the full message list in the sidebar (with the clicked source highlighted); web citations still use the inline popover.Shared mapping:
citation-utils(haystackRefToSource,buildMessageCitations) centralizes Haystack → citation shape and per-message dedupe byfileId, replacing ad-hoc building intext-part.tsxso badges and sidebar stay aligned.HaystackReferenceMeta/DocumentCitationSourcegain optionaltitle,bookTitle,sourceUrl,contributors, andscore; document chip labels prefer section title over book name.Rows:
CitationRowopens safe external URLs or falls back to the in-app document sideview. Tests cover utils, row, and sidebar open/close.Reviewed by Cursor Bugbot for commit b1f0d93. Bugbot is set up for automated code reviews on this repo. Configure here.