Skip to content

Traffic: render model-written Markdown in answers, thinking and system prompts - #370

Merged
fylorn merged 1 commit into
devfrom
markdown-prose
Oct 24, 2026
Merged

fylorn merged 1 commit into
devfrom
markdown-prose

Conversation

@fylorn

@fylorn fylorn commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Answers in a request's Content › Parsed view and in a session's conversation were shown as raw text, so **bold**, # headings, lists and tables appeared as their markup characters. They are now rendered.

  • Rendered: assistant text, thinking, system prompts. User messages stay as typed.
  • marked is used only as a tokenizer; tokens are drawn as React elements (src/traffic/Markdown.tsx). No HTML is injected: HTML in the model's text is shown as text, links show their text with the URL on hover and are not clickable (clicking would navigate the app window), images show their alt text and are never fetched.
  • Single newlines are line breaks (breaks: true), matching how models write answers.
  • Security-hit highlighting still applies to every text leaf, including code spans and code blocks.
  • While an answer streams, top-level blocks are memoized by their source, so only the last block re-renders; the caret and the "…" of a collapsed answer sit at the end of the last line.

Tests: src/traffic/Markdown.test.tsx (formatting, line breaks, HTML stays text, links not clickable, hits highlighted, tail placement). Checked visually in light and dark.

🤖 Generated with Claude Code

…m prompts

Answers in a request's Content tab and in a session's conversation now show
headings, bold, lists, tables and code blocks instead of the raw `**` and `#`.
What the user typed is still shown as-is.

marked only tokenizes; the tree is drawn as React elements, so HTML in the
model's text stays text, links are not clickable (they would navigate the app
window) and images are not fetched. Security hits are still highlighted, and
while an answer streams only its last block re-renders, with the caret at the
end of the last line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 2a86a99 into dev Oct 24, 2026
6 checks passed
@fylorn
fylorn deleted the markdown-prose branch October 24, 2026 13:07
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant