From ec327b4b9fbdc74311c599a32a011a86a0f995b1 Mon Sep 17 00:00:00 2001 From: Nan Jiang Date: Thu, 4 Jun 2026 08:20:21 +0800 Subject: [PATCH] fix(discord): stop typing indicator before response delivery The persistent typing loop can keep the typing indicator active past the moment the bot's reply is sent, causing a ~10s 'typing...' bubble that visually overlaps the response text on Discord. Move the typing stop from the generic cleanup path (which fires after response delivery) to just before the response is sent, ensuring the indicator is dismissed before the reply arrives. --- gateway/platforms/base.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py index 89806a739312..098671bca0db 100644 --- a/gateway/platforms/base.py +++ b/gateway/platforms/base.py @@ -4034,6 +4034,16 @@ async def _stop_typing_task() -> None: # cancelling, let this message-processing task unwind now. pass + async def _stop_typing_now(chat_id: str) -> None: + """Stop the persistent typing loop *before* response delivery + so Discord's ~10s typing indicator doesn't overlap the reply.""" + await _stop_typing_task() + try: + if hasattr(self, "stop_typing"): + await self.stop_typing(chat_id) + except Exception: + pass + try: await self._run_processing_hook("on_processing_start", event) @@ -4069,6 +4079,9 @@ async def _stop_typing_task() -> None: session_key, ) response = None + # Stop persistent typing indicator before response delivery so + # Discord's ~10s typing bubble doesn't overlap the reply text. + await _stop_typing_now(event.source.chat_id) if not response: logger.debug("[%s] Handler returned empty/None response for %s", self.name, event.source.chat_id) if response: