Problem
A fenced block of code sits in the middle of an answer. Its whole purpose is to end up somewhere else, and getting it there by selecting text with a mouse picks up line numbers, drops the last character, or misses the top line entirely.
Solution
Attach a small control cluster to the block itself. Copy first, because copy is what nearly everyone does. Then whatever the surrounding product can honestly offer: a language label, a run control where there’s somewhere to run it, and an apply control where there’s a file to apply it to.
Copy has to be exact. The clipboard write should carry the raw source with original indentation and no decoration, which means line numbers, the language label, and any diff markers have to be excluded from the copied text rather than merely styled differently. Selecting rendered code with a pointer is exactly the operation that picks up all three, which is why a copy control is worth having even though the text is right there.
The language label earns its space by doing two jobs: it tells the reader what they’re looking at, and it’s the honest place to admit uncertainty when the model didn’t specify. A block silently rendered as one language and highlighted wrong is a small, constant irritation.
Apply is the action worth the most and the one carrying real consequence. Writing generated code into a file is a change to the viewer’s work, and HAX guideline 16 puts the obligation before the action rather than after: name the file, show the change as a diff, and require an explicit confirmation. An apply control that writes silently is the fastest path to someone losing work they can’t recover.
Run has the same shape with a sharper edge. Executing generated code is the point at which a suggestion becomes an action with effects, and the questions of where it runs, with what access, and what happens on failure belong in the interface rather than in documentation.
Streaming complicates all of this. A block still arriving is incomplete, and a copy control that appears at the opening fence hands over half a function. The controls should wait for the closing fence, and a block whose fence never arrives because generation was stopped needs to say so rather than presenting itself as complete.
Use when
Answers regularly contain code, configuration, or commands that are meant to be used rather than read.
Don’t use when
The snippet is illustrative. A three-word inline example wants inline code styling, and hanging a control cluster off it adds chrome to something nobody will copy.
Trade-offs
A control row on every block adds visual weight to answers that are already dense, and an answer with six blocks carries six of them. Copy is nearly free; run and apply are expensive to build well and dangerous to build carelessly. Line numbers help discussion and actively hurt copying, so a product wanting both has to keep two representations. A run control implies the code was checked. Nothing in the pipeline guarantees that.
Checklist
- Does copy carry the raw source with no line numbers or markers?
- Is indentation preserved exactly?
- Does the control cluster wait until the block has finished streaming?
- Is the language labelled, and is a guess shown as a guess?
- Does apply name the target file and show a diff before writing?
- Is an apply reversible in one step?
- Where does a run control execute, with what access?
- Is copy reachable from the keyboard?
- Is there feedback confirming the copy happened?
- What does an unterminated block from a stopped generation look like?
Compare
ChatGPT puts copy on every block and adds a canvas path for code meant to be worked on rather than lifted, which separates reading from editing. Claude promotes substantial code into an artifact with its own controls and version history, so the block in the transcript stays a reference rather than the working copy. Cursor makes apply the primary action and writes the change into the open file as a reviewable diff. It’s the highest-consequence version of the pattern here, and the most gated. Perplexity keeps the cluster to copy alone. Code there is evidence in an answer—not work in progress.
Related
Artifact panel is where a block graduates once it becomes the thing being worked on. Response actions is the same idea at turn scale. Suggestion diff is what an apply control should show before writing. Structured output is the sibling problem for tables. Streaming response determines when these controls may appear.