Skip to content

Render user messages as markdown#263

Merged
brsbl merged 12 commits into
mainfrom
bb/user-message-markdown
Jun 19, 2026
Merged

Render user messages as markdown#263
brsbl merged 12 commits into
mainfrom
bb/user-message-markdown

Conversation

@brsbl

@brsbl brsbl commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

What

User message bubbles in the timeline now render markdown — matching the markdown the prompt box recently started producing. Previously a sent message showed # heading, - list, **bold** as literal characters (assistant messages already rendered markdown; user messages didn't).

How

  • New markdown-prompt-mentions pipeline. The existing markdown mention path (markdown-thread-mentions) only recognizes the @thread:<id> token by regex and would silently drop file (@src/foo.ts) and slash-command (/deploy) mentions. The new pipeline replaces each mention's exact source span (by offset, from the editor's authoritative mentions array) with an inert private-use sentinel before parsing, then renders it back into the shared PromptMentionPill — so thread, file, and command mentions all keep their pills under markdown. The generated/system-message path keeps the token/regex approach (its @thread: token is template-injected, not authored).
  • MarkdownPreview gains a promptMentions prop that activates the offset pipeline (+ remark-breaks for single-newline handling). The existing threadMentions path is unchanged.
  • CollapsibleMessageText renders via MarkdownPreview, preserving the muted [bb …] prefix, the 4096-char cap, and collapse/expand — reworked from a source-line clamp to a max-h-[15lh] visual clamp (block markdown doesn't line-clamp cleanly). > quotes now render as native markdown blockquotes.

Tests / verification

  • New node-env unit tests for the substitution engine + remark plugin (8 passing).
  • New jsdom render tests covering thread/file/command pills + markdown structure (CI — jsdom isn't installed in every local checkout).
  • New Ladle story thread/timeline/User Message Markdown (formatting · mentions · blockquote · long/collapsible).
  • tsc, ESLint, Prettier all clean.

🤖 Generated with Claude Code

brsbl and others added 12 commits June 19, 2026 04:23
Route the user message bubble through MarkdownPreview so the markdown the prompt
box now produces (headings, lists, bold/italic/code, blockquotes) renders
instead of showing as literal text.

Adds an offset-based prompt-mention pipeline (markdown-prompt-mentions) that
substitutes each mention's source span for an inert sentinel before parsing,
then renders it back into the canonical pill — so thread, file, and slash-command
mentions all keep their pills under markdown (the existing @thread-token path
only handled threads). Preserves the muted prefix, the 4096-char cap, and
collapse/expand (now a max-height clamp, since markdown blocks don't line-clamp).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The ParentChildSystemMessages story omitted resolveSegmentLinkHref, so the
system-message markdown path left its @thread: tokens as literal text instead
of pills. Pass the resolver (matching the agent-initiated rows) so the thread
mentions render as linked pills.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	apps/app/src/components/ui/markdown-preview.tsx
Bump the user message bubble from rounded-md to rounded-2xl so it reads like a
chat message bubble.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover the markdown rendering path of the user message bubble: heading/bold/list/
code structure, thread + file mention pills, `> ` blockquotes, the rounded
bubble shape, and a plain-text message.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bump the user message bubble's left/right padding (p-2 -> px-3.5 py-2) so the
text sits comfortably inside the rounded chat bubble.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Match the common AI-chat user-bubble treatment: narrower content cap
(max-w 80% -> 70%), roomier balanced padding (px-4 py-2.5), and a hairline
border so the bubble reads as a distinct message against the low-contrast fill.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use the subtle border-seam token (a lighter divider) instead of border so the
bubble edge reads as a hairline rather than an outline.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Softer jump from main's 6px. Make the bubble test radius-agnostic (assert on the
fill, not the radius class).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Give the error status decoration a subtle semantic red, but only when it is an
emphasized error — the one that actually fails the thread (system/terminal error
rows). Transient work-row errors the agent recovers from (a failed command, an
errored fetch) and denied/interrupted annotations stay muted. The small mono +
opacity-75 keep even the red subtle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@brsbl brsbl merged commit 5c2dbd5 into main Jun 19, 2026
6 checks passed
@brsbl brsbl deleted the bb/user-message-markdown branch June 19, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant