Merged
Conversation
对于支持图像输入的模型(supportsImage),在 Cowork 模式中上传图片时, 将图片以 base64 image content block 直接放入 messages 发送给模型, 利用模型原生视觉能力识别图片内容,而非走原有的文件路径 + ReadFile 工具流程。 对于不支持图像的模型,维持现有的文件路径逻辑不变。 主要改动: - 新增 CoworkImageAttachment 类型定义 - CoworkPromptInput 识别图片文件(扩展名白名单),读取为 base64 data URL - 新增 dialog:readFileAsDataUrl IPC 接口(读取本地图片,20MB 限制) - 全链路透传 imageAttachments:UI → IPC → CoworkRunner - CoworkRunner 在 local 模式下构造 SDKUserMessage with image blocks, 通过 AsyncIterable 形式传给 Claude Agent SDK 的 query() 函数 - 图片附件在 UI 中以蓝色 PhotoIcon 区分显示 - 图片 base64 数据持久化到消息 metadata 中(支持多轮对话上下文) - OpenAI 兼容代理已有 image → image_url 转换,无需额外修改 已验证:kimi-k2 模型可正常工作。 已知遗留问题(后续更新): - 聊天消息列表中未显示图片内容预览或文件路径,需补充 UI 展示 - minimax 等部分模型/渠道尚需进一步测试兼容性 - sandbox 模式下图片附件暂回退为文件路径方式 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. 修复 sanitizeCoworkMessageForIpc 截断 imageAttachments base64 数据的问题 - 之前 sanitizeIpcPayload 会将 base64 字符串截断至 4000 字符 - 现在将 imageAttachments 从通用 sanitize 流程中排除,保留原始数据 2. 在 UserMessageItem 中添加图片缩略图预览和点击放大 lightbox 3. 修复 tempSession 中首轮消息也包含 imageAttachments metadata 4. 更新 electron.d.ts 类型定义,补充 imageAttachments 和 readFileAsDataUrl Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
startSession 的 !skipInitialUserMessage 分支构建用户消息时, 仅处理了 skillIds 而忽略了 imageAttachments,导致当 continueSession 因 activeSession 不存在而 fallback 到 startSession 时, 图片附件的 metadata 丢失,前端无法渲染图片预览。
在 IPC handler、CoworkRunner、CoworkService、CoworkView、 CoworkPromptInput、UserMessageItem 各环节添加 imageAttachments 相关的 console.log,便于追踪图片数据在进程间传递时是否丢失。
Closed
This was referenced Mar 3, 2026
mammut001
pushed a commit
to mammut001/LobsterAI
that referenced
this pull request
Mar 11, 2026
…base64-input Feat/image base64 input
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
Closes #71