fix(controller): Add stop_services() and dialog imports for GUI decoupling

- Add AppController.stop_services() to clean up AI client and event loop
- Add ConfirmDialog, MMAApprovalDialog, MMASpawnApprovalDialog imports to gui_2.py
- Fix test mocks for MMA dashboard and approval indicators
- Add retry logic to conftest.py for Windows file lock cleanup
This commit is contained in:
2026-03-04 20:16:16 -05:00
parent bc7408fbe7
commit 2d92674aa0
5 changed files with 92 additions and 59 deletions

View File

@@ -418,6 +418,15 @@ class AppController:
self._loop_thread = threading.Thread(target=self._run_event_loop, daemon=True)
self._loop_thread.start()
def stop_services(self) -> None:
"""Stops background threads and cleans up resources."""
import ai_client
ai_client.cleanup()
if self._loop and self._loop.is_running():
self._loop.call_soon_threadsafe(self._loop.stop)
if self._loop_thread and self._loop_thread.is_alive():
self._loop_thread.join(timeout=2.0)
def _init_ai_and_hooks(self, app: Any = None) -> None:
import api_hooks
ai_client.set_provider(self._current_provider, self._current_model)