refactor: tool-based RAG UI with block-based rendering - #1047
Conversation
Update chat UI to support the new tool-based RAG pipeline from stampy-chat (StampyAI/stampy-chat#204). - Block-based rendering: thinking, tool_use+tool_result (merged), text - Turn-based SSE protocol: handle 'turn' events with tool results - Citations extracted from tool_result ui_output blocks - Cross-turn citation reference resolution via priorCitations - Markdown rendering with react-markdown, KaTeX math support - Memoized CitationMarkdown component (avoids recreating component types per render causing unmount/remount flicker) - Tool calls displayed with friendly names in collapsible details - Parallel tool_use blocks matched to tool_results by id (not adjacency) - Model list updated to dateless Anthropic IDs (claude-sonnet-4-6 etc.) - CHATBOT_URL: production default with localhost auto-detection for dev - Payload size limit raised to 200KB for block-structured history - Glossary injection skips pre and details elements (prevents corrupting tool result XML display) - Removed: useIsMobile/mobile prop (unused), DOMPurify (replaced by react-markdown's React-native rendering) - Kept upstream's useGlossaryInjection and glossary popup support
| import {Link} from '@remix-run/react' | ||
| import MarkdownIt from 'markdown-it' | ||
| import DOMPurify from 'dompurify' | ||
| import Markdown from 'react-markdown' |
There was a problem hiding this comment.
switching to react-markdown for the chatbot for flexibility. also makes it reasonably easy to toss in katex (math rendering), which we want anyway.
| "isbot": "^5.1.28", | ||
| "katex": "^0.16.23", | ||
| "lodash": "^4.17.21", | ||
| "markdown-it": "^14.1.0", |
There was a problem hiding this comment.
markdown-it isn't going away because it's used in articles. I poked claude several times about maybe could we just do one or the other, but the conclusion ended up being "well, maybe, but the bottleneck is human testing effort, and react-markdown handles more of what we need for chatbot ui".
|
Oh crud, for some reason I didn't merge this when talking to @nerualauren earlier! Anyway, I think lauren should merge this since apparently it needs to be done at the same time as another PR lauren has got otherwise things will break. |
Companion PR to StampyAI/stampy-chat#204 -- updates the chat UI to support the new tool-based RAG pipeline.
Summary
turnevents carrying tool results alongside existingstreaming/thinkingeventstool_result.ui_outputblocks instead of a separatecitationsSSE eventpriorCitationsaccumulated across conversation turnsreact-markdownwithremark-math/rehype-katexfor math renderingwithCitationProcessingrecreated component types every render, causing React unmount/remount flicker during streamingclaude-sonnet-4-6,claude-opus-4-6, etc.)Test plan
chat.stampy.ai, local dev hitslocalhost:3001🤖 Generated with Claude Code