Skip to content

[Bug] Chinese IME input shows underscores in TUI on Windows #29993

@cgartlab

Description

@cgartlab

Bug Report: Chinese IME input shows underscores in TUI on Windows

Environment

Item Value
OpenCode version 1.15.12
OS Windows 11 Pro Insider Preview (Build 26220)
Terminal Windows Terminal
Shell PowerShell 7.6.2
Node.js v26.2.0
System code page 65001 (UTF-8)
Input method Microsoft Pinyin (zh-Hans-CN)
Terminal font Hack Nerd Font

Description

When typing Chinese characters in the OpenCode TUI chat input using a Chinese IME (Input Method Editor), all composed characters are displayed as underscores _______ instead of the actual Chinese characters.

The IME candidate window appears correctly, and selecting a candidate should input the Chinese character, but the TUI renders it as underscores.

Steps to Reproduce

  1. Launch opencode in Windows Terminal
  2. Switch to Chinese input method (Microsoft Pinyin)
  3. Type pinyin in the chat input (e.g., nihao)
  4. The input field shows _______ instead of the composition text
  5. Select a candidate from the IME window
  6. The confirmed character also appears as underscore or is not displayed

Expected Behavior

  • During IME composition: the pinyin text should be visible in the input field
  • After IME confirmation: the Chinese character should be displayed correctly
  • The input should work seamlessly with Chinese IME, similar to how it works in other TUI applications

Actual Behavior

  • All Chinese input (composition and confirmed characters) appears as underscores _______
  • The IME candidate window works correctly
  • English input works fine
  • The issue affects all Chinese IME operations in the TUI

Diagnostic Information

System code page verification:


Active code page: 65001
ACP: 65001
OEMCP: 65001

Chinese character OUTPUT test (bash tool):


$ echo "中文测试:你好世界"
中文测试:你好世界

Output works correctly — the issue is INPUT only.

VT processing:


HKCU:\Console\VirtualTerminalLevel = 1
HKCU:\Console\%wt%\VirtualTerminalLevel = 1

Related Issues

This appears to be related to:

Root Cause Analysis

The issue appears to be in the TUI's input handling layer. The IME composition events (compositionstart, compositionupdate, compositionend) are not properly handled in the Windows terminal environment. The TUI renders the composition buffer as underscores instead of the actual text.

PR #17013 and #17041 attempted to fix IME composition handling, but the issue persists on Windows.

Additional Context

  • The issue is Windows-specific — macOS and Linux may handle IME differently
  • The issue affects input only — Chinese character output works correctly
  • The issue persists with system code page set to 65001 (UTF-8)
  • The issue affects all Chinese IME operations (composition, confirmation, editing)

Workaround

Currently, the only workaround is to:

  1. Type Chinese text in an external editor (e.g., Notepad, VS Code)
  2. Copy the text
  3. Paste it into the OpenCode TUI

This is not ideal for users who primarily work with Chinese input.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions