fix: sticky idle state prevents stale working status - #149
Merged
Conversation
The agent status state machine could get stuck showing "working" when late-arriving hook events (PostToolUse, SubagentStop, etc.) overrode the idle status set by the Stop event. This was exacerbated by known CC bugs where Stop hooks don't always fire (#26770, #29881). Changes: - Make idle and stopped "sticky" states — only UserPromptSubmit, SessionStart, SessionEnd, PermissionRequest, Notification, and PreToolUse can transition out of them - Log dropped events for debugging sticky guard behavior - Fix dashboard default status fallback from "working" to "unknown" (agents with no hook state showed as spinning) - Add Notification to idle exit events so permission_prompt notifications can break through the sticky guard - Add comprehensive tests for sticky idle behavior (11 new tests) - Export clearAgentState helper for test cleanup Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
aterrylu
marked this pull request as ready for review
April 15, 2026 06:01
nox-0x
approved these changes
Apr 15, 2026
nox-0x
left a comment
Collaborator
There was a problem hiding this comment.
Solid fix. Sticky idle/stopped guard is clean and well-tested (11 new cases). The UI fallback change from "working" to "unknown" is the right call — no hook state != actively working. LGTM.
8 tasks
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
deriveStatus()state machine had no protection against late-arriving hook events overriding the idle stateChanges
idleandstoppedcan only be exited byUserPromptSubmit,SessionStart,SessionEnd,PermissionRequest,Notification, orPreToolUse. LatePostToolUse,SubagentStop, etc. are logged and dropped?? "working"fallback to?? "unknown"in Sidebar and TabBar so agents with no hook state don't show as spinningNotificationadded to idle exit events sopermission_promptnotifications can break through the sticky guardCC Bug References
commandtype sometimes never fireTest plan
🤖 Generated with Claude Code