Replies: 1 comment
|
Follow-up after building a local fix — two refinements to the suggested fix above. 1. A naive swap to the native path regresses comma paths. 2. The narrowest change that keeps both working is to choose per path: const target = windowsPath.includes(",")
? pathToFileURL(windowsPath, { windows: true }).href.replaceAll(",", "%2C")
: windowsPath;With that, the function hands A caveat that argues for the Shell API: a path containing both a comma and non-ASCII characters is served by neither form and stays broken. One thing worth flagging for anyone reproducing this: Selection was read via UI Automation ( |
Uh oh!
There was an error while loading. Please reload this page.
TL;DR —
revealNativePathhandsexplorer.exe /select,a percent-encodedfile:///URL where the switch expects a filesystem path. Explorer resolves that fine for purely ASCII paths, but for a path containing non-ASCII characters (CJK) it does nothing at all — no window, no error, no dialog. Sinceexplorer.exeexits1even on success, that silent no-op is swallowed by the existingcatch, the route answers204, and the Web client reports success. Net effect: "Reveal in File Explorer" on a CJK path looks like it worked and nothing happens.Environment
dsh0.1.5-rc.2(also checked0.1.5-rc.3,0.1.6-alpha.2,0.1.7-alpha.2)@deepseek-ai/dsh-native-command→revealNativePathWhere
The logic is byte-identical in every published version I checked —
0.1.5-rc.2lines 228–234,0.1.7-alpha.2lines 239–245:For
C:\示例目录\报告.mdthat producesSteps to reproduce
%TEMP%\示例目录\报告.md.revealNativePathdirectly).204, the client shows the success toast.Repeat with a pure ASCII path (
%TEMP%\plain\report.md) and it works — which is why this goes unnoticed in ASCII-only environments.Measurements
Selection state read through UI Automation (
SelectionItemPattern.IsSelectedProperty) rather than inferred, becauseShell.Application'sDocumentrefusesFocusedItem/SelectedItemswithDISP_E_NOTACOLLECTION. Each trial uses a brand-new directory so Explorer window reuse cannot confuse the result.A= the code above,B=["/select,", nativePath].file:///URL)plain.mdspa ced.mdpl,ain.md%2Cworks)中文文件.md中文 文件.mdAis consistent across five independent runs: 6/6 successes on ASCII-only names, 11/11 failures on any name containing CJK. Interleaving A and B with three repetitions each (to cancel the ordering effect described below) gives A3/3failures and B3/3opens on a CJK path.Two separate defects
Correctness — non-ASCII paths never reveal. The percent-encoded URL form is not resolved by
explorer.exe /select,. This is the common case for the users hit by it: any CJK project directory makes the feature a no-op. The same code path is used from WSL, afterwslpath -w.Observability — the failure is reported as success.
explorer.exereturns1for both a successful handoff and a failure to resolve the path, and thecatchdeliberately treats1as success (the JSDoc even says "Explorer exit 1 is accepted as a delegated handoff, not proof of selection"). SohandlePresentOpenreturns204, the client shows a success toast, and there is no log line, no non-2xx status, and no user-visible error anywhere. This is what made the bug expensive to diagnose — the user-visible symptom is "the button does nothing", and every instrument says it succeeded.Suggested fix
The durable fix is to stop routing this through
explorer.exeargument parsing at all and use the Shell API meant for it —SHOpenFolderAndSelectItems— which the package is already well placed to do, since it embeds and compiles C# for Windows file associations (WINDOWS_ASSOCIATIONS).As a minimal interim change, keep the
%2Csubstitution (it is load-bearing: a raw comma in the URL fails, verified 2/2, and a raw comma in a native path also fails 2/2) but stop percent-encoding non-ASCII:What I could not verify
%2Cis required for commas, but I could not get a clean pass on the combination: Explorer coalesces rapid successive/select,invocations, so whichever variant runs later in a batch looks worse. That artefact is in my harness, not necessarily in the product — but it means I am proposing that line as a direction, not as a tested patch.%would become ambiguous under the interim fix (it would look like an escape), which is another reason to prefer the Shell API.Happy to re-run anything or provide the matrix scripts if useful.
中文摘要:「在文件资源管理器中显示」对含中文的路径完全无反应(纯 ASCII 路径正常)。原因是
revealNativePath把pathToFileURL(...).href这个百分号编码的file:///URL 传给了explorer.exe /select,,而该开关期望的是文件系统路径;%E4%B8%AD这类 UTF-8 转义不会被解析,于是 Explorer 静默什么都不做。又因为 Explorer 成功失败都返回 1,这个静默失败被现有的catch当作成功,接口返回 204,前端提示成功——所以现象是「点了没反应,但哪里都显示成功了」。五个版本的代码逐字相同。附了复现矩阵与两处缺陷说明。All reactions