fix: prevent false positives from stale approval buttons in chat history
State machine no longer transitions directly from IDLE to WAITING_FOR_USER on approval signals. Must see AGENT_WORKING first — this prevents stale buttons like "Run this time only" persisting in chat history from triggering the flash when no agent task is active. Also removed "Continue" and "Resume" from approval keywords (too generic, appear in normal chat text). Made-with: Cursor
This commit is contained in:
@@ -66,10 +66,17 @@ class TestStateMachine:
|
||||
changed = sm.update(agent_working=False, approval_needed=False)
|
||||
assert sm.cooldown == 5.0
|
||||
|
||||
def test_direct_approval_from_idle(self):
|
||||
"""If we detect approval buttons without seeing agent_working first,
|
||||
still transition to WAITING_FOR_USER."""
|
||||
def test_stale_approval_from_idle_ignored(self):
|
||||
"""Approval buttons in IDLE state (stale chat history) must not trigger flash."""
|
||||
sm = StateMachine()
|
||||
changed = sm.update(agent_working=False, approval_needed=True)
|
||||
assert sm.state == FlasherState.IDLE
|
||||
assert changed is False
|
||||
|
||||
def test_approval_after_working_triggers(self):
|
||||
"""Approval buttons after seeing agent work should trigger flash."""
|
||||
sm = StateMachine()
|
||||
sm.update(agent_working=True, approval_needed=False)
|
||||
changed = sm.update(agent_working=False, approval_needed=True)
|
||||
assert sm.state == FlasherState.WAITING_FOR_USER
|
||||
assert changed is True
|
||||
|
||||
Reference in New Issue
Block a user