Problem
People need to copy code from an answer without missing characters or including line numbers and labels.
Solution
Put a Copy button and a language label on each code block. Copy the source exactly, keeping its indentation and excluding display labels or line numbers.
Offer Run only when the app can execute the code. Explain where it will run and what it can access. For Apply, show the destination file and proposed changes before asking people to confirm.
Wait until the code is complete before enabling these actions. If generation stops early, label the block as incomplete.
Use when
Answers contain code, configuration, or commands that people will use elsewhere.
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
Controls on every block can crowd an answer. Run and Apply require more safeguards than Copy because they can affect files or systems. Their presence should not imply that generated code has been tested.
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 provides space for working on larger code files. Response actions apply to the whole answer. Suggestion diff shows proposed changes before applying them.
Structured output handles formats such as tables. Streaming response affects when a code block is ready to use.