Skip to content

Add copy buttons for assistant message text blocks #574

@SheferKagan

Description

@SheferKagan

Summary

Add a dedicated copy button for individual copyable sections inside assistant chat messages.

Today the chat UI has a message-level copy action, but users often only want to copy one specific block from an assistant response: a command, code snippet, config snippet, prompt, JSON payload, quoted/styled text box, etc.

Desired behavior

When an assistant message renders a distinct copyable block, that block should expose its own copy button.

Examples of copyable blocks:

  • fenced markdown code blocks
  • command snippets
  • JSON/config snippets
  • styled text boxes/callouts that contain copyable text
  • quoted/styled blocks where the intent is to copy only that section

The button should copy only the contents of that block, not the entire assistant message.

Example

Assistant response:

Run this:

[code block]
npm run build
[Copy]

Then check the output.

Clicking the block-level copy button should copy only:

npm run build

not the full assistant response.

UX notes

  • Keep the existing whole-response copy action.
  • Add the section-level copy affordance on or near the block itself, likely top-right.
  • Use a clear icon + tooltip, consistent with existing chat copy buttons.
  • Provide copied feedback, e.g. icon changes/checkmark or tooltip text changes to Copied.
  • Avoid adding visual noise to normal paragraphs.
  • The button should work for both code blocks and styled/callout-like text boxes.
  • Long blocks should keep the copy button visible and aligned.
  • Copy should preserve the plain text contents of the block.

Acceptance criteria

  • Code/fenced blocks in assistant messages have a dedicated copy button.
  • Styled text boxes/callouts in assistant messages can expose a dedicated copy button when they contain copyable text.
  • Clicking a block copy button copies only that block's text.
  • Message-level copy still copies the whole assistant message.
  • Copy feedback is visible.
  • Layout remains stable for long blocks and narrow widths.
  • No copy button is added to normal prose paragraphs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions