mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-15 12:15:16 +00:00
fix(webui): 附件死锁 + qq 插件文件发送收敛到 output 通道
1. webui 附件死锁修复(output_send__webui 发图 60s 超时根因) EventAgentOutput 订阅者已持 chatMu,附件分支调 addChatMsg(内部 再次 Lock)——sync.Mutex 不可重入导致 Publish 永久阻塞,工具超时、 图片永远发不出来。改为持锁状态下直接操作 chatHistory+persist。 2. qq 插件 image/file 分支收敛到 output 通道 output_send__qq 的 type=image/file 此前只透传 payload 给 CQ 码, 发本地文件必须绕道 upload_group_file 独立工具。现在与 voice 分支 同模式:本地路径拷入 NapCat 共享目录转 file:///app/files/<name> URI, http(s)/file:// URL 保持透传。upload_group_file 保留作为群文件柜 专用入口。 验证:工具链重编译 → qq.hmap 重打包 → pluginmgr overwrite 安装 (config_kept=true)→ agent 经 output_send__qq 用本地路径发图成功, mascot.webp 已落共享目录。
This commit is contained in:
@ -470,7 +470,6 @@ func (h *Handler) subscribeChatEvents() {
|
|||||||
}
|
}
|
||||||
m := ChatMsg{
|
m := ChatMsg{
|
||||||
Role: "assistant",
|
Role: "assistant",
|
||||||
Content: content,
|
|
||||||
Source: channel,
|
Source: channel,
|
||||||
Time: time.Unix(ev.Timestamp, 0).Format(time.RFC3339),
|
Time: time.Unix(ev.Timestamp, 0).Format(time.RFC3339),
|
||||||
Attachment: att,
|
Attachment: att,
|
||||||
@ -478,8 +477,23 @@ func (h *Handler) subscribeChatEvents() {
|
|||||||
// 附件消息不把本地路径当正文展示(如 "/tmp/homeagent.png"),置空
|
// 附件消息不把本地路径当正文展示(如 "/tmp/homeagent.png"),置空
|
||||||
if att != nil {
|
if att != nil {
|
||||||
m.Content = ""
|
m.Content = ""
|
||||||
|
} else {
|
||||||
|
m.Content = content
|
||||||
}
|
}
|
||||||
h.addChatMsg(m)
|
// 已持 chatMu:直接操作 chatHistory + persist,不可调 addChatMsg
|
||||||
|
//(内部会重入加锁导致死锁——output_send__webui 发图 60s 超时的根因)
|
||||||
|
h.chatHistory = append(h.chatHistory, m)
|
||||||
|
if len(h.chatHistory) > maxChatHistory {
|
||||||
|
drop := len(h.chatHistory) - maxChatHistory
|
||||||
|
h.chatHistory = h.chatHistory[drop:]
|
||||||
|
if h.pendingIdx >= 0 {
|
||||||
|
h.pendingIdx -= drop
|
||||||
|
if h.pendingIdx < 0 {
|
||||||
|
h.pendingIdx = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h.persistChatLocked()
|
||||||
h.chatMu.Unlock()
|
h.chatMu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
2330
third_party/homeagent-sdk/example/qq/plugin.go
vendored
Normal file
2330
third_party/homeagent-sdk/example/qq/plugin.go
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user