fix(wire): a.gw 在接线 onPersisted 前赋值——防 nil Server panic
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

wire.go 原在 a.channelBridge.SetOnPersisted(a.gw.BroadcastPersisted) / AuditEvent 之后才
a.gw=gw(663),导致网关 Server 字段为 nil;一旦有 IM 主人私聊落主会话→notifyPersisted→
BroadcastPersisted(nil receiver)→panic 崩溃,面板 adminBackthink 请求失败显示'暂无后台思考'。
把 a.gw=gw 提前到 gw.SetVoice 后(接线前),移除冗余复制。go build/test 全绿, 已重建部署.
This commit is contained in:
Aska committed 2026-09-07 19:54:14 +08:00
1 parent 6a2b8b9f12
commit 9f35b2663e
1 file changed
+2 -1
+2 -1
View File
@@ -648,6 +648,7 @@ func (a *app) wireFrontend() error {
return fmt.Errorf("gateway: %w", err)
}
gw.SetVoice(a.voice)
a.gw = gw // assign BEFORE wiring hooks below, which capture a.gw / gw (nil-receiver panic otherwise)
if a.channelBridge != nil {
// Route the channel bridge's owner-private persisted messages into the same
// `message_persisted` broadcast the orchestrator uses, so the Web client mirrors
@@ -660,9 +661,9 @@ func (a *app) wireFrontend() error {
a.gw.AuditEvent("bridge:"+msg.Platform, "channel.reject", reason)
})
}
a.gw = gw
a.capacitySink = gw
// Wire the backthink proactive sinks now that the gateway hub (active-client
// route) and the channel bridge (IM fallback) both exist. They were absent when
// backthink.New ran (the hub needs the loop and the bridge needs the loop and the