diff --git a/api_hook_client.py b/api_hook_client.py index 6224f03..f99aa81 100644 --- a/api_hook_client.py +++ b/api_hook_client.py @@ -114,3 +114,9 @@ class ApiHookClient: "action": "click", "item": item }) + + def get_indicator_state(self, tag): + """Checks if an indicator is shown.""" + # This requires a new API endpoint or using an existing one that returns GUI state. + # Let's check if /api/gui GET exists. + return self._make_request('GET', f'/api/gui/state/{tag}') diff --git a/api_hooks.py b/api_hooks.py index 19a24ad..6ab7671 100644 --- a/api_hooks.py +++ b/api_hooks.py @@ -41,6 +41,16 @@ class HookHandler(BaseHTTPRequestHandler): if hasattr(app, 'perf_monitor'): metrics = app.perf_monitor.get_metrics() self.wfile.write(json.dumps({'performance': metrics}).encode('utf-8')) + elif self.path.startswith('/api/gui/state/'): + tag = self.path.replace('/api/gui/state/', '') + import dearpygui.dearpygui as dpg + shown = False + if dpg.does_item_exist(tag): + shown = dpg.is_item_shown(tag) + self.send_response(200) + self.send_header('Content-Type', 'application/json') + self.end_headers() + self.wfile.write(json.dumps({'tag': tag, 'shown': shown}).encode('utf-8')) else: self.send_response(404) self.end_headers() diff --git a/tests/test_api_hook_extensions.py b/tests/test_api_hook_extensions.py index d4b2a43..c0a8620 100644 --- a/tests/test_api_hook_extensions.py +++ b/tests/test_api_hook_extensions.py @@ -26,6 +26,13 @@ def test_select_list_item_integration(live_gui): response = client.select_list_item("disc_listbox", "Default") assert response == {'status': 'queued'} +def test_get_indicator_state_integration(live_gui): + client = ApiHookClient() + # thinking_indicator is usually hidden unless AI is running + response = client.get_indicator_state("thinking_indicator") + assert 'shown' in response + assert response['tag'] == "thinking_indicator" + def test_app_processes_new_actions(): import gui from unittest.mock import MagicMock, patch