feat(gui): Implement event-driven API metrics updates and decouple from render loop

This commit is contained in:
2026-02-23 16:38:23 -05:00
parent 0c27aa6c6b
commit 2dd6145bd8
4 changed files with 138 additions and 57 deletions

View File

@@ -41,7 +41,7 @@ def app_instance():
def test_telemetry_panel_updates_correctly(app_instance):
"""
Tests that the _update_telemetry_panel method correctly updates
Tests that the _update_performance_diagnostics method correctly updates
DPG widgets based on the stats from ai_client.
"""
# 1. Set the provider to anthropic
@@ -64,7 +64,7 @@ def test_telemetry_panel_updates_correctly(app_instance):
patch('dearpygui.dearpygui.does_item_exist', return_value=True) as mock_does_item_exist:
# 4. Call the method under test
app_instance._update_telemetry_panel()
app_instance._refresh_api_metrics()
# 5. Assert the results
mock_get_stats.assert_called_once()
@@ -78,7 +78,7 @@ def test_telemetry_panel_updates_correctly(app_instance):
def test_cache_data_display_updates_correctly(app_instance):
"""
Tests that the _update_telemetry_panel method correctly updates the
Tests that the _update_performance_diagnostics method correctly updates the
GUI with Gemini cache statistics when the provider is set to Gemini.
"""
# 1. Set the provider to Gemini
@@ -104,7 +104,7 @@ def test_cache_data_display_updates_correctly(app_instance):
with patch('ai_client.get_history_bleed_stats', return_value={}):
# 4. Call the method under test
app_instance._update_telemetry_panel()
app_instance._refresh_api_metrics()
# 5. Assert the results
mock_get_cache_stats.assert_called_once()