MoonshotAI / MoonshotAI/kimi-code

Clipboard image paste does not work in WSL

Open
#2,722 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What version of Kimi Code is running?

0.34.0

Which open platform/subscription were you using?

kimi code

Which model were you using?

kimi k3

What platform is your computer?

Windows + WSL, running Kimi Code inside Windows Terminal.

What issue are you seeing?

Pasting an image from the Windows clipboard into Kimi Code does not work when Kimi Code is running inside WSL.

After taking a screenshot with Win+Shift+S, pressing Ctrl+V at the Kimi Code prompt produces no image attachment / image placeholder and no error message.

I also tried Alt+V, but it does not attach the image either.

I initially suspected Windows Terminal was intercepting Ctrl+V, so I removed the Windows Terminal Ctrl+V paste keybinding. After doing that, Ctrl+V is successfully passed through to WSL, but image paste in Kimi Code still does nothing.

I separately verified that WSL can access the image currently stored in the Windows clipboard through powershell.exe, so the Windows-to-WSL clipboard bridge itself appears to be working.

What steps can reproduce the bug?

Run Kimi Code inside WSL using Windows Terminal:
kimi
Take a screenshot on Windows using:
Win+Shift+S
Return to the Kimi Code TUI.
Press:
Ctrl+V
Nothing is attached to the prompt. No image placeholder appears and no error is shown.
Diagnostic 1: Ctrl+V reaches WSL correctly

I removed the Windows Terminal Ctrl+V paste binding so that the keypress is forwarded to WSL.

I then tested the raw input outside Kimi Code with:

python3 -c 'import sys,tty,termios; fd=sys.stdin.fileno(); old=termios.tcgetattr(fd); tty.setraw(fd); print("press Ctrl+V"); b=sys.stdin.buffer.read(1); termios.tcsetattr(fd,termios.TCSADRAIN,old); print(repr(b), b.hex())'

Pressing Ctrl+V produces:

b'\x16' 16

So Ctrl+V is reaching the WSL process correctly.

Diagnostic 2: WSL can read the Windows clipboard image

After taking a screenshot with Win+Shift+S, I ran:

powershell.exe -NoProfile -Command 'Add-Type -AssemblyName System.Windows.Forms; $img=[System.Windows.Forms.Clipboard]::GetImage(); if ($img) { Write-Output "OK $($img.Width)x$($img.Height)" } else { Write-Output "EMPTY" }'

This successfully returns:

OK x

So powershell.exe running from WSL can successfully retrieve the Windows clipboard image.

Despite both of these working independently, pressing Ctrl+V inside Kimi Code still does not attach the image.

What is the expected behavior?

When running Kimi Code inside WSL, after taking a Windows screenshot with Win+Shift+S, pressing Ctrl+V should read the Windows clipboard image and attach it to the current Kimi Code prompt.

An image attachment / placeholder should appear in the TUI before submitting the prompt.

Additional information

From reading the current implementation, it looks like Kimi Code already has explicit WSL clipboard-image handling and a PowerShell fallback for Windows clipboard images.

Since:

Ctrl+V reaches the WSL process as 0x16
powershell.exe invoked from WSL can successfully call System.Windows.Forms.Clipboard.GetImage()
Kimi Code itself still does not attach the image

this may be somewhere in the TUI image-paste dispatch / clipboard fallback path rather than Windows Terminal swallowing the key or Windows clipboard access being unavailable.

I have not identified the exact root cause yet.

Workaround

Saving the Windows clipboard image to a file through PowerShell and then asking Kimi Code to read that image file works, so model/image-file handling itself appears to be functional.

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 with the TUI image-paste dispatch and clipboard fallback path identified in the issue, then reproduce the Ctrl+V flow inside WSL after confirming the raw key input and PowerShell clipboard access. Done means a Windows clipboard image produces an attachment or placeholder in the prompt, with an error shown if retrieval fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, powershell, typescript
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.