Terminal on Windows: CJK bytes escaped as M-... in the prompt, and IME (pinyin) input does not work #7964
Replies: 3 comments
|
Update — the reporter ran the Windows read-outs: the locale hypothesis is ruled out. Windows 11, Git Bash via the terminal, same CJK workspace:
So the shell is not in a C/POSIX locale, yet the prompt still escapes the CJK bytes. That matches our local pty reproduction, where Next read-out we are asking for (this should separate "bash's own cwd expansion" from "the terminal renderer"): cd ~/Documents/<workspace-with-cjk>
PS1='$PWD> ' # direct variable expansion
PS1='\w> ' # bash's own \w expansionIf |
Correction + next narrowing steps (from the reporter's own control runs)Withdrawing one explanation I gave above. I wrote that the escaping happens where the shell expands What the affected machine shows
So: not the locale, and not One thing worth knowing before anything elseDSH's own shell prompt is plain ASCII: Two commands that narrow it down (paste as-is)Only colours: Only the OSC window-title sequence: Whichever of the two starts showing Please also paste the two readings of the prompt actually in use on the affected machine: The decisive attribution control (please run)Open a native Git Bash window (minTTY), completely outside DSH,
What I could and could not reproduce locallyI re-ran a real-pty matrix on macOS (bash 3.2) with a CJK working directory: plain Happy to help interpret whatever those four commands print. |
Where the prompt actually comes from: two different terminal pathsFollowing up on the correction above — I traced which code sets a prompt, and the answer explains why the prompt in the sidebar terminal is the shell's own one rather than DSH's controlled prompt.
|
Uh oh!
There was an error while loading. Please reload this page.
Summary
Two problems in the DSH terminal on Windows (Git Bash via the official terminal), both affecting CJK users:
M-…) whilepwdprints the same path correctly.They look independent (one is the shell's prompt string, the other is the frontend input path), so they are reported separately below.
Environment
0.1.7-rc.2(dsh --version) · web GUIProblem 1 — CJK bytes in the prompt become
M-…Actual: the prompt shows the working directory as escaped 8-bit bytes:
Same terminal, same directory:
pwdprints it correctly:So the path itself is fine; only the prompt rendering is affected. (This is the same mechanism the user reported as "path display is broken".)
Minimal reproduction / what I could confirm
I could not run the Windows build, so I reproduced the mechanism on macOS through a real pty with a CJK directory and
PS1='\w> ':LC_ALL=C/private/tmp/…/M-iM-;M-^XM-hM-.M-$M-eM-7M-%M-dM-=M-^\M-eM-^LM-:>(escaped)LC_ALL=en_US.UTF-8LC_ALL=C+TERM=dumbTwo findings worth noting:
PS1(PS1='中文目录> ') is not escaped in any of those cases. The escaping happens where the shell itself decodes the working directory into the prompt (\w/\W, which the default Git Bash prompt uses). It is therefore not the terminal renderer.Readings requested on Windows (this is the decisive control):
Expected: the prompt persists the path in its original non-ASCII form (or at least the terminal shows readable CJK), like
pwddoes.Actual: the prompt shows
M-…escapes.A code lead (read-only inspection of my local checkout): the terminal backend does not pass any locale to the shell.
packages/terminal/terminal-bash/src/index.tschildEnvironment()(around:64-88) setsTERM: 'dumb',PAGER,GIT_PAGER,DSH_*,PS1,PROMPT_COMMAND— and noLANG/LC_ALL/LC_CTYPE; the environment is the subprocess provider's scrubbed ambient base, which on Windows has no locale variables. There is no otherLC_ALLinpackages/terminal/*,packages/api/terminal-controllerorpackages/subprocess/subprocess-localexcept Linux sandbox helpers pinningLC_ALL=C(subprocess-local/src/linux-scope.ts). Passing a UTF-8 locale for the terminal shell (or allowing a per-rowenvmap) would be an upstream change; a third-party plugin cannot do it today because the terminal row's Config only carriesshell.path/shell.name/shell.args.Problem 2 — IME (pinyin) does not work in the terminal
Actual: typing pinyin in the DSH terminal does not produce characters (composition/candidate window does not commit text).
Not reproduced locally (the headless macOS environment has no IME), so this half is reported as observed behaviour plus a code-level pointer rather than a confirmed cause.
Code-level pointer: the terminal frontend is xterm.js (
packages/client/ui-sidebar-terminal/src/client/terminal.tsx,new Terminal({…})), so composition handling is xterm's own; DSH's terminal code contains nocomposition*handling for the terminal surface — the only composition-aware code in that package is the title rename input (TerminalTitle.tsx, which skips Enter whileisComposingis true). If the terminal's hidden textarea loses focus, is covered by an overlay, or the key handler swallowskeyCode 229/composition*, the IME never commits. Related reports exist for the chat input (#4233, #1417, #6138) but not for the terminal.Impact
Any CJK (and generally non-ASCII) user who works in a directory with a localized name sees a mangled prompt, and cannot type their language into the terminal at all. The second one makes the terminal unusable for them, not just ugly.
Ask
envmap)? If the escaping is expected on Windows, is there a recommended shell-side setup?Happy to run anything on Windows, or to provide the exact pty script and raw byte dumps.
All reactions