Skip to content

fix(shell): read clipboard media on BracketedPaste for Windows terminals#2481

Open
redjade75723 wants to merge 2 commits into
MoonshotAI:mainfrom
redjade75723:main
Open

fix(shell): read clipboard media on BracketedPaste for Windows terminals#2481
redjade75723 wants to merge 2 commits into
MoonshotAI:mainfrom
redjade75723:main

Conversation

@redjade75723

@redjade75723 redjade75723 commented Jul 1, 2026

Copy link
Copy Markdown

On Windows Terminal and VS Code's integrated terminal, Ctrl+V is handled
by the terminal itself and emitted as a BracketedPaste event. Binary
content like images cannot be carried as text in that event, so paste
would silently fail.

This change makes _handle_bracketed_paste() first try _try_paste_media()
to read images and files directly from the system clipboard before
falling back to the text payload.

Fixes paste of screenshots and copied image files on Windows.

Related Issue

None.

Description

On Windows, when using terminals that support bracketed paste mode (e.g., Windows Terminal, VS Code integrated terminal), pasting image content via Ctrl+V fails silently because the BracketedPaste event only carries text data.

This PR updates _handle_bracketed_paste() in src/kimi_cli/ui/shell/prompt.py to attempt reading media directly from the system clipboard via _try_paste_media() before falling back to the standard text payload. This enables pasting screenshots and copied image files on Windows.

Tests have been added in tests/.../test_prompt_clipboard.py.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any. (None applicable)
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

On Windows Terminal and VS Code's integrated terminal, Ctrl+V is handled

by the terminal itself and emitted as a BracketedPaste event. Binary

content like images cannot be carried as text in that event, so paste

would silently fail.

This change makes _handle_bracketed_paste() first try _try_paste_media()

to read images and files directly from the system clipboard before

falling back to the text payload.

Fixes paste of screenshots and copied image files on Windows.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread src/kimi_cli/ui/shell/prompt.py Outdated
Restrict the BracketedPaste media fallback to Windows so that plain
text pastes on Linux and macOS do not pay the cost of spawning
xclip/wl-paste or querying the AppKit pasteboard.

Addresses review feedback that every BracketedPaste was triggering a
system clipboard read on all platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant