refactor(channelbridge): 多气泡分割+旁白剥离+随机延迟上移为IM公共出口——sendReply/SendProactive统一(微信主动推送也分割)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

This commit is contained in:
Aska committed 2026-09-08 16:26:35 +08:00
1 parent d09b25071d
commit bcf7fe5de0
4 files changed
+233 -36

No files matched your search

+12 -1
View File
@@ -31,6 +31,11 @@ const proactiveRecentCount = 20
// WeChat is a first-class candidate (it is whitelisted and, when connected, the
// recent-active/fallback selection may pick it).
//
// The push exits through the shared IM bubble dispatcher (sendIMBubbles), so a
// multi-paragraph message is split into bubbles, role-play/narration is stripped, and
// sends are spaced 0.5-2s apart — the same behaviour as a reply, and the reason
// WeChat/other IM proactive pushes no longer arrive as one un-split <p> blob.
//
// When the owner profile has no whitelisted account that is backed by a connected
// adapter it returns a clear error so the caller records the reason rather than
// silently dropping the push.
@@ -55,7 +60,13 @@ func (b *Bridge) SendProactive(ctx context.Context, msg adapter.UnifiedMessage)
// prefers, without duplicating the message.
out.ChannelID = target.accountID
out.SenderID = target.accountID
if err := ad.SendProactive(ctx, out); err != nil {
// The push exits through the shared IM bubble dispatcher, so a multi-paragraph
// proactive message is split into bubbles and role-play/narration is stripped, with
// the same 0.5-2s gap as a reply — WeChat proactive pushes are no longer sent as a
// single un-split message.
if err := b.sendIMBubbles(ctx, out, func(ctx context.Context, msg adapter.UnifiedMessage) error {
return ad.SendProactive(ctx, msg)
}, msg.Content); err != nil {
return fmt.Errorf("channelbridge: send proactive via %q: %w", target.platform, err)
}
// Mirror the proactive message into the main conversation context (design/16