feat: Render Markdown in chat and query output using rich#22
Open
KylinMountain wants to merge 6 commits intomainfrom
Open
feat: Render Markdown in chat and query output using rich#22KylinMountain wants to merge 6 commits intomainfrom
KylinMountain wants to merge 6 commits intomainfrom
Conversation
Collaborator
Author
Use rich's Live + Markdown to progressively render LLM responses in the chat REPL with proper formatting (headings, bold, code blocks, lists, etc.) instead of raw text output. Falls back to plain text when --no-color is set. Tool call lines still use prompt_toolkit styled output.
Apply the same rich Live + Markdown streaming render to `openkb query` as was added to chat. Falls back to plain text when stdout is not a tty.
f206c75 to
5d2b4b4
Compare
Collaborator
Author
Code reviewFound 1 issue:
Lines 153 to 160 in 5d2b4b4 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Collaborator
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- Create a fresh Live instance after each tool call instead of
stop/start on the same instance, preventing the auto-refresh
thread from overwriting stdout text with CURSOR_UP sequences
- Respect NO_COLOR env var in query.py (consistent with chat.py)
- Fix print("\n") → print() in chat.py finally block to avoid
extra blank line when Live is active
Custom Rich Theme: bold headings without color, dark background for inline code, subtle link/list/blockquote colors. Shared via _make_rich_console() used by both chat and query.
- Headings: blue (#5fa0e0) - Code: yellow-ish on dark background - List bullets: green (#6ac0a0) - Bold: bright white, italic: light gray - Paragraph text: light gray for visibility
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
rich.live.Live+rich.markdown.Markdownto progressively render LLM responses with proper terminal formatting (headings, bold, code blocks, lists, etc.)openkb chat(interactive REPL) andopenkb query(single-shot)--no-coloris set (chat) or stdout is not a tty (query)rich>=13.0as an explicit dependencyTest plan
python -m pytest tests/— 197 passedopenkb chat— verify headings, bold, code blocks render with formattingopenkb chat --no-color— verify plain text fallbackopenkb query "question"— verify formatted outputopenkb query "question" > file.txt— verify no ANSI codes in file