feat: interactive retrieval citations with unified hover cards - #3654
Open
EDDIWARD wants to merge 13 commits into
Open
feat: interactive retrieval citations with unified hover cards#3654EDDIWARD wants to merge 13 commits into
EDDIWARD wants to merge 13 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…ions - Remove the CitationWriteGuard tool and the agent-level 'preserve citations in tool output' toggle from backend, SDK, SQL migrations and frontend UI - Show a source-card hover popover on citation markers in both chat pages - Keep click-to-select source card working; gate sentence-level highlight behind ENABLE_CITATION_CLICK_HIGHLIGHT flag (default off)
…rieval-citations-clean # Conflicts: # frontend/app/[locale]/newchat/ui/markdown-text.tsx # frontend/app/[locale]/newchat/ui/sources-panel.tsx
- Extract shared highlight helpers (escapeRegExp, extractHighlightTerms, splitSourceTextIntoSentences) into frontend/lib/citationHighlight.ts, removing duplication between the /chat right panel and /newchat sources panel - Add keyboard activation (Enter/Space, role=button, aria-label) to citation markers in markdownRenderer so interactive elements are accessible - Consolidate the three duplicated search-result formatting loops in knowledge_base_search_tool.py into one _format_search_results helper - Extend unit tests to cover score/highlight-term merging, no-mutation guarantees, and source_search persistence of retrieval highlight terms
- Extract CiteIndexBadge and HighlightedChunkText into components/common/highlightedSourceText.tsx, removing duplicated copies from the /chat right panel, /newchat sources panel, and cite marker - Unify the three source-card variants in sources-panel around a shared SourceCardBody - Split extractHighlightTerms into focused helpers to reduce cognitive complexity and share the term merge/dedupe pipeline via mergeHighlightTerms - Use a native <button> for citation markers in markdownRenderer and flatten nested ternaries flagged by SonarCloud - Replace escaped string regexes with String.raw / RegExp.exec in getCitedAnswerContext
EDDIWARD
marked this pull request as ready for review
August 18, 2026 08:38
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.
Summary
Interactive retrieval citations in both chat experiences.
Clicking a marker opens the right panel and selects + scrolls to the matching source card, in both
/newchatand the legacy/chatpage.Sentence-level highlight inside the retrieved Chunk is kept but gated behind
ENABLE_CITATION_CLICK_HIGHLIGHT(frontend/const/citation.ts, default off). Flip the flag to true to re-enable it.Removed the citation write guard experiment entirely: the
CitationWriteGuardtool, the agent-level "preserve citations in tool output" toggle (backend + frontend UI), and the related SQL migration.Why
Users can see which retrieved source supports a statement directly from the marker (hover card), and jump to the matching source card (click) in both chat pages. The sentence-level Chunk highlight stays available behind a feature flag while its visual behavior is still being tuned.
Validation
tsc --noEmittype check passed (after merging latest develop).test_core_agent(142),test_knowledge_base_search_tool(76),test_context_utils(27).prompt suggestion
If the user wishes not to include citation tags in his/her tool content, he/she is recommended to utilize agentic level prompt as such:(using few-shot example) These prompt enables citation in normal conversations but not included in contents of tools (such as file writer).


![Uploading image.png…]()