fix: prevent duplicate control response for already-handled requests (#229)#230
Merged
Nathan Schram (nathanschram) merged 2 commits intodevfrom Mar 27, 2026
Merged
Conversation
Update error hint text from "corrupted during a restart" to "archived or expired" — better reflects the actual cause when Claude Code auto-archives a session between resume runs. Related: anthropics/claude-code#39178 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…229) When a user clicks Approve/Deny on a control request via Telegram, send_claude_control_response() marks it in _HANDLED_REQUESTS but can't access state.pending_control_requests. The 5-minute expiry check then sends a duplicate DENY for the same request_id, causing Claude Code to receive conflicting approve+deny responses and stall. Add reconciliation in translate() that checks _HANDLED_REQUESTS against pending_control_requests before the expiry loop: - Removes already-handled requests from pending (prevents spurious deny) - Emits action_completed to clear stale inline keyboards - Adds belt-and-suspenders guard on the expiry list comprehension The upstream Claude Code freeze is tracked in anthropics/claude-code#39666. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
translate()that syncs_HANDLED_REQUESTSwithstate.pending_control_requestsaction_completedto clear stale inline keyboards from progress messagesFixes #229
What happened
When a user clicks Approve on a control request (e.g. ExitPlanMode),
send_claude_control_response()writes the response to Claude Code's stdin and marks it in_HANDLED_REQUESTS. But it can't accessstate.pending_control_requests(local to the translate loop). After 5 minutes, the expiry check finds the already-handled request and sends a second DENY — Claude Code receives conflicting approve+deny responses for the samerequest_idand stalls.The upstream Claude Code freeze (ignoring a valid approval written to stdin) is tracked in anthropics/claude-code#39666.
Changes
src/untether/runners/claude.py:request_to_actionmapping onClaudeStreamState(request_id → action_id)action_completedrid not in _HANDLED_REQUESTStests/test_claude_control.py:test_handled_request_not_auto_denied_on_expiry— verifies handled requests skip auto-denytest_reconciliation_emits_action_completed_for_stale_keyboard— verifies keyboard cleanupTest plan
ruff check)@untether_dev_bot, approve ExitPlanMode, verify no stale keyboard and noexpired_auto_denyin logs🤖 Generated with Claude Code