feat(desktop): Composer 直连生图/生视频#75
Conversation
抽取 resolveComposerDirectMediaTool(slot_match,双槽同名优先视频)与 buildImageGenerationSubConfig / buildMediaOnlyTransportConfig,并补充单测。
新增 direct-media-turn:媒体专用 transport、generate_image/video 调用、 orchestrator 事件与 archiveHistory 三段写入;附执行器与归档单测。
在 submitUserTurnAfterInitializedCommand 中分流直连路径;有附件时回退聊天; SessionTurnOrchestratorContext 注入 requireConfig 与 API Key 解析。
直连模式下切换占位符与模型按钮旁「生图/生视频」标签,并补充中英文 i18n。
纯 imageGeneration 模型作为当前推理时自动走直连生图;Vercel AI Gateway 生图改用 provider.image() v3 协议,避免误走 language-model 聊天 API。
直连生图等长耗时回合在 API 返回前即乐观清空草稿;失败时恢复原文, 并在提交时同步 resetAfterSend 以清空富文本 DOM。
直连生图/生视频仅写入 archiveHistory 时,后续 persist(fromRuntime) 或切回聊天模型后的 refreshArchiveFromRuntime 会用空 runtime 覆盖归档;在 executeDirectMediaTurn 完成后将归档灌入 runtime。
占位符文案仍保留,仅去掉模型名右侧 Image/Video 提示卡片及相关 i18n。
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7dc407f. Configure here.
| } | ||
| } | ||
|
|
||
| composerRichInputRef.current?.resetAfterSend(runtime.settings.agentMode); |
There was a problem hiding this comment.
发送失败草稿无法恢复
High Severity
submitComposerMessage 在调用 sendMessage 之前就会执行 resetAfterSend 并清空父级 composer;失败时 useDesktopRuntime 虽用 setComposer 恢复文本,但 ComposerRichInput 在 skipExternalValueSyncRef 与 conversationBusy 下会跳过外部值同步,界面常仍为空,用户会误以为草稿已丢失。
Additional Locations (1)
Triggered by project rule: Bugbot
Reviewed by Cursor Bugbot for commit 7dc407f. Configure here.
| config, | ||
| config.activeModel, | ||
| explicitWorkspaceFiles.length, | ||
| ); |
There was a problem hiding this comment.
直连模式模型来源不一致
Medium Severity
Composer 占位符用 runtime.settings.activeModel 判断直连生图/生视频,但 submitUserTurnAfterInitialized 用 config.activeModel 决定是否走 executeDirectMediaTurn。模型选择后 setActiveModel 会乐观更新 settings,而 updateConfig 异步完成前两者可能不一致,出现占位符提示直连、实际仍走聊天或相反。
Additional Locations (1)
Triggered by project rule: Bugbot
Reviewed by Cursor Bugbot for commit 7dc407f. Configure here.
发送成功后再清空 RichInput 与 composer 草稿,避免失败时 skipExternalValueSync 导致界面无法恢复。直连占位符改用 snapshot.config.activeModel,与宿主 submit 路径一致。


Summary
untime.history,切回聊天模型后续聊可引用生成结果。
Test plan