From 221fb17c5e3956520852f19a83ade4411fe70c07 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Tue, 3 Feb 2026 15:06:18 -0800 Subject: [PATCH] Refine typing indicator behavior in message handling - Adjusted the `_keep_typing` method to refresh the typing indicator every 2 seconds instead of 4, improving responsiveness after progress messages. - Updated the `GatewayRunner` to restore the typing indicator after sending progress messages, enhancing user experience during message processing. --- gateway/platforms/base.py | 5 +++-- gateway/run.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py index 839561b5..21a806c1 100644 --- a/gateway/platforms/base.py +++ b/gateway/platforms/base.py @@ -172,11 +172,12 @@ class BasePlatformAdapter(ABC): """ pass - async def _keep_typing(self, chat_id: str, interval: float = 4.0) -> None: + async def _keep_typing(self, chat_id: str, interval: float = 2.0) -> None: """ Continuously send typing indicator until cancelled. - Telegram/Discord typing status expires after ~5 seconds, so we refresh every 4. + Telegram/Discord typing status expires after ~5 seconds, so we refresh every 2 + to recover quickly after progress messages interrupt it. """ try: while True: diff --git a/gateway/run.py b/gateway/run.py index 06937d54..113707f6 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -414,7 +414,9 @@ class GatewayRunner: # Non-blocking check with small timeout msg = progress_queue.get_nowait() await adapter.send(chat_id=source.chat_id, content=msg) - await asyncio.sleep(0.5) # Small delay between messages + # Restore typing indicator after sending progress message + await asyncio.sleep(0.3) + await adapter.send_typing(source.chat_id) except queue.Empty: await asyncio.sleep(0.3) # Check again soon except asyncio.CancelledError: