feat(ui): add copy button to user message code blocks#20946
Open
sandikodev wants to merge 7 commits intoanomalyco:devfrom
Open
feat(ui): add copy button to user message code blocks#20946sandikodev wants to merge 7 commits intoanomalyco:devfrom
sandikodev wants to merge 7 commits intoanomalyco:devfrom
Conversation
Parse backtick syntax in user message text before rendering. Triple backticks render via Markdown component (with syntax highlight), single backticks render as inline <code> elements. Closes anomalyco#12791
- Replace Markdown component with native pre/code render to eliminate excess spacing from prose styles - Auto-collapse code blocks exceeding 8 lines with show/hide toggle - Add styling for inline code and code block in user-message-text
Add ui.message.codeBlock.showMore and ui.message.codeBlock.showLess keys to en.ts and use them in CodeBlock component instead of hardcoded strings.
Add ui.message.codeBlock.showMore and ui.message.codeBlock.showLess to all 16 non-English locale files.
Reduce margins on headings, paragraphs, hr, pre, and table elements to improve visual density in AI responses. Values were previously too large (2rem/2.5rem) causing excessive whitespace around code blocks and section dividers.
When a fenced code block is extracted from user message text, the closing ``` leaves trailing newlines that become orphan whitespace in the next text segment. These are artifacts of the markdown syntax, not intentional user spacing, so they are trimmed. This is open for discussion — an alternative is to preserve them and let the container handle spacing via CSS.
Add a copy button to the header bar of code blocks in user messages, consistent with the existing copy button in AI response code blocks. Uses IconButton component for design system consistency. Closes anomalyco#20943
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one directly related PR: Related PR:
No duplicate PRs found with overlapping functionality. PR #20946 is complementary to #20942, building on its code block improvements by adding copy functionality. |
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.
Issue for this PR
Closes #20943
Type of change
What does this PR do?
While working on #20942, I noticed code blocks in user messages had no
copy button — unlike code blocks in
AI responses. This adds one to thetop-right of the language label bar, using IconButton for consistency
with the rest of the UI.
This PR depends on #20942 and is submitted as draft until that one merges.
How did you verify your code works?
Tested manually — button appears on hover, copies to clipboard, shows
check icon briefly then resets.
Screenshots / recordings
1. Copy button visible (hover state)

2. Copied state

Checklist