fix(agent): 主 Agent 每个会话均可交互,修实时徽章滞留
上一版把非当前段设为只读、且仅当前段可发消息,与"像会话页一样在任一 会话都能对话"的诉求不符;同时实时徽章改用 recentLive 后,turn 结束仍 会在 5s 窗口内继续显示"实时流式中"。 - server: chat 接口接收目标段 seg,消息写到用户正在看的会话段(缺省=最新段) - web: 去掉只读/当前/历史区分,任一主 Agent 会话都可直接对话;send 带 seg - web: 实时徽章改回按真实运行状态(sending/mainChatRunning)判断,且收到 终结记录(result/报错)即刻熄灭;输入框同样在终结记录后立即解禁
This commit is contained in:
1 parent
b4bbe612df
commit
6b59d4126e
4 files changed
+57
-50
No files matched your search
+11
-4
@@ -3450,6 +3450,7 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Message string `json:"message"`
|
||||
Attachments []chatAttachment `json:"attachments,omitempty"` // 方式1 上传的文件(路径相对任务工作目录)
|
||||
Seg *int `json:"seg,omitempty"` // 目标主会话分段;缺省=最新段
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeErr(w, 400, err.Error())
|
||||
@@ -3474,10 +3475,16 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) {
|
||||
s.chatCancel[t.ID] = cancel
|
||||
s.chatMu.Unlock()
|
||||
|
||||
// The whole turn belongs to the current main-agent segment. Read it once (chatBusy
|
||||
// serializes turns, so it can't change under us) and stamp every mainagent row with
|
||||
// it, so this turn's transcript + activity land in the segment the user is viewing.
|
||||
mainSeg, _ := t.Store.CurrentMainSeg()
|
||||
// The turn belongs to whichever main-agent segment the user is chatting in (any
|
||||
// segment is interactive, like the top-level chat conversations). Stamp every
|
||||
// mainagent row with it so this turn's transcript + activity land in that segment.
|
||||
// Missing seg (older clients) falls back to the newest segment.
|
||||
mainSeg := 0
|
||||
if req.Seg != nil && *req.Seg >= 0 {
|
||||
mainSeg = *req.Seg
|
||||
} else {
|
||||
mainSeg, _ = t.Store.CurrentMainSeg()
|
||||
}
|
||||
segPtr := &mainSeg
|
||||
|
||||
// Persist + broadcast the human turn so the 主 Agent 编排会话 survives page
|
||||
|
||||
Reference in new issue
Block a user