Skip to content

Fix Windows clipboard paste mojibake for CJK search text#7

Open
kirahan wants to merge 1 commit into
Mininglamp-AI:mainfrom
kirahan:bugfix
Open

Fix Windows clipboard paste mojibake for CJK search text#7
kirahan wants to merge 1 commit into
Mininglamp-AI:mainfrom
kirahan:bugfix

Conversation

@kirahan
Copy link
Copy Markdown

@kirahan kirahan commented May 18, 2026

Problem

ComputerActionExecutor._type_text() pastes text on Windows via clip.exe and Ctrl+V. The clipboard was filled with text.encode("utf-16le") (UTF-16 without BOM).

On localized Windows (e.g. code page 936 / GBK), clip.exe can treat that byte stream as ANSI/system code page instead of Unicode. Pasting into the taskbar search box or other text fields then shows mojibake (e.g. 企业微信吅OON胜醇).
image

Agent output is unaffected: logs and action_desc still show the correct Chinese string (type: 企业微信). The bug is in local input, not model responses.

Solution

Encode clipboard input as UTF-16 with BOM using Python's utf-16 codec (adds FF FE BOM + UTF-16LE payload), which clip.exe recognizes as Unicode.

Changes

# visual/computer/computer_action_executor.py — _type_text(), Windows branch

# Before
subprocess.run(["clip"], input=text.encode("utf-16le"), check=True)

# After
# clip.exe expects UTF-16 with BOM; utf-16le alone is misread as ANSI on
# localized Windows and pastes mojibake into Search / text fields.
subprocess.run(["clip"], input=text.encode("utf-16"), check=True)

Typing still uses clipboard + Ctrl+V (unchanged); only the Windows clipboard encoding is fixed. macOS (pbcopy / UTF-8) and Linux (xclip) paths are unchanged.

Files Changed

  • visual/computer/computer_action_executor.py

Testing

  • On Windows 11 (GBK console, chcp 936), run a task that types a CJK app name into taskbar search (e.g. 企业微信).
  • Confirm search box shows the correct characters, not mojibake.
  • Confirm macOS/Linux paste behavior is unchanged (no regression).

- Use UTF-16 with BOM for clip.exe stdin instead of raw utf-16le
- Prevents localized Windows from treating paste bytes as ANSI
- Fixes garbled input when typing app names in taskbar search

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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