fix(channels): drop compaction notices on channels without an in-place affordance (#5799)

* fix(channels): drop compaction notices on channels without an in-place affordance

QQ's C2C/group message API has no edit or recall endpoint, so the
compaction lifecycle reached the chat as two permanent standalone
messages. Add a show_compaction_notices capability that defaults to
true (Telegram/Discord/WebSocket keep their in-place lifecycle) and
opt QQ out, with a per-channel showCompactionNotices config override.

Fixes #5784

* fix(qq): keep compaction-notice suppression inside the QQ channel

Per review on #5799: drop ContextCompactionEvent in QQChannel.send()
based on a QQ-local QQConfig.show_compaction_notices (default false,
camel alias showCompactionNotices) instead of a cross-channel
BaseChannel capability plus manager-level configuration and dispatch
policy. BaseChannel, ChannelManager and the manager compaction test
return to their upstream shape.

Also adds the missing zh-TW locale copy (plus es/id/ko/vi so all ten
QQ locales carry the new setup field) and QQ-level tests covering the
default drop, the enabled path, ordinary-message passthrough, and the
camelCase config override.
This commit is contained in:
AlfredChaos authored and GitHub committed 2026-09-18 00:45:58 +08:00
1 parent a0a99f24da
commit 24c41a6af0
14 files changed
+173

No files matched your search

+1
View File
@@ -11,6 +11,7 @@ SETUP_SPEC = ChannelSetupSpec(
"allowFrom": field("list"),
"msgFormat": field("enum", choices={"plain", "markdown"}, default="plain"),
"ackMessage": field(default="⏳ Processing..."),
"showCompactionNotices": field("bool", default=False),
"mediaDir": field(),
"downloadChunkSize": field("int", default=1024 * 256),
"downloadMaxBytes": field("int", default=1024 * 1024 * 200),
+17
View File
@@ -37,6 +37,7 @@ from loguru import logger
from pydantic import Field
from nanobot.bus.events import OutboundMessage
from nanobot.bus.outbound_events import ContextCompactionEvent
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.schema import Base
@@ -192,6 +193,11 @@ class QQConfig(Base):
download_chunk_size: int = 1024 * 256 # 256KB
download_max_bytes: int = 1024 * 1024 * 200 # 200MB safety limit
# QQ's C2C/group message API has no edit or recall endpoint, so compaction
# notices would land as separate permanent messages (#5784). Off by default;
# set showCompactionNotices: true to post them anyway.
show_compaction_notices: bool = False
class QQChannel(BaseChannel):
"""QQ channel using botpy SDK with WebSocket connection."""
@@ -298,6 +304,17 @@ class QQChannel(BaseChannel):
async def send(self, msg: OutboundMessage) -> None:
"""Send attachments first, then text."""
# Compaction notices assume the channel can update one message in place
# (Telegram/Discord edit their notice; WebSocket projects it as status).
# QQ's C2C/group API has no edit or recall endpoint, so by default the
# lifecycle is dropped here instead of posting two permanent messages
# (#5784); showCompactionNotices: true restores them.
if (
isinstance(msg.event, ContextCompactionEvent)
and not self.config.show_compaction_notices
):
return
try:
if not self._client:
raise RuntimeError("QQ client not initialized")
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "Maximum download size"
},
"showCompactionNotices": {
"label": "Compaction notices",
"choices": {
"true": "On",
"false": "Off"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "Tamaño máximo de descarga"
},
"showCompactionNotices": {
"label": "Avisos de compactación de contexto",
"choices": {
"true": "Activado",
"false": "Desactivado"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "Taille maximale de téléchargement"
},
"showCompactionNotices": {
"label": "Avis de compactage du contexte",
"choices": {
"true": "Activé",
"false": "Désactivé"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "Ukuran unduhan maksimum"
},
"showCompactionNotices": {
"label": "Notifikasi pemadatan konteks",
"choices": {
"true": "Aktif",
"false": "Nonaktif"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "最大ダウンロードサイズ"
},
"showCompactionNotices": {
"label": "コンテキスト圧縮通知",
"choices": {
"true": "オン",
"false": "オフ"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "최대 다운로드 크기"
},
"showCompactionNotices": {
"label": "컨텍스트 압축 알림",
"choices": {
"true": "켜기",
"false": "끄기"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "Tamanho máximo de download"
},
"showCompactionNotices": {
"label": "Avisos de compactação de contexto",
"choices": {
"true": "Ativado",
"false": "Desativado"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "Kích thước tải xuống tối đa"
},
"showCompactionNotices": {
"label": "Thông báo nén ngữ cảnh",
"choices": {
"true": "Bật",
"false": "Tắt"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "下载大小上限"
},
"showCompactionNotices": {
"label": "上下文压缩通知",
"choices": {
"true": "开",
"false": "关"
}
}
}
}
@@ -33,6 +33,13 @@
},
"downloadMaxBytes": {
"label": "下載大小上限"
},
"showCompactionNotices": {
"label": "上下文壓縮通知",
"choices": {
"true": "開",
"false": "關"
}
}
}
}