Repository navigation
Render the user's own Markdown messages in the chat - #607
Open
thiblahute wants to merge 1 commit into
Open
thiblahute wants to merge 1 commit into
thiblahute wants to merge 1 commit into
Conversation
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.
This branch has not been deployed
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
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/**/*.tsor a sum like2 * 3would turn into emphasis.What changed
web/src/userMarkdown.ts(new):looksLikeMarkdownrecognises 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:UserMessageTextshows a user message as typed unless it looks like Markdown, in which case it renders through the sameMarkdownPreview(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:quickwith an isolatedHOME/TMPDIR.Manual checks
fix src/**/*.ts and my_file_name: it shows as typed.