fix(shell): read clipboard media on BracketedPaste for Windows terminals#2481
Open
redjade75723 wants to merge 2 commits into
Open
fix(shell): read clipboard media on BracketedPaste for Windows terminals#2481redjade75723 wants to merge 2 commits into
redjade75723 wants to merge 2 commits into
Conversation
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.
This was referenced Jul 1, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()insrc/kimi_cli/ui/shell/prompt.pyto 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
make gen-changelogto update the changelog.make gen-docsto update the user documentation.