MoonshotAI / MoonshotAI/kimi-code

TUI: mouse-copying assistant output adds left padding and hard line-wraps, corrupting pasted text (grok cli / opencode are not affected)

Open
#3,745 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

Summary

When selecting assistant output (especially fenced code blocks) in the TUI with the mouse and copying it, the clipboard content is corrupted in two ways:

  1. Every line carries the TUI's left padding (~4–5 leading spaces).
  2. Long logical lines are hard-wrapped at the chat content width, so a single line is copied as multiple lines, with padding on the continuation lines.

grok cli and opencode render assistant content flush-left, so mouse-copying from them is lossless. In Kimi Code, the very common workflow of "copy a command the agent printed and paste it into a terminal" is actively dangerous.

Environment

  • kimi 0.42.0
  • Windows 11, PowerShell (oh-my-posh prompt)

Steps to reproduce

  1. Ask the agent to print a multi-line shell snippet, or a single long command (e.g. echo '<a-long-string>' >> somefile).
  2. Select the code block in the TUI with the mouse and copy it.
  3. Paste into another terminal or an editor.

Expected behavior

The clipboard contains exactly the raw text the agent emitted — no added leading spaces, no inserted line breaks. This is how grok cli and opencode behave.

Actual behavior

  • Each pasted line starts with the TUI's left-margin padding (visible as ~5 leading spaces).
  • Lines longer than the chat content width arrive split at the visual wrap point; the continuation lines keep the padding, so a quoted string can be silently broken in the middle.

Real-world impact

While setting up SSH key authentication on a server, I copied a one-liner the agent printed:

echo 'ssh-ed25519 AAAA...<long-key>... user@host' >> ~/.ssh/authorized_keys

The paste arrived as two lines — the key body on one line and user@host (with leading spaces) on the next. authorized_keys ended up corrupted and sshd refused the key (Permission denied (publickey)). The break is invisible in a terminal, so it took an extra debugging round to find.

Related

  • #2721 — fullscreen TUI with mouse selection/copy (broader UX request; this issue is specifically about copy fidelity of the normal transcript).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the TUI transcript rendering and mouse-selection clipboard path, reproducing the issue with a fenced snippet and a long command. The work is done when copied assistant output preserves its original leading spaces and logical line breaks, including long lines, and the reproduction no longer corrupts pasted shell commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.