claude-code - 💡(How to fix) Fix Click-to-copy affordance on agent-designated content

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Add a clickable [copy] affordance that Claude Code renders inline after content the agent marks as copy-worthy (shell commands, code blocks, file paths, identifiers). Clicking it copies the original text verbatim to the system clipboard. This replaces both manual text selection and the current request-driven clipboard workflow.

Root Cause

  1. Client-side affordance. Claude Code renders a small [copy] control next to any designated span. The user clicks it when ready, and the original bytes are written to the system clipboard. Because the copied text comes from the agent-supplied source rather than the rendered buffer, it is free of wrapping, indentation, and styling artifacts.
RAW_BUFFERClick to expand / collapse

Summary

Add a clickable [copy] affordance that Claude Code renders inline after content the agent marks as copy-worthy (shell commands, code blocks, file paths, identifiers). Clicking it copies the original text verbatim to the system clipboard. This replaces both manual text selection and the current request-driven clipboard workflow.

Problem

Two recurring frictions make it hard to get text out of a Claude Code session and into another terminal or editor:

  1. Selecting rendered output is unreliable. Text in the TUI has been reflowed for display — line wrapping inserts newlines, list and code indentation adds leading whitespace, and markdown styling is baked into the rendered glyphs. Copying a command by mouse selection therefore captures wrapping artifacts and indentation that must be cleaned up by hand before the command will run.

  2. The current clipboard workflow is request-driven and fragile. Putting text on the clipboard today requires explicitly asking the agent to do so. The clipboard is a single shared slot, so any later write clobbers the previous contents before the user is ready to paste. A dedicated turn is often spent solely to place one command on the clipboard, which is an expensive use of context for a trivial result.

The underlying mismatch is that clipboard population is currently push-on-request (the agent writes eagerly when asked), when what the user wants is pull-on-demand (the content is offered, and the user takes it at the moment of use).

Proposed solution

A two-part mechanism:

  1. Agent-facing primitive. A way for the agent to designate a span of text as copy-worthy — for example, a tool call or an inline markup marker that wraps the exact bytes to be copied. The agent supplies the canonical text once; rendering and clipboard handling are left to the client.

  2. Client-side affordance. Claude Code renders a small [copy] control next to any designated span. The user clicks it when ready, and the original bytes are written to the system clipboard. Because the copied text comes from the agent-supplied source rather than the rendered buffer, it is free of wrapping, indentation, and styling artifacts.

This makes the workflow pull-on-demand: the content is offered without committing the clipboard, the user takes it at the moment of use, and no conversational turn is spent managing the clipboard.

Feasibility

Both required terminal capabilities are standard and widely deployed:

  • Click detection via the SGR mouse protocol (xterm 1006). A full-screen TUI that owns the input loop — which Claude Code is — can enable mouse tracking, render the affordance, hit-test click coordinates against it, and act. Every mainstream TUI framework (Textual, Bubble Tea, ratatui) implements clickable widgets this way.

  • Clipboard write via OSC 52 (ESC ] 52 ; c ; <base64> ESC \). The application emits the escape sequence and the terminal places the decoded text into the system clipboard verbatim. This needs no external helper (wl-copy, xclip), works over SSH, and never touches the rendered text, so no wrapping or markdown mangling is possible.

Why this belongs in Claude Code

The TUI owns the input loop and the render buffer. Mouse hit-testing and OSC 52 emission both require that ownership, so the feature cannot be supplied from inside a conversation or by an external skill — it has to be implemented in the client itself.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Click-to-copy affordance on agent-designated content