@@ -229,13 +229,34 @@ def test_no_data_returns_zero(self):
229229class TestResolveAgent :
230230 def test_stdin_agent_preferred (self ):
231231 stdin = {"agent" : {"name" : "security-reviewer" }}
232- assert hud .resolve_agent (stdin , "old-env-agent" ) == "security-reviewer"
232+ assert hud .resolve_agent (stdin , env_agent = "old-env-agent" ) == "security-reviewer"
233+
234+ def test_stdin_overrides_hud_state (self ):
235+ stdin = {"agent" : {"name" : "security-reviewer" }}
236+ state = {"activeAgent" : "plan-mode" }
237+ assert hud .resolve_agent (stdin , state , "env-agent" ) == "security-reviewer"
238+
239+ def test_hud_state_fallback (self ):
240+ assert hud .resolve_agent ({}, {"activeAgent" : "security-specialist" }) == "security-specialist"
241+
242+ def test_hud_state_overrides_env (self ):
243+ state = {"activeAgent" : "security-specialist" }
244+ assert hud .resolve_agent ({}, state , "env-agent" ) == "security-specialist"
233245
234246 def test_fallback_to_env (self ):
235- assert hud .resolve_agent ({}, "env-agent" ) == "env-agent"
247+ assert hud .resolve_agent ({}, env_agent = "env-agent" ) == "env-agent"
248+
249+ def test_env_when_hud_state_empty (self ):
250+ assert hud .resolve_agent ({}, {"activeAgent" : "" }, "env-agent" ) == "env-agent"
251+
252+ def test_env_when_hud_state_none (self ):
253+ assert hud .resolve_agent ({}, None , "env-agent" ) == "env-agent"
236254
237- def test_both_empty (self ):
238- assert hud .resolve_agent ({}, "" ) == ""
255+ def test_all_empty (self ):
256+ assert hud .resolve_agent ({}, {}, "" ) == ""
257+
258+ def test_both_empty_no_hud (self ):
259+ assert hud .resolve_agent ({}, None , "" ) == ""
239260
240261
241262class TestResolveModelLabel :
@@ -359,6 +380,32 @@ def test_stdin_agent_overrides_env_badge(self):
359380 assert "[\u2605 fron]" in result # [★ fron]
360381 assert "\u25d0 " not in result # ◐ (backend glyph) absent
361382
383+ def test_hud_state_agent_fallback_badge (self ):
384+ result = hud .format_status_line (
385+ {},
386+ {"activeAgent" : "security-specialist" , "focus" : "auth" , "blockerCount" : 1 },
387+ )
388+ lines = result .strip ().split ("\n " )
389+ assert len (lines ) == 2
390+ assert "[\u25ee secu]" in lines [1 ] # [◮ secu]
391+ assert "[auth]" in lines [1 ]
392+ assert "[\u26a0 1]" in lines [1 ] # [⚠1]
393+
394+ def test_stdin_agent_overrides_hud_state (self ):
395+ stdin = {"agent" : {"name" : "frontend-developer" }}
396+ state = {"activeAgent" : "security-specialist" }
397+ result = hud .format_status_line (stdin , state )
398+ assert "[\u2605 fron]" in result # [★ fron]
399+ assert "\u25ee " not in result # ◮ (security glyph) absent
400+
401+ def test_hud_state_agent_overrides_env (self ):
402+ state = {"activeAgent" : "security-specialist" }
403+ result = hud .format_status_line ({}, state , active_agent = "backend-developer" )
404+ lines = result .strip ().split ("\n " )
405+ assert len (lines ) == 2
406+ assert "[\u25ee secu]" in lines [1 ] # [◮ secu] from hud_state
407+ assert "\u25d0 " not in result # ◐ (backend glyph) absent
408+
362409 def test_no_agent_single_line (self ):
363410 result = hud .format_status_line ({}, {"version" : "5.1.1" })
364411 assert "\n " not in result
0 commit comments