# Implementation Plan: Hook API UI State Verification (hook_api_ui_state_verification_20260302)

## Phase 1: API Endpoint Implementation
- [ ] Task: Initialize MMA Environment `activate_skill mma-orchestrator`
- [ ] Task: Implement `/api/gui/state` GET Endpoint
    - [ ] WHERE: `gui_2.py` (or `app_controller.py` if decoupled), inside `create_api()`.
    - [ ] WHAT: Add a FastAPI route that serializes allowed UI state variables into JSON.
    - [ ] HOW: Define a set of safe keys (e.g., `_gettable_fields`) and extract them from the App instance.
    - [ ] SAFETY: Use thread-safe reads or deepcopies if accessing complex dictionaries.
- [ ] Task: Update `ApiHookClient`
    - [ ] WHERE: `api_hook_client.py`
    - [ ] WHAT: Add a `get_gui_state(self)` method that hits the new endpoint.
    - [ ] HOW: Standard `requests.get`.
    - [ ] SAFETY: Include error handling/timeouts.
- [ ] Task: Conductor - User Manual Verification 'Phase 1: API Endpoint' (Protocol in workflow.md)

## Phase 2: State Wiring & Integration Tests
- [ ] Task: Wire Critical UI States
    - [ ] WHERE: `gui_2.py`
    - [ ] WHAT: Ensure fields like `ui_focus_agent`, `active_discussion`, `_track_discussion_active` are included in the exposed state.
    - [ ] HOW: Update the mapping definition.
    - [ ] SAFETY: None.
- [ ] Task: Write `live_gui` Integration Tests
    - [ ] WHERE: `tests/test_live_gui_integration.py`
    - [ ] WHAT: Add a test that changes the provider/model or focus agent via actions, then asserts `client.get_gui_state()` reflects the change.
    - [ ] HOW: Use `pytest` and `live_gui` fixture.
    - [ ] SAFETY: Ensure robust wait conditions for GUI updates.
- [ ] Task: Conductor - User Manual Verification 'Phase 2: State Wiring & Tests' (Protocol in workflow.md)

## Phase 3: Final Validation
- [ ] Task: Full Suite Validation & Warning Cleanup
    - [ ] WHERE: Project root
    - [ ] WHAT: `uv run pytest`
    - [ ] HOW: Ensure 100% pass rate.
    - [ ] SAFETY: Ensure the hook server gracefully stops.
- [ ] Task: Conductor - User Manual Verification 'Phase 3: Final Validation' (Protocol in workflow.md)