44from agent_chat_cli .components .chat_history import ChatHistory
55from agent_chat_cli .components .messages import (
66 Message ,
7+ RoleType ,
78 SystemMessage ,
89 UserMessage ,
910 AgentMessage ,
@@ -24,7 +25,9 @@ def app(self):
2425 async def test_adds_system_message (self , app ):
2526 async with app .run_test ():
2627 chat_history = app .query_one (ChatHistory )
27- chat_history .add_message (Message .system ("System alert" ))
28+ chat_history .add_message (
29+ Message (type = RoleType .SYSTEM , content = "System alert" )
30+ )
2831
2932 widgets = chat_history .query (SystemMessage )
3033 assert len (widgets ) == 1
@@ -33,7 +36,7 @@ async def test_adds_system_message(self, app):
3336 async def test_adds_user_message (self , app ):
3437 async with app .run_test ():
3538 chat_history = app .query_one (ChatHistory )
36- chat_history .add_message (Message . user ( "Hello" ))
39+ chat_history .add_message (Message ( type = RoleType . USER , content = "Hello" ))
3740
3841 widgets = chat_history .query (UserMessage )
3942 assert len (widgets ) == 1
@@ -42,7 +45,7 @@ async def test_adds_user_message(self, app):
4245 async def test_adds_agent_message (self , app ):
4346 async with app .run_test ():
4447 chat_history = app .query_one (ChatHistory )
45- chat_history .add_message (Message . agent ( "I can help" ))
48+ chat_history .add_message (Message ( type = RoleType . AGENT , content = "I can help" ))
4649
4750 widgets = chat_history .query (AgentMessage )
4851 assert len (widgets ) == 1
@@ -52,7 +55,11 @@ async def test_adds_tool_message_with_json_content(self, app):
5255 async with app .run_test ():
5356 chat_history = app .query_one (ChatHistory )
5457 chat_history .add_message (
55- Message .tool ("read_file" , '{"path": "/tmp/test.txt"}' )
58+ Message (
59+ type = RoleType .TOOL ,
60+ content = '{"path": "/tmp/test.txt"}' ,
61+ metadata = {"tool_name" : "read_file" },
62+ )
5663 )
5764
5865 widgets = chat_history .query (ToolMessage )
@@ -63,7 +70,13 @@ async def test_adds_tool_message_with_json_content(self, app):
6370 async def test_tool_message_handles_invalid_json (self , app ):
6471 async with app .run_test ():
6572 chat_history = app .query_one (ChatHistory )
66- chat_history .add_message (Message .tool ("bash" , "not valid json" ))
73+ chat_history .add_message (
74+ Message (
75+ type = RoleType .TOOL ,
76+ content = "not valid json" ,
77+ metadata = {"tool_name" : "bash" },
78+ )
79+ )
6780
6881 widgets = chat_history .query (ToolMessage )
6982 assert len (widgets ) == 1
@@ -72,8 +85,8 @@ async def test_tool_message_handles_invalid_json(self, app):
7285 async def test_adds_multiple_messages (self , app ):
7386 async with app .run_test ():
7487 chat_history = app .query_one (ChatHistory )
75- chat_history .add_message (Message . user ( "First" ))
76- chat_history .add_message (Message . agent ( "Second" ))
77- chat_history .add_message (Message . user ( "Third" ))
88+ chat_history .add_message (Message ( type = RoleType . USER , content = "First" ))
89+ chat_history .add_message (Message ( type = RoleType . AGENT , content = "Second" ))
90+ chat_history .add_message (Message ( type = RoleType . USER , content = "Third" ))
7891
7992 assert len (chat_history .children ) == 3
0 commit comments