Skip to content

feat: add generalized document sources sidebar (THU-608)#1002

Open
darkbanjo wants to merge 1 commit into
mainfrom
jkab/thu-608-generalize-sources-sidebar
Open

feat: add generalized document sources sidebar (THU-608)#1002
darkbanjo wants to merge 1 commit into
mainfrom
jkab/thu-608-generalize-sources-sidebar

Conversation

@darkbanjo

@darkbanjo darkbanjo commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

What

Brings 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.tsx, so badges and the sidebar share one source of truth.
  • Extends 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 (trackCitation*).
  • Reverted text-[var(--oup-accent)] colors to theme defaults.
  • Removed the hardcoded placeholder publication year from the row subtitle.
  • On-demand only: per product decision, the demo's auto-open-on-response-complete behavior is intentionally not ported (the sidebar opens only on badge/button click).

Design note

Citation rendering is intentionally bifurcated: document citations → sidebar, web-link citations → existing inline popover. CitationRow is document-shaped. Unifying web sources into the sidebar would be a follow-up design pass.

Test

  • 277/277 chat-component tests pass (incl. pre-existing citation-badge / text-part suites — 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: CitationsSidebarProvider wraps 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 by fileId, replacing ad-hoc building in text-part.tsx so badges and sidebar stay aligned. HaystackReferenceMeta / DocumentCitationSource gain optional title, bookTitle, sourceUrl, contributors, and score; document chip labels prefer section title over book name.

Rows: CitationRow opens 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.

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>
@github-actions

Copy link
Copy Markdown

Semgrep Security Scan

No security issues found.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b1f0d93. Configure here.

@github-actions

Copy link
Copy Markdown

PR Metrics

Metric Value
Lines changed (prod code) +419 / -51
JS bundle size (gzipped) 🟢 682.3 KB → 683.5 KB (+1.2 KB, +0.2%)
Test coverage 🟢 78.09% → 78.18% (+0.1%)
Performance (preview) Preview not ready — Render deploy may have timed out
Accessibility
Best Practices
SEO

Updated Thu, 18 Jun 2026 18:22:25 GMT · run #1949

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