Skip to content

Copy inline code from chat, and make copying work on every connection #23

Closed

Description

@tannerpolley

Goal

Make it easy to copy anything an agent shows in code formatting in the main chat (commands, paths, snippets), to paste somewhere else.

Owner request (2026-10-12).

What exists today

  • Fenced code blocks already have an always-visible "Copy code" button in their header, next to wrap and Run (ChatMarkdown.tsx ~929–1010, MarkdownCodeBlockFrame). It covers blocks at any depth, including diff and shell blocks. Mermaid diagrams have Copy below the diagram.
  • Gaps:
    1. Inline code (single backticks, used constantly for paths, commands and ids) has no copy action (ChatMarkdown.tsx ~3236–3257). It only becomes a file chip when the text looks like a path.
    2. The copy handler uses navigator.clipboard directly and silently does nothing when it's unavailable (ChatMarkdown.tsx ~891–894), for example in a browser over plain http on a LAN or Tailscale address. The repo's writeTextToClipboard helper is not used.
    3. A <pre> with anything other than a single <code> child falls back to a bare <pre> with no frame or Copy (ChatMarkdown.tsx ~529–553).

Proposed

  • Inline code: click to copy, with brief "Copied" feedback. Keep file-chip behavior for paths, and offer copy there too, for example from the chip's menu.
  • Fallback: use writeTextToClipboard (or add a fallback to it) so copying works on every surface and connection, and show feedback when it fails instead of failing silently.
  • Bare <pre>: give the fallback the same frame and Copy button.

Small and self-contained. Mobile is out of scope.

Activity

  1. tannerpolley commented on Oct 13, 2026

    @tannerpolley
    OwnerAuthor

    Done on main (f82de03, 246b862); ships in the next release (v2.12):

    • Click inline code to copy it, or Tab to it and press Enter or Space. Screen readers announce it as copyable, and the text stays selectable.
    • Every copy in chat (code blocks, tables, file chips, inline code) goes through the shared clipboard helper, which falls back to execCommand over plain HTTP. A failed copy shows "Couldn't copy".
    • A bare <pre> gets the code-block frame and Copy, and keeps its line breaks.
      Reviewed by GPT-6.1 Sol; review findings fixed and covered by behavior tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequested improvement or new capability.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions