Skip to content

Render the user's own Markdown messages in the chat - #607

Open
thiblahute wants to merge 1 commit into
powerfooI:mainfrom
thiblahute:upstream/chat-user-markdown
Open

thiblahute wants to merge 1 commit into
powerfooI:mainfrom
thiblahute:upstream/chat-user-markdown

Conversation

@thiblahute

Copy link
Copy Markdown
Collaborator

Summary

Render the user's own messages written in Markdown in the chat, as the agent's replies are.

Why

The chat renders the agent's replies as Markdown but always showed the user's messages as plain text, so a message with a code fence, a list or a link showed its raw syntax. Rendering every user message as Markdown would mangle ordinary text, though: a path like src/**/*.ts or a sum like 2 * 3 would turn into emphasis.

What changed

  • web/src/userMarkdown.ts (new): looksLikeMarkdown recognises a code fence, inline code, a link, a list item, or emphasis set off by spaces (not inside a word or path).
  • web/src/components/AgentHistoryChat.tsx: UserMessageText shows a user message as typed unless it looks like Markdown, in which case it renders through the same MarkdownPreview (sanitised the same way) with line breaks kept. Used for sent messages, the text around uploaded images, and messages still on their way.
  • FEATURES.md (Agent History).

Verification

  • bun test web/src/userMarkdown.test.ts web/src/components/UserMessageText.dom.test.ts web/src/components/AgentHistoryChat.test.ts: what counts as Markdown and what does not; a code fence and inline code rendered; plain text with paths and * shown as typed, newlines kept; raw HTML (<script>, onerror) sanitised away.
  • bun run format:check, bun run lint, bun run typecheck:bun, bun run build:web, bun run test:quick with an isolated HOME/TMPDIR.
  • Asset budget: unchanged (initial JS 832.3/833 KiB, gzip 256.7/257 KiB).

Manual checks

  • Send a message with a fenced code block and a list: it renders as the agent's replies do.
  • Send fix src/**/*.ts and my_file_name: it shows as typed.

A message the user wrote in Markdown (a code fence, inline code, a list,
a link, emphasis) now renders in the chat as the agent's replies do,
sanitised the same way, instead of showing its raw syntax. Plain text,
and text that only holds Markdown's characters (an `_` or a `*` in a
path, a word or a sum), still shows as typed.
@github-actions github-actions Bot added the enhancement New feature or request label Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant