MiMo-Code icon indicating copy to clipboard operation
MiMo-Code copied to clipboard

Ctrl+V Paste Fix Report — MiMo Code on Windows

Open N-verner-A opened this issue 5 months ago • 1 comments

Description

Hello!

Problem Description

On Windows (both classic Console/conhost and Windows Terminal), the Ctrl+V keyboard shortcut does not paste text from the clipboard into MiMo Code's TUI input field. Right-click paste also fails in some environments.


Root Cause Analysis

After investigating, I identified four distinct bugs that together prevent clipboard paste from working correctly in Windows environments (Console, Windows Terminal, and compiled Bun binary):

  1. Ctrl+V handler – In prompt/index.tsx, the onKeyDown for input_paste did not call e.preventDefault() for text pastes. It relied on bracketed-paste support, which is not available in Windows Console/ConPTY. As a result, the default browser/terminal paste behavior took over, and the TUI never received the paste event.

  2. Double‑submission guard – Rapid Enter presses or pastes that include trailing newlines triggered multiple deferred submissions, leading to duplicate sends or erratic behavior.

  3. Clipboardy / Bun binary – The clipboardy package relies on clipboard_x86_64.exe being located via import.meta.url. In a compiled Bun binary (mimo.exe), import.meta.url resolves to a virtual path, so the executable cannot be found and executed.

  4. UTF‑8 encoding – When clipboardy falls back to PowerShell, it outputs text in the system default encoding (e.g., Windows‑1251 for Russian), not UTF‑8. This caused mojibake for non‑ASCII characters (Cyrillic, etc.).


Solution

I have created two patches that address all four issues:

  • mimo_ctrlv_windows.patch – fixes the Ctrl+V handler (adds e.preventDefault(), calls pastePlainText() directly) and adds a submission guard to prevent double‑send.
  • mimo_clipboard_bun_binary.patch – replaces the clipboard mechanism with a PowerShell‑based reader that forces UTF‑8 output and works reliably in the compiled Bun binary.

The patches are available in my public repository:

👉 https://github.com/N-verner-A/mimo-code-patches


How to Apply

  1. Clone the official MiMo Code repository:
    git clone https://github.com/XiaomiMiMo/MiMo-Code.git
    cd MiMo-Code
    
  2. Download the patches from the above repository and apply them using git am:
    git am < /path/to/mimo_ctrlv_windows.patch
    git am < /path/to/mimo_clipboard_bun_binary.patch
    
  3. Rebuild the CLI:
    cd packages/opencode
    bun run build --single
    
  4. The compiled binary will be at packages/opencode/dist/mimocode-windows-x64/bin/mimo.exe.

Tested Scenarios

  • Windows 10 & 11
  • PowerShell, Windows Terminal, and classic conhost
  • English and Russian (Cyrillic) text
  • Single‑line and multi‑line paste
  • Image clipboard (unchanged) – not affected
  • Compiled mimo.exe (Bun’s --compile)

Environment

  • MiMo Code version: 0.1.1
  • Binary version: 0.0.0-main-202606181748
  • Base commit: 98c283a

Note: These patches are specific to the current 0.1.1 release. If upstream changes significantly, they may need to be rebased or re‑applied. I hope this can be merged or at least serve as a reference for a proper fix.


Plugins

No response

MiMoCode version

0.1.1

Steps to reproduce

  1. Run MiMoCode in Windows PowerShell or in cmd;
  2. Copy text to clipboard;
  3. Try to paste using right-click or Ctrl+V, or Ctrl+Shift+V, or Shift+Insert;;
  4. Nothing happens - no text is pasted.

Screenshot and/or share link

No response

Operating System

Windows 10

Terminal

Windows PowerShell, cmd

N-verner-A avatar Jun 19 '26 11:06 N-verner-A

thanks, it has already solved in next version !

MiMoHardFather avatar Jun 19 '26 14:06 MiMoHardFather