fix: prevent duplicate interactive UI messages#1
Merged
Conversation
Remove the fallback sender in status_polling that raced with the JSONL path, causing the interactive UI to be sent twice. Instead, make the JSONL path (the sole sender) retry pane capture with increasing delays (0.3s, 0.7s, 1.0s) to handle slow UI rendering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Problem
Two independent code paths could send the same interactive UI to Telegram:
bot.py:handle_new_message): detects tool_use in JSONL, callshandle_interactive_ui()status_polling.py): detects UI in terminal pane, callshandle_interactive_ui()as a "fallback"The fallback's
get_interactive_msg_id()guard failed due to an async race — both paths calledsend_message()before either stored the message ID.Log evidence:
Fix
Single-sender design: only the JSONL path sends AskUserQuestion/ExitPlanMode UIs. The status poll's role is limited to
set_interactive_mode()(suppressing status updates while the prompt is active).The fallback was originally added because the JSONL path's 0.3s sleep sometimes wasn't enough for Claude Code to render the UI. Instead of a second sender, the JSONL path now retries with increasing delays (0.3s, 0.7s, 1.0s).
Changes
status_polling.py: removeget_interactive_msg_idfallback call for JSONL-tracked UIsbot.py: replace single 0.3s sleep with retry loop (0.3s, 0.7s, 1.0s)Test plan
🤖 Generated with Claude Code