MoonshotAI / MoonshotAI/kimi-code
/copy inside tmux: OSC52 wrapped in DCS passthrough — content lost ("unverified") in tmux buffer and never reaches outer terminal
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
Environment
- Kimi Code 0.38.0, Linux x86_64 server over SSH from a macOS client running Zellij
- tmux 3.4 with
set-clipboard on - Outer terminal: Zellij on macOS
Summary
When running Kimi Code inside tmux, /copy emits an OSC 52 sequence wrapped in a tmux DCS passthrough (ESC P tmux; … ESC \). This breaks both directions:
- tmux side: with
set-clipboard on, tmux sees the sequence but reports it "unverified" and stores no payload —tmux show-buffershows onlyCopied via terminal escape sequence (unverified, 4117 characters).with the actual text lost. Pasting in another tmux window (prefix + ]) yields nothing. - Outer terminal side: the wrapped sequence is also not delivered — nothing lands in the local macOS clipboard (verified via Zellij).
Reproduction
- Inside tmux: run
kimi, send any message (e.g.reply with exactly: KIMI-CLIP-TEST-OK), wait for the reply. - Run
/copy. tmux list-buffers/tmux show-buffer→ buffer contains only theunverifiedannotation line, no content.
Root cause (from bundled binary, clipboard-osc52.ts)
function buildClipboardOSC52(text, insideTmux = isInsideTmux()) {
const sequence = `${ESC}]52;c;${Buffer.from(text, "utf8").toString("base64")}${BEL}`;
if (!insideTmux) return sequence;
return `${ESC}Ptmux;${sequence.replaceAll(ESC, `${ESC}${ESC}`)}${ESC}${ST}`;
}
The ESC P tmux; prefix is the tmux passthrough convention (forward verbatim to the parent terminal, bypassing tmux's own handling). Two consequences:
- tmux 3.4 still observes the inner OSC 52 and tries to decode it, fails, and stores only an annotation → content lost even with
set-clipboard on. - The passthrough skips tmux entirely, so in SSH setups (tmux on server, emulator on client) delivery depends wholly on the client; in our case (Zellij on macOS) it doesn't arrive.
Expected behavior
Other tools handle this correctly: Claude Code and yazi emit a plain, unwrapped OSC 52 (ESC ]52;c;<base64> ESC \). tmux then writes it to the buffer (paste anywhere with prefix + ]) and forwards it to the parent terminal. Please emit the unwrapped sequence inside tmux too, or make the passthrough compatible with tmux 3.x.
Workaround
Mouse selection + tmux copy-mode; or another tool whose copy works inside tmux.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the bundled clipboard-osc52.ts implementation and the /copy entry point, then reproduce the issue with tmux set-clipboard on. Verify that the emitted OSC 52 sequence is handled by tmux and reaches the outer terminal, with the full text present in tmux show-buffer and the local clipboard.
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
- Clearly specified
- Newbie friendliness
- 72/100