feat(chat): 支持多类型记录 @ 引用及滚动分页 (#135)

This commit is contained in:
RuoJi6 authored and GitHub committed 2026-09-16 22:36:07 +08:00
1 parent 1c6342d8b3
commit f6b5c11352
15 files changed
+1173 -25

No files matched your search

+6 -1
View File
@@ -888,6 +888,7 @@ func (s *Server) Handler() http.Handler {
mux.HandleFunc("PUT /api/settings", s.putSettings)
mux.HandleFunc("POST /api/settings/web-search/test", s.testWebSearch)
mux.HandleFunc("GET /api/report", s.getReport)
mux.HandleFunc("GET /api/chat/mentions", s.searchChatMentions)
mux.HandleFunc("POST /api/chat", s.chat)
mux.HandleFunc("POST /api/chat/upload", s.chatUpload) // 方式1 文件上传:落到会话/任务工作目录 uploads/
mux.HandleFunc("GET /api/tasks/{id}/chat/status", s.taskChatStatus)
@@ -3523,6 +3524,10 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) {
writeErr(w, 400, err.Error())
return
}
agentMessage, ok := s.prepareChatMentionMessage(w, req.Message)
if !ok {
return
}
// Admission is serialized with deletion's chat cancellation. Mark every chat
// turn busy before its first activity/file write, including rule-mode turns.
// If deletion wins the race, the second barrier check rejects this request.
@@ -3589,7 +3594,7 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) {
// 把上传附件的【绝对路径】清单拼进发给 agent 的消息,它据此用 Read/Bash 打开文件。
// taskDir = agent 的工作目录(CWD),与 chatUpload 落盘、ensureRunDir 一致。
taskDir := filepath.Join(s.m.dir, "tasks", t.ID)
agentMsg := composeAgentMessage(req.Message, req.Attachments, taskDir)
agentMsg := composeAgentMessage(agentMessage, req.Attachments, taskDir)
s.engine.BeginLLMCall(t.ID)
_, err := ma.Chat(ctx, maTaskID, mainSeg, s.m.Assets(), t.Store, t.Goal, agentMsg, emit, t.Notify, resume, t.NotifyGoal, t.NotifyHint)
s.engine.EndLLMCall(t.ID)