Bug: Native Windows directory picker truncates paths at BMP chars whose UTF-16 low byte is 0x00 (e.g. 一 U+4E00) #727
taominjigithub002
started this conversation in
General
Replies: 2 comments
|
+1 — reproduced today on Windows with dsh 0.1.0-rc.6, same root cause. Real case: selecting I also confirmed against the actual bytes of Preparing a fix PR. |
0 replies
|
@dsh-fix-comment.md |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
On Windows, when a workspace directory's name contains a character whose Unicode code point ends in
00hex (so its UTF-16LE low byte is0x00— e.g.一U+4E00, encoded as bytes00 4E), the native folder dialog worker truncates the returned path at that character.workspace.createthen rejects the truncated, nonexistent path with:Example (synthetic): selecting
D:\Projects\项目一测试produces the error pathD:\Projects\项目— truncated exactly before一(U+4E00).Environment
dsh-web-app,dsh-host-directory-picker-nativeboth 0.1.0-rc.6)127.0.0.1on win32). Note this affects the web GUI too, not just desktop: the web GUI callshost.pickDirectory, which opens the same native OS dialog on the host screen. The in-app browse dialog is only mounted when the native dialog is unavailable (remote/SSH/non-loopback bind), so on a local Windows setup every workspace pick goes through this buggy native path.Root cause
readUtf16()inpackages/host/directory-picker-native/src/win32-dialog-bindings.ts(built output:lib/worker.cjs) scans for the NUL terminator by checking only the low byte of each UTF-16 code unit:Any BMP character whose code point is
0xXX00(low byte 0x00) stops the scan early.一(U+4E00) encodes as00 4Ein UTF-16LE, so a path containing it is cut right before it.D:\Projects\项目一测试encodes as:The full path is otherwise perfectly valid:
fs.realpathon the untruncated path succeeds (verified).Suggested fix
Stop only on a full 2-byte NUL terminator:
Steps to reproduce
0xXX00, e.g.项目一测试(contains一U+4E00).workspace-invalid-path: cannot create a workspace at "D:\Projects\项目": ENOENT: no such file or directory, realpath 'D:\Projects\项目'.Expected behavior
The workspace is created with the full path
D:\Projects\项目一测试.Workarounds (until fixed)
一) — the only no-config workaround.@deepseek-ai/dsh-host-directory-picker-browse+@deepseek-ai/dsh-client-ui-directory-picker-browseinstead ofdirectory-picker-autoin the app config, so the in-app browser dialog (which lists via Nodefsand is unaffected) is used even on a local Windows host.All reactions