feat: inline citations and source cards for RAG results - #161
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…est opts in Sources now come from the excerpts that fit the context budget, so the numbers in the prompt and on the cards are the same list. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Text inside bold and italic now goes through the same link step as the rest of a line, so URLs inside ** are linked too. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…<claudius-chat> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…uest field Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…re it An upstream failure delivered as the first stream event (an overload) must still reach the route before the SSE response opens, so it stays a JSON 503 the client retries instead of an in-band STREAM_ERROR. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Early sources are attached to the streaming reply only when the option is on, so an embed that never opted in shows its source icon on done as before, even against a worker that announces sources early. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Measured against main (967a227) with size-limit --json on both trees, limits set to measured + 5%: claudius.iife.js raw 222981 -> 232443 B (+9462), gzip 71954 -> 74454 B (+2500), brotli 62828 -> 64990 B (+2162) claudius.js raw 115459 -> 129310 B (+13851), gzip 31881 -> 34946 B (+3065), brotli 27235 -> 29542 B (+2307) claudius.css raw 24604 -> 24970 B (+366), gzip 5177 -> 5237 B (+60), brotli 4556 -> 4604 B (+48) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…while streaming Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… snippets Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Deploying chat-widget with
|
| Latest commit: |
9bd8262
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8899972c.chat-widget-ejc.pages.dev |
| Branch Preview URL: | https://56-inline-citations.chat-widget-ejc.pages.dev |
Contributor
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #56
What
Opt-in
citationsoption (boolean | { maxSources, favicons }, default off, fails closed) onChatWidget,ClaudiusConfig,<claudius-chat citations citations-max-sources citations-favicons>, andwidget.citationsin client configs. When it is on and a reply carriessources:[n]markers in the reply render as numbered accent chips;[1, 3]and[1][3]both work, out-of-range or malformed brackets stay text;maxSources(default 5) cards show before "Show all";The widget sends
citations: truewith each request. The worker then numbers its RAG excerpts in the system prompt to matchsources(two chunks of one page share a number) and appends a citing instruction. Independently of the flag, every source now carries asnippet, sources are limited to the excerpts that fitmaxContextChars(so the prompt and the cards always agree), and/api/chat/streamannouncesevent: sourceswith the first upstream event so chips render while the text streams.donestill carriessources.Docs: new
configuration/citations.md; widget options, localization, clients, theming, RAG, and a new streaming section in the REST reference;CLAUDE.md. Design and plan are indocs/plans/2026-09-27-inline-citations-*.md.Behaviour changes outside the opt-in
**bold**or*italic*are now linked (the inline renderer's leaf step is shared).Decisions made without you (see the design doc for the reasoning)
@1tag).sourcesSSE event in addition todone.sources, emitted with the first upstream event so a first-event upstream error is still a JSON 503.<origin>/favicon.ico, no third party, no referrer,favicons: falseto switch off. Cards mount only when the footer is opened, so no request happens before that.[1, 3]groups supported as well as[1][3].Verification
vitest runvitest runvitest runtsc --noEmit,eslint src/,prettier --check,typedoc --emit none,vite build(lib + iife),publint,attwcitations.spec.tsastro buildsize-limitBundle deltas against
main(measured withsize-limit --jsonon both trees, limits set to measured + 5%):claudius.iife.jsgzip 71,954 → 74,454 B (+2,500), brotli +2,162, raw +9,462;claudius.jsgzip +3,065; CSS gzip +60.Review
An independent whole-branch review ran before this PR was opened: no critical findings, two important (a first-event upstream error would have opened the SSE before failing, and a marker glued to a URL broke the link) and five minor. All seven are fixed with a failing test first (
fix:commits). The worker's localtsc -p .has 15 pre-existing errors inattachments.tstypings that predate this branch.🤖 Generated with Claude Code