Repository navigation
fix(media): 图片直接预览,视频由 Agent 获取路径自主查看 - #7970
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR changes how Agents inspect generated and task-owned media. 整体可以合并;建议修正未知时长视频无法返回首帧的问题。 Findings
Fix with agent prompt### Issue 1
apps/desktop/src/main/cindy-media/videoInspection.ts:66
`extractVideoFrames` 会把没有有限时长元数据的视频直接判为越界,连默认请求零秒也不例外。浏览器 `MediaRecorder` 生成的 WebM 可以正常解码,但 `video.duration` 仍为 `Infinity`;此时首帧已经加载,这里的判断却让整个检查返回 `VIDEO_PREVIEW_FAILED`。原视频交付不受影响,但 Agent 无法查看画面。
建议区分“时长未知”和“时间越界”,允许读取已加载的首帧,并补充对应回归测试。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae8f91d03b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
ae8f91d to
987b32c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 987b32c2d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Review report · PR #7970 fix(media): 图片直接预览,视频由 Agent 获取路径自主查看
Findings没有 P0/P1。 (heavy 档专项定性,均非缺陷,记录如下供复核:)
数据外发核对:预览像素只进 MCP image 内容块随工具结果交给当前模型;不进 JSON 文本、不新建媒体副本、不自动发 IM、无新增网络目的地、无新增第三方依赖(sharp、better-sqlite3、drizzle 均为既有依赖;security-scan 确认本 PR 未新增/升级依赖)。错误返回与 Rule coverage按 rule-map 命中读取并逐项核对(只审本 PR 新增/修改代码):
Verification实际执行(本 worktree,命令退出码如实记录):
Intent alignment
多轮 Codex/Greptile 意见均限于内存/DoS 与解码健壮性,未改变产品方向;已 Resolve 的 3 条 thread 的修复承诺与最终代码逐条相符(视频抽帧确已整体移除、输入上限确已改为 6 MiB/像素上限/缩略链路)。无确认偏离,无需用户裁定事项。存疑项:无(初始实现 4 个提交完整可核验)。 Overallpass —— 没有 P0/P1;原意一致性复核完成,无待裁定方向问题。建议按仓库策略合并。 |
这次改了什么
摘要
媒体生成成功后,Agent 之前只拿到受管地址;工具说明又规定只有用户询问存储位置才能取得文件路径,导致 Agent 无法主动检查自己的成果。
图片成功结果现在附带最多两张模型可见预览,已有任务图片可用
inspect查看。需要查看或分析视频时,Agent 可主动用已有resolve_local_path取得文件路径,自行选择抽帧、分析工具或脚本,沿用当前任务的权限处理。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
inspect;原有生成字段与路径解析接口保留,插件协议无变化。UI 变化
不涉及。
怎么验证的
自动验证
pnpm --dir packages/cindy-tools exec vitest run src/__tests__/ghostMcp.test.ts:96 项通过。pnpm --dir apps/desktop exec vitest run src/main/cindy-media/__tests__/mediaInspection.test.ts src/main/cindy-brain/__tests__/ghostModelImages.test.ts:23 项通过。pnpm --dir apps/desktop exec vitest run src/main/__tests__/inlineImageCompressor.test.ts:3 项通过,验证既有压缩接口保持兼容。pnpm --dir apps/desktop run typecheck、pnpm --dir packages/cindy-tools exec tsc --noEmit、pnpm --dir packages/lizi-mcps exec tsc --noEmit:通过。pnpm check:test-hygiene、pnpm check:dev-docs、git diff --check:通过。测试价值:
mediaInspection.test.ts:调用真实inspectMedia/previewGeneratedImages,用临时图片文件及内存账本验证像素、归属撤销、损坏文件、批量限制和付费成果保留。原生成测试只验证地址;最小输入是一个任务图片引用,压缩期间撤销任务/账号/引用时必须丢弃像素。另用合法 PNG 加超限字节、4096×4097 像素 PNG 先复现旧实现仍返回预览,再验证超限不影响原始生成成功;高熵 PNG 验证新缩略链路返回可解码、符合字节预算的 WebP。视频输入在读取文件前提示使用路径工具。unit;单独运行 1.01 秒。ghostMcp.test.ts:调用真实handleMedia,验证 image 内容块与 JSON 元数据分离、失败时不返回像素,以及受管图片/视频路径交接。原测试只验证 JSON;最小输入是带一张预览的完成结果。unit;单独运行 0.630 秒。ghostWorkdirGate与invocationService覆盖路径解析及 Ask / Auto / Full Access、远程任务、撤权处理;本次没有修改这些路径授权判据。手工验证
自审完整 diff,确认能力目录和 media 工具不再要求用户先询问路径。内置视频解码器已移除;此前对该解码器的 MP4/WebM smoke 不作为当前视频查看链路的验收证据。
未执行的验证
未运行完整 Agent 创作会话、Windows/Linux 实机或 SSH 跨主机视频分析。Host 路径不保证能在 SSH 工作区直接读取,工具明确标注所属电脑;本次不增加跨主机文件传输。整仓测试交由 CI,本地执行影响面对应的定向测试与类型检查。
风险
风险分类
影响与回滚
session-attachment受管引用,读取前后和批量返回前复核,校验文件内容指纹。自动最多两张、总内联预算 140 KB。读取前沿用模型图片 6 MiB 输入上限;源图最多 16,777,216 像素,直接从 Buffer 解码,超预算时先缩到最长边 1280,再仅对缩略图调整质量。达标后才编码 Base64,避免原图重复复制、解码。超限保留原始成果,Agent 可取路径自行分析。inspect路由、还原工具说明;原始媒体与生成状态保留,预览失败不会重新付费生成。提交前检查