feat: export file attachments and repair Moments video loading - #345
Open
fan26a wants to merge 2 commits into
Open
feat: export file attachments and repair Moments video loading#345fan26a wants to merge 2 commits into
fan26a wants to merge 2 commits into
Conversation
ILoveBingLu
requested changes
Aug 13, 2026
ILoveBingLu
left a comment
Owner
There was a problem hiding this comment.
目前不建议直接合并,请先处理以下问题:
阻塞:206 Partial Content 可能被当成完整视频永久缓存
downloadSnsVideoToFile 接受所有 206 响应,但完整性检查只比较 Content-Length 与本次响应实际接收长度,没有解析 Content-Range 判断响应是否覆盖整个视频。
我用下面的响应做了复现:
HTTP/1.1 206 Partial Content
Content-Length: 24
Content-Range: bytes 0-23/1000000下载器会返回 { success: true },保存的 24 字节由于包含合法 ftyp 文件头,也会被 isPlayableVideoBuffer 判定为有效。之后 snsService 会将其写入正式缓存;缓存命中时又只验证前 12 字节,因此这个截断文件会持续被当作可播放视频。
这与本 PR 的“下载完整性检查”和“损坏缓存自动恢复”目标直接冲突。建议:
- 未主动发送
Range请求时只接受 200;或 - 严格解析 206 的
Content-Range,确认范围从 0 开始且结束位置覆盖总长度; - 增加测试:仅返回合法视频头的 206 分段响应必须失败且不得保留文件。
相关位置:electron/services/snsVideoUtils.ts 112-143 行、electron/services/snsService.ts 1553-1559 和 1592-1632 行。
次要:AI 导出入口没有接入 exportFiles
页面导出已经新增 exportFiles,但 AI 导出相关的 AiExportMediaOptions、校验、runner 映射及工具 Schema 仍只有头像、图片、视频、表情、语音五项。因此新功能只能从导出页面使用,AI 的聊天导出工具无法导出附件。
涉及:
electron/services/agent/aiExportTypes.tselectron/services/agent/aiExportValidation.tselectron/services/agent/aiExportRunner.tselectron/services/agent/tools/exportChat.ts
如果产品范围明确只支持页面导出,请在 PR 中说明;否则建议一并补齐契约和测试。
补充验证:PR 自带的 node --experimental-strip-types scripts/test-sns-video.ts 可以通过,git diff --check 也通过;当前 PR 没有 CI checks。
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.
Summary
Testing
node --experimental-strip-types scripts/test-sns-video.tsvite build