Skip to content

Commit d065c0b

Browse files
committed
refactor: update post_app_event naming
1 parent 3a04706 commit d065c0b

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Read `docs/architecture.md` for an architectural overview of the project. Refactors should always start here first.
66
- The project uses `uv`, `ruff` and `ty`
7+
- Typechecking is done via `uv run ty check`
78
- Run commands should be prefixed with `uv`: `uv run ...`
89
- Use `asyncio` features, if such is needed
910
- Prefer early returns

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ test:
1919
uv run pytest
2020

2121
type-check:
22-
uv run ty check src
22+
uv run ty check

src/agent_chat_cli/core/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def post_user_message(self, message: str) -> None:
2323
async def post_system_message(self, message: str) -> None:
2424
await self.app.renderer.add_message(RoleType.SYSTEM, message)
2525

26-
async def handle_app_event(self, event) -> None:
26+
async def post_app_event(self, event) -> None:
2727
await self.app.renderer.handle_app_event(event)
2828

2929
async def interrupt(self) -> None:

src/agent_chat_cli/core/agent_loop.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def start(self) -> None:
9393

9494
await self._handle_message(message)
9595

96-
await self.app.actions.handle_app_event(
96+
await self.app.actions.post_app_event(
9797
AppEvent(type=AppEventType.RESULT, data=None)
9898
)
9999

@@ -136,7 +136,7 @@ async def _handle_message(self, message: Message) -> None:
136136
text_chunk = delta.get("text", "")
137137

138138
if text_chunk:
139-
await self.app.actions.handle_app_event(
139+
await self.app.actions.post_app_event(
140140
AppEvent(
141141
type=AppEventType.STREAM_EVENT,
142142
data={"text": text_chunk},
@@ -164,7 +164,7 @@ async def _handle_message(self, message: Message) -> None:
164164
)
165165

166166
# Finally, post the agent assistant response
167-
await self.app.actions.handle_app_event(
167+
await self.app.actions.post_app_event(
168168
AppEvent(
169169
type=AppEventType.ASSISTANT,
170170
data={"content": content},
@@ -181,7 +181,7 @@ async def _can_use_tool(
181181

182182
# Handle permission request queue sequentially
183183
async with self.permission_lock:
184-
await self.app.actions.handle_app_event(
184+
await self.app.actions.post_app_event(
185185
AppEvent(
186186
type=AppEventType.TOOL_PERMISSION_REQUEST,
187187
data={

tests/core/test_agent_loop.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def mock_app():
2121
app = MagicMock()
2222
app.ui_state = MagicMock()
2323
app.actions = MagicMock()
24-
app.actions.handle_app_event = AsyncMock()
24+
app.actions.post_app_event = AsyncMock()
2525
app.actions.post_system_message = AsyncMock()
2626
return app
2727

@@ -156,8 +156,8 @@ async def test_handles_text_delta_stream_event(self, mock_app, mock_config):
156156

157157
await agent_loop._handle_message(message)
158158

159-
mock_app.actions.handle_app_event.assert_called_once()
160-
call_arg = mock_app.actions.handle_app_event.call_args[0][0]
159+
mock_app.actions.post_app_event.assert_called_once()
160+
call_arg = mock_app.actions.post_app_event.call_args[0][0]
161161
assert call_arg.type == AppEventType.STREAM_EVENT
162162
assert call_arg.data == {"text": "Hello world"}
163163

@@ -178,7 +178,7 @@ async def test_ignores_empty_text_delta(self, mock_app, mock_config):
178178

179179
await agent_loop._handle_message(message)
180180

181-
mock_app.actions.handle_app_event.assert_not_called()
181+
mock_app.actions.post_app_event.assert_not_called()
182182

183183

184184
class TestHandleMessageAssistantMessage:
@@ -193,8 +193,8 @@ async def test_handles_text_block(self, mock_app, mock_config):
193193

194194
await agent_loop._handle_message(message)
195195

196-
mock_app.actions.handle_app_event.assert_called_once()
197-
call_arg = mock_app.actions.handle_app_event.call_args[0][0]
196+
mock_app.actions.post_app_event.assert_called_once()
197+
call_arg = mock_app.actions.post_app_event.call_args[0][0]
198198
assert call_arg.type == AppEventType.ASSISTANT
199199
assert call_arg.data["content"][0]["type"] == ContentType.TEXT.value
200200
assert call_arg.data["content"][0]["text"] == "Assistant response"
@@ -212,8 +212,8 @@ async def test_handles_tool_use_block(self, mock_app, mock_config):
212212

213213
await agent_loop._handle_message(message)
214214

215-
mock_app.actions.handle_app_event.assert_called_once()
216-
call_arg = mock_app.actions.handle_app_event.call_args[0][0]
215+
mock_app.actions.post_app_event.assert_called_once()
216+
call_arg = mock_app.actions.post_app_event.call_args[0][0]
217217
assert call_arg.type == AppEventType.ASSISTANT
218218
assert call_arg.data["content"][0]["type"] == ContentType.TOOL_USE.value
219219
assert call_arg.data["content"][0]["name"] == "read_file"
@@ -287,7 +287,7 @@ async def test_posts_permission_request_message(self, mock_app, mock_config):
287287
_context=MagicMock(),
288288
)
289289

290-
mock_app.actions.handle_app_event.assert_called_once()
291-
call_arg = mock_app.actions.handle_app_event.call_args[0][0]
290+
mock_app.actions.post_app_event.assert_called_once()
291+
call_arg = mock_app.actions.post_app_event.call_args[0][0]
292292
assert call_arg.type == AppEventType.TOOL_PERMISSION_REQUEST
293293
assert call_arg.data["tool_name"] == "write_file"

0 commit comments

Comments
 (0)