feat(api): Add GUI state manipulation hooks with thread-safe queueing

This commit is contained in:
2026-02-23 12:21:18 -05:00
parent 03db4190d7
commit 5f9bc193cb
3 changed files with 48 additions and 0 deletions

View File

@@ -68,6 +68,16 @@ def test_ipc_server_starts_and_responds():
with urllib.request.urlopen(req) as response:
assert response.status == 200
assert app_mock.disc_entries == [{"role": "User", "content": "hi"}]
# Test GUI queue hook
req = urllib.request.Request("http://127.0.0.1:8999/api/gui", method="POST", data=json.dumps({"action": "set_value", "item": "test_item", "value": "test_value"}).encode("utf-8"), headers={'Content-Type': 'application/json'})
with urllib.request.urlopen(req) as response:
assert response.status == 200
# Instead of checking DPG (since we aren't running the real main loop in tests),
# check if it got queued in app_mock
assert hasattr(app_mock, '_pending_gui_tasks')
assert len(app_mock._pending_gui_tasks) == 1
assert app_mock._pending_gui_tasks[0] == {"action": "set_value", "item": "test_item", "value": "test_value"}
finally:
server.stop()