fix(channelbridge): IM 渠道也走「回合必落可见回复」(与网关同口径)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

根因(agent-194,文件:行):
- inbound.go 的 deliverReply 对空回复直接 return(静默)⇒ 只剩 user 消息;
- runInboundTurn 报错直接 return ⇒ 失败回合连说明都没有。
修法:抽共享**纯函数**包 internal/runtime/turnreply(从网关逐字搬运、零语义改动)+
channelbridge/turnreply.go 的 turnVisibleReply(与网关 persistTurnReply 同构);
取消边界在 IM 用 context.Canceled / ctx 取消表达(渠道桥无代次概念,如实登记差异)。
测试 6 条:空回复/纯空白/轮次用尽/安全网/回合报错/取消不落库/正常逐字不变。
变异:还原旧静默行为 ⇒ 4 条红(含「出站 0 条,want 1」与英文内部诊断外泄)。
This commit is contained in:
AskaEth committed 2026-10-04 22:29:54 +08:00
1 parent be38651ba4
commit fbbbb4ea64
6 files changed
+380 -73

No files matched your search

@@ -183,23 +183,6 @@ func TestProcessSkipsEmptyText(t *testing.T) {
}
}
func TestProcessLoopErrorDoesNotSend(t *testing.T) {
t.Parallel()
b, chat, _, ad := newTestBridge(t)
chat.res = nil
chat.err = context.DeadlineExceeded
b.process(context.Background(), directMessage())
if chat.sessionID != history.MainSessionID {
t.Errorf("loop should still run for valid text on the main session, session = %q", chat.sessionID)
}
if len(ad.sends) != 0 {
t.Errorf("send count = %d, want 0 on loop error", len(ad.sends))
}
}
func TestProcessGroupMessageKeepsGroupTarget(t *testing.T) {
t.Parallel()
@@ -231,19 +214,6 @@ func TestProcessGroupMessageKeepsGroupTarget(t *testing.T) {
}
}
func TestProcessEmptyReplySendsNothing(t *testing.T) {
t.Parallel()
b, chat, _, ad := newTestBridge(t)
chat.res = &loop.Result{Text: " "}
b.process(context.Background(), directMessage())
if len(ad.sends) != 0 {
t.Errorf("send count = %d, want 0 for empty reply", len(ad.sends))
}
}
// captureHistory 记录每次 Append,用于断言桥接器把主人私聊
// 消息写入 Web 主会话(design/16 §4.4)。
type captureHistory struct {