directory-picker-browse: New-folder errors show invalid payload for host.createDirectory because the UI drops rpcError.details.issues
#4575
Replies: 1 comment
|
Diagnosis holds, and the helper is unchanged on master (0.1.1-rc.2). // packages/client/ui-directory-picker-browse/src/client/DirectoryBrowser.tsx:67
function failureText(error: unknown): string {
if (error instanceof DirectoryBrowseError) return error.rpcError.message
return error instanceof Error ? error.message : String(error)
}Your refs are into the published const payload = route.schema.safeParse(message.payload)
if (!payload.success) {
return errorResponse(message.rpcId, { code: 'bad-request', message: `invalid payload for ${method}`, details: { issues: payload.error.issues } })
}That's the only place in the repo emitting that string, so every unary method's schema rejection reads identically. Worth pairing with the fact that One correction, in your favour: export type RpcError = {
[C in RpcErrorCode]: { code: C; message: string; details: RpcErrorDetailsMap[C] }
}[RpcErrorCode]with I'd still not ship that as the fix, for a reason that isn't in the report. The dialog's copy is localized, with zh and en dictionaries registered in The field also already has the seam to hang it on, in 2 places, because Enter bypasses the button. Line 1032 is The problem queued behind it: that predicate already exists twice, and deliberately. // packages/host/directory-picker-browse/src/index.ts:308
if (name.trim() === '' || name === '.' || name === '..' || /[/\\]/.test(name)) {
throw new DirectoryPickerError('directory-create-failed', join(parent, name), `"${name}" is not a single path segment`)
}The comment above it says the wire schema also refuses these, but direct service consumers must hit the same fence. An inline UI check makes 3 copies with 3 different wordings, and you can't dedupe by importing the schema: On the mkdir note, non-recursive is correct ( Workaround for your users today with no upstream change: the pencil zone on the path bar ( |
Uh oh!
There was an error while loading. Please reload this page.
Summary
In the browse directory picker, typing/pasting an absolute path into the New folder name field surfaces
invalid payload for host.createDirectoryto the end user. The actionable text the schema already produces (host.createDirectory requires a single non-blank path segment name) is transported correctly but dropped by the picker UI.Reported by a non-technical Windows user of a product built on dsh; the message told them nothing about what was wrong or what to do.
All three packages at
0.1.0-rc.7. Electron host on Windows 10/11 x64.Reproduction
@deepseek-ai/dsh-host-directory-picker-browse).D:\Projects\demo.Observed: red inline text
invalid payload for host.createDirectory.Expected: something like "Enter a folder name only — to create it somewhere else, use Edit path."
Where it is lost
The payload is correctly rejected, with a specific reason:
dsh-host-apiproxy/lib/types/api/host.schema.js:44-45dsh-host-apiproxy/lib/index.js:4857-4862— the genericmessage, with the zod issues preserved underdetails:So the proxy does the right thing:
details.issues[0].messagecarries the readable sentence.dsh-client-ui-directory-picker-browse/lib/client.js:113-116— the picker's failure-text helper reads onlymessage:details.issuesis never consulted, so the specific reason is discarded at the very last step before display.Suggested fixes
1. Use the detail that is already there. When
rpcError.code === 'bad-request'andrpcError.details?.issues?.length, prefer the first issue'smessageover the generic one. That alone turns the above intohost.createDirectory requires a single non-blank path segment name— still developer-flavoured, but at least it names the actual constraint.2. Validate in the field, before the round trip. The New-folder input knows it wants one segment (
browser.folderName). Rejecting/and\inline, with a hint pointing at the existing Edit path affordance (browser.editPath), fixes the real user problem: they were not trying to name a folder oddly, they were trying to go somewhere else. Pasting a full path into the only text field on screen is a very natural mistake when the target is on another drive.3. Optional — say so in the label.
browser.untitledFolderas placeholder reads as "type a name here"; an explicit hint ("name only") would cost nothing.Note on a related constraint
dsh-host-directory-picker-browse/lib/index.js:225uses non-recursivemkdir, so multi-level creation is not possible even with a corrected message. That is a reasonable default, but it means a user targetingD:\A\Bmust createA, enter it, then createB. Worth mentioning in the same hint.Filed from the same downstream product as
#4330 (the Windows native-picker segfault). That one is confirmed fixed for us by switching the win32 backend to
browse; this report is about the browse backend's own UX.All reactions