Repository navigation
feat: add a copy button to Markdown code blocks - #581
Merged
Merged
Conversation
Every fenced code block gets the chat's copy button in its top-right corner, once per fence even when a long block is split across root-list items. The button and the two-second "copied" check it shows move out of the chat into widgets::copy as copy_button and CopiedMark, which the chat and MarkdownState now share, so one owner holds the feedback behaviour.
Tryanks
enabled auto-merge
October 3, 2026 04:11
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
Every fenced code block in Markdown gets a copy button in its top-right corner. It is the same ghost icon button the chat uses on messages, with the same two-second check mark. Right-click "Copy code" stays. Mermaid diagrams keep the right-click copy only.
A long block split across several root-list items shows exactly one button, and that button copies the whole fence, matching what the context menu copies.
Evidence
After: gallery example in light and dark at 980 px shows the button in the block's corner.
code_block_copy_button_copies_the_whole_fencedrives the real root list, clicks the button of a 100-line fence that is split across items, and asserts the clipboard holds the whole fence without the trailing newline.The click-to-check feedback in the live app was not exercised through the desktop automation harness (its synthetic clicks did not reach the unfocused GPUI window). The clipboard contract is covered by the test and the check icon reuses the chat's existing path.
Merge Danger
Door: two-way
UI only, no state or protocol change.
Blast Radius: layout
Code blocks gain a chip over the right end of their first line. The chip has a muted background so code under it stays readable, but a long first line in a narrow block now ends under it.