Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

kiro-cli: /copy to clipboard copies rendered TUI buffer, not raw message text

Open rndjams opened this issue 6 months ago • 4 comments

[DRAFT] kiro-cli: /copy to clipboard copies rendered TUI buffer, not raw message text


Operating System: macOS 26.4.1, Apple Silicon

Kiro Version: 2.4.1 (kiro-cli)


Bug Description

The /copy to clipboard slash command in kiro-cli copies the rendered terminal buffer rather than the raw message text. Every paste produces syntactically broken output: heredoc content gains the TUI panel's 2-space left indent, and lines that exceed the terminal width are split at the column boundary.

I used /copy to clipboard on a response containing a shell heredoc, then pasted the result into a terminal. The code was broken before I could run it.


Steps to Reproduce

  1. Start a kiro-cli session: kiro-cli
  2. Ask for a shell snippet that includes a heredoc, e.g.:

    Write a shell config file using a heredoc. Include at least one line with a long value likely to exceed ~80 columns.

  3. When the response appears in the TUI panel, run /copy to clipboard
  4. Paste into a terminal (iTerm2, macOS Terminal, or any shell prompt)
  5. Observe the pasted content

Minimal reproducible example — response contains:

cat > ~/.config/app/config << 'EOF'
[settings]
session_valid = python3 -c "import os,time; exit(0 if time.time() < os.path.getmtime(os.path.expanduser('~/.cache/app/token')) + 7200 else 1)"
token_refresh = refresh-token --daemon
EOF

Pasted result:

cat > ~/.config/app/config << 'EOF'
  [settings]
  session_valid = python3 -c "import os,time; exit(0 if time.time() < os.path.getmtime(os.path.expanduser('~/.cache/app/token')) + 7200
  else 1)"
  token_refresh = refresh-token --daemon
EOF

Expected Behavior

/copy to clipboard should place the raw message text on the clipboard — the same plain-text/Markdown string that was passed to the TUI renderer, with no panel padding and no column wrapping. The pasted content above should be identical to the code block as written.


Additional Context

Two distinct artifacts introduced by the render-buffer scrape:

  1. Box-padding bleed. Every interior line of the code block carries the TUI panel's 2-space left indent. A heredoc that writes a config file silently writes every value with leading spaces — broken behavior that's easy to miss.

  2. Soft-wrap split. Lines that exceed the terminal width are split at the column boundary. else 1)" becomes an orphaned continuation line, which is a shell syntax error on paste.

Root cause: /copy to clipboard captures the visual terminal buffer rather than the source message text. The render pipeline adds panel padding and column wrapping; neither should appear in clipboard content.

Proposed fix — OSC 52: Write clipboard content via OSC 52 using the raw message text, before the render pipeline runs:

\e]52;c;<base64-encoded-raw-text>\a

OSC 52 is supported by iTerm2, Warp, Ghostty, kitty, and tmux (set-clipboard on). This is the same mechanism used by Neovim, lazygit, and tmux-yank for clipboard writes from TUI contexts. For terminals that don't support OSC 52, fall back to pbcopy/xclip/xsel with the same raw string.

Impact:

  • Affects all kiro-cli users who use /copy to clipboard to paste generated code
  • Severity: every /copy invocation produces broken output; heredoc and multi-line shell expression errors are silent
  • Workaround: manually strip indent and rejoin wrapped lines before running

References:

  • OSC 52 spec: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
  • Neovim OSC 52 clipboard provider: runtime/autoload/provider/clipboard.vim
  • Same issue filed for GSD TUI copy: open-gsd/gsd-pi#69
  • Related Warp feature request (paste_transform): warpdotdev/warp#11608

rndjams avatar May 23 '26 17:05 rndjams

Thanks for filing this detailed bug report! The issue with /copy to clipboard grabbing the rendered TUI output (with padding and column wraps) instead of the raw message text is a great catch — that definitely makes pasted code unusable. A maintainer will review this shortly, and we appreciate you including such a clear reproducible example to help us track it down!

github-actions[bot] avatar May 23 '26 17:05 github-actions[bot]

Thanks for raising this! We've marked it as a feature request for the team to evaluate. We'll update this issue if it gets prioritized.

AnilMaktala avatar Jun 02 '26 16:06 AnilMaktala

Thanks for raising this.

Closing this as stale -- it hasn't had any activity in several months. If you're still seeing this on the current version, please open a new issue with your Kiro version, OS, and reproduction steps. To update, download from kiro.dev.

AnilMaktala avatar Sep 15 '26 14:09 AnilMaktala

Confirmed fixed on kiro-cli 2.21.4 (macOS 26.4.1, Apple Silicon). /copy to clipboard now writes raw message text — verified via pbpaste | cat -vet: no panel indent, no soft-wrap splits on lines exceeding 80 columns. Current builds copy via NSPasteboard (arboard) rather than scraping the rendered TUI buffer, which removes the root cause. Leaving closed.

rndjams avatar Sep 15 '26 18:09 rndjams