feat: 独立对话(ChatAgent)也支持文件上传(方式1:落盘 + Read/Bash 读取)

补齐上次只做了任务主 Agent 的遗留:独立对话面此前只共用了 transcript 渲染,
后端注入 + Composer 上传缺失,现补上。

- 后端(pgSendConversationMessage):收 attachments;用 userActivityWithAttachments
  存 {text,attachments} JSON 供卡片渲染(无附件仍存全文 Detail 供懒加载);用
  composeAgentMessage 把【绝对路径】清单拼进发给 ChatAgent 的消息,baseDir=
  <workDir>/sessions/conv-<id>/,与 chatUpload 落盘、chat.go 的 sessionWorkDir 对齐;
  纯附件无文本也可发,首条会话名兜底"附件消息"。
- 前端(chat/page.tsx):Composer 加回形针上传按钮 + 附件 chip 预览(可移除);
  ChatView 上传到 scope=session&id=conv-<id> 并带附件发送;DraftChat 草稿态没有
  会话 id,点回形针先懒创建会话再上传,交接文本+附件给 ChatView 发送。
- api.sendConversationMessage 增加 attachments 参数。
This commit is contained in:
Autumn-27 committed 2026-08-18 07:55:18 -04:00
1 parent 071414063e
commit 683f5ee684
3 files changed
+162 -17

No files matched your search

+2 -2
View File
@@ -414,8 +414,8 @@ export const api = {
},
conversationMsgDetail: (id: number, seq: number) =>
get<{ detail: string }>(`/conversations/${id}/messages/${seq}`).then((r) => r.detail ?? ""),
sendConversationMessage: (id: number, message: string) =>
post<{ status: string }>(`/conversations/${id}/messages`, { message }),
sendConversationMessage: (id: number, message: string, attachments?: ChatAttachment[]) =>
post<{ status: string }>(`/conversations/${id}/messages`, { message, attachments }),
stopConversation: (id: number) => post<{ status: string }>(`/conversations/${id}/stop`, {}),
saveAgentPrompt: (key: string, template: string, note = "") => put<{ version: number }>(`/agents/${key}/prompt`, { template, note }),
resetAgentPrompt: (key: string) => post<{ version: number }>(`/agents/${key}/prompt/reset`, {}),