fix(gateway): bypass text batching when delay is 0 (#6996)

The text batching feature routes TEXT messages through
asyncio.create_task() + asyncio.sleep(delay). Even with delay=0,
the task fires asynchronously and won't complete before synchronous
test assertions. This broke 33 tests across Discord, Matrix, and
WeCom adapters.

When _text_batch_delay_seconds is 0 (the test fixture setting),
dispatch directly to handle_message() instead of going through
the async batching path. This preserves the pre-batching behavior
for tests while keeping batching active in production (default
delay 0.6s).
This commit is contained in:
Teknium 2026-04-09 23:59:20 -07:00 committed by GitHub
parent d5023d36d8
commit 13d7ff3420
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View file

@ -1101,7 +1101,7 @@ class MatrixAdapter(BasePlatformAdapter):
self._background_read_receipt(room.room_id, event.event_id)
# Only batch plain text messages — commands dispatch immediately.
if msg_type == MessageType.TEXT:
if msg_type == MessageType.TEXT and self._text_batch_delay_seconds > 0:
self._enqueue_text_event(msg_event)
else:
await self.handle_message(msg_event)