feat(gui2): Complete EventEmitter integration
This commit is contained in:
12
gui_2.py
12
gui_2.py
@@ -239,6 +239,7 @@ class App:
|
||||
ai_client.comms_log_callback = self._on_comms_entry
|
||||
ai_client.tool_log_callback = self._on_tool_log
|
||||
mcp_client.perf_monitor_callback = self.perf_monitor.get_metrics
|
||||
self.perf_monitor.alert_callback = self._on_performance_alert
|
||||
|
||||
# AI client event subscriptions
|
||||
ai_client.events.on("request_start", self._on_api_event)
|
||||
@@ -404,6 +405,17 @@ class App:
|
||||
with self._pending_gui_tasks_lock:
|
||||
self._pending_gui_tasks.append({"action": "refresh_api_metrics", "payload": payload})
|
||||
|
||||
def _on_performance_alert(self, message: str):
|
||||
"""Called by PerformanceMonitor when a threshold is exceeded."""
|
||||
alert_text = f"[PERFORMANCE ALERT] {message}. Please consider optimizing recent changes or reducing load."
|
||||
# Inject into history as a 'System' message
|
||||
with self._pending_history_adds_lock:
|
||||
self._pending_history_adds.append({
|
||||
"role": "System",
|
||||
"content": alert_text,
|
||||
"ts": project_manager.now_ts()
|
||||
})
|
||||
|
||||
def _process_pending_gui_tasks(self):
|
||||
if not self._pending_gui_tasks:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user