Skip to content

TUI: copy an assistant reply's raw markdown to the system clipboard (/copy + Ctrl+Y) #362

Description

@erain

Copying an assistant response out of the TUI to paste elsewhere is painful: terminal selection drags in glamour styling (ANSI codes, box-drawing, wrapped/indented lines), so the pasted text is mangled. The clean source already exists — the transcript stores each assistant item's raw markdown in transcriptItem.Text, separate from the glamour-rendered transcriptItem.Rendered (cmd/glue/tui/transcript.go:38-42, finalized in handleTurnDone at cmd/glue/tui/tui.go:1206-1211). We just need to plumb that raw text to the clipboard.

Plan:

  1. /copy [N] slash command — copies the most recent assistant reply's raw markdown, or reply N (1-based over assistant turns) when an argument is given. Added to slashSpecs() so it shows in /help and the / picker.
  2. Ctrl+Y keybinding — copies the most recent assistant reply instantly, no typing.
  3. Delivery via OSC 52 (github.com/aymanbagabas/go-osc52/v2, already an indirect dep → promote to direct). Works locally and over SSH with no external binary, unlike atotto/clipboard. Sequence is written to the tty so it doesn't fight bubbletea's alt-screen stdout renderer.
  4. A · copied reply N (1234 chars) to clipboard system line confirms; friendly messages when there's no assistant reply yet or N is out of range.

Pointers: cmd/glue/tui/tui.go:657 (handleInputKey, add Ctrl+Y near the Ctrl+C block), :945 (handleSlash dispatch), cmd/glue/tui/commands.go:56 (slashSpecs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions