fix(composer): attach native files dropped into desktop - #76
Merged
Merged
Conversation
Jaxton07
requested changes
Sep 21, 2026
Jaxton07
left a comment
Owner
There was a problem hiding this comment.
发现 1 个需要修正的正确性问题:
packages/desktop/src/renderer/src/components/composer/drop-files.ts:12:不要对webUtils.getPathForFile()返回的原生路径调用trim()。macOS/Linux 允许文件名以空格开头或结尾;当前实现会把路径改成另一个不存在的路径,也可能把两个不同文件错误去重。这里应保留原字符串,只用空字符串判断(例如if (path.length > 0) paths.add(path)),并补一个保留首尾空格的测试。
非阻塞项:本 PR 给 PiApi 新增了一个表外成员,docs/INDEX.md 中“手写成员只有 on*/platform”的描述已过时;请一并更新索引。
其余实现方向合理:采用 Electron 官方 webUtils.getPathForFile preload bridge,并复用现有附件草稿管线。CI 已通过;本地复核通过 typecheck、lint 和新增的 2 个单测。
Jaxton07
approved these changes
Sep 22, 2026
Jaxton07
left a comment
Owner
There was a problem hiding this comment.
维护者修复已补充:保留 Electron 返回的原生路径原值,新增尾随空格路径回归测试,并同步更新 PiApi/项目索引说明。
本地 typecheck、全部测试、lint 通过;远端 CI 通过。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #62.
The desktop composer accepted image paste and file-picker attachments, but did not handle a native OS file drop. This adds a preload bridge around Electron
webUtils.getPathForFile, then routes dropped paths through the existing composer attachment flow. Invalid or repeated paths are ignored.Validation:
npm run typechecknpm run lintnpm run test(including two new focused drop-path tests)npm run buildI verified the code path and tests on macOS; I could not run the Windows desktop drag-and-drop interaction locally, so I would appreciate a Windows smoke test from a maintainer or contributor.