Skip to main content

Chat UI Formatting and Hover Sources

Summary​

Updated the Quantago chat UI so grounded source annotations render as inline hoverable sentence regions instead of leaking raw [source](#qg=...) markdown or encoded payload fragments. The chat renderer now preserves markdown structure while cleaning legacy source debris, renders fenced code with the same CodeMirror experience used by the bot Code tab, and supports source tooltips with Copy and Pin actions.

Reasoning​

Stored chat messages can contain long encoded grounding payloads, including older links with raw parentheses in excerpts. Those broke markdown link parsing and could leak encoded debris into the visible answer or into code blocks. The frontend now normalizes and shields valid grounding links before cleanup, preserves newlines so fenced code remains fenced, and groups source links before ReactMarkdown's anchor renderer runs so paragraphs, list items, and headings can all become hoverable grounded regions.

Key Changes​

  • Added math rendering with remark-math, rehype-katex, and KaTeX CSS.
  • Rendered chat code blocks with @uiw/react-codemirror and language extensions matching the bot Code tab style.
  • Fixed grounding payload encoding in frontend, backend, and semantic-search by percent-encoding raw parentheses.
  • Added recovery for older broken #qg source links and cleanup for orphaned encoded source debris.
  • Preserved markdown newlines during cleanup to keep fenced code blocks intact.
  • Added hover source tooltips with Sources at the top and Copy/Pin actions in the footer.
  • Grouped source links directly in ReactMarkdown parent renderers so tooltips work for paragraphs, list items, and headings.

Verification​

Production bundle tested on the live Quantago chat page after deploy:

sourceGroupCount: 68
encodedCount: 0
rawSourceCount: 0
qgInCode: 0
codeEditorCount: 5
hasFlattenedFence: false
tooltipVisibility: visible
tooltipOpacity: 1
hasSourcesLabel: true
hasCopy: true
hasPin: true
hoverBackground: rgba(250, 204, 21, 0.15)

Deployed commits to both develop and main, with GitHub Actions successful for dev and production.