fix(telegram): stop typing indicator from lingering after response delivery - #30732
Closed
mpesce wants to merge 1 commit into
Closed
fix(telegram): stop typing indicator from lingering after response delivery#30732mpesce wants to merge 1 commit into
mpesce wants to merge 1 commit into
Conversation
…livery Telegram has no native 'stop typing' API — the indicator self-expires after ~5s. The gateway's _keep_typing() loop fires send_typing() every ~2s, and a race condition causes one final refresh after the response is already delivered, keeping the indicator alive for another 5s. Add stop_typing() to TelegramAdapter using the existing _typing_paused mechanism from the base adapter. The gateway already calls stop_typing() at the right moment — this just gives Telegram an implementation that pauses the refresh loop's last tick instead of inheriting the no-op. The _typing_paused set and the _keep_typing check/finally cleanup are already in BasePlatformAdapter — no new infrastructure needed.
Collaborator
Author
|
Closing in favor of #29595 — the notify-flag approach is strictly better for Telegram: it prevents the re-arm before it happens rather than racing to suppress it after, avoids new infrastructure, and has regression tests. Three well-considered approaches for the same bug is a good sign for the project. Thanks for the review. |
Author
|
Closed in favor of #29595. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Telegram shows a "typing..." indicator that persists for ~5 seconds after the agent response has already been delivered. This happens because:
_keep_typing()loop (inbase.py) firessend_typing()every ~2s to keep the bubble alive during processingadapter.stop_typing(chat_id)atgateway/run.py:8441TelegramAdapterinherits the base class's emptystop_typing()_keep_typingbackground task is still alive — cancellation hasn't propagated yetsend_typing()fires, resetting Telegram's 5s timerPlatforms with native stop-typing APIs (Slack, Signal, Matrix) override
stop_typing()to actively clear the indicator. Telegram can't, but it can suppress the next refresh.Fix
Add
stop_typing()toTelegramAdapterthat pauses the typing refresh loop using the existing_typing_pausedmechanism fromBasePlatformAdapter. No new infrastructure needed —_typing_pausedalready exists (line 1350),_keep_typingalready checks it (line 2304), and thefinallyblock already cleans it up (line 2349).Testing
Tested on systemd 259 (Ubuntu) with Telegram Bot API. After the fix, the typing indicator fades naturally within ~5s of the final
send_typing()call rather than getting a late refresh after the response is already visible.