fix: clear stale blocked status when approval prompt disappears#6
Open
bloodcarter wants to merge 1 commit intoaannoo:mainfrom
Open
fix: clear stale blocked status when approval prompt disappears#6bloodcarter wants to merge 1 commit intoaannoo:mainfrom
bloodcarter wants to merge 1 commit intoaannoo:mainfrom
Conversation
When a PTY-detected approval prompt is resolved, the delivery loop's recovery branch only checked for ST_ACTIVE status, skipping recovery when status was ST_BLOCKED. This left agents showing "blocked" in hcom list even after the prompt was approved. Add immediate blocked-to-listening transition when approval_showing goes false but DB still says blocked. 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.
Problem
When a PTY agent displays a permission/approval prompt, the delivery loop correctly sets the agent's status to
■ blockedin the database. However, when the user approves the prompt and the agent resumes work, the status stays stuck as "blocked" until the agent's entire turn completes and the Stop hook fires.Expected behavior
After a user approves a permission prompt,
hcom listshould show the agent as▶ activeor◉ listeningwithin a few seconds.Actual behavior
hcom listcontinues to show■ blockedfor the duration of the agent's turn (potentially minutes), even though:This can mislead orchestrators into attempting to unblock an agent that isn't stuck, potentially disrupting its work.
Root cause
In the delivery loop's gate-blocked branch (
src/delivery.rs), whenscreen.approvalgoes fromtruetofalse:reason = "not_idle"because the agent is actively producing outputif status == ST_ACTIVE— it never matches "blocked"Result: status is stuck as "blocked" from approval-clear until turn-end.
Fix
Added an immediate recovery check in the gate-blocked branch: when
approval_showingisfalse,gate.reasonis"not_idle", and the DB status is still"blocked", clear it to"listening"right away. This runs before the existingST_ACTIVEstability recovery.Why this is safe
screen.approvalis a one-way latch cleared only by user input, andclear_approval()also clears the output buffer to prevent re-triggering from stale OSC9 bytes.Verification
🤖 Generated with Claude Code