# Plan: Fix Test Suite Regressions

## Objective
Restore the full test suite to a passing state after the `gui_2.py` refactoring (Phase 2 & Phase 3 of Context Composition Redesign).

## Key Files & Context
- `src/gui_2.py`: The main GUI entry point where methods were moved to module level.
- `src/hot_reloader.py`: Handles module registration, currently causing collisions in tests.
- `tests/*.py`: Multiple test files referencing deleted/moved methods.

## Implementation Steps

### Phase 1: Fix HotReloader Collisions
- [ ] Modify `src/gui_2.py` to check if `src.gui_2` is already registered before calling `HotReloader.register`. This allows multiple `App()` instances (common in tests) without triggering `ValueError`.
- [ ] Revert `src/hot_reloader.py` to its original state (raising `ValueError` on duplicate registration) to satisfy existing tests for that logic.

### Phase 2: Fix Method Migration Regressions (Batch)
- [ ] Identify all test files calling `app._render_*` or checking `hasattr(App, '_render_*')`.
- [ ] Use Tier 3 workers to surgically update these tests:
    - Change `app._render_XYZ()` to `gui_2.render_XYZ(app)`.
    - Change `hasattr(App, '_render_XYZ')` to `hasattr(gui_2, 'render_XYZ')` (and import `gui_2`).
    - Note: Some internal helpers might still be prefixed with `_` at the module level.
- [ ] Target the following specific files:
    - `tests/test_ast_inspector_extended.py`
    - `tests/test_discussion_takes_gui.py`
    - `tests/test_gui_discussion_tabs.py`
    - `tests/test_gui_fast_render.py`
    - `tests/test_gui_phase4.py`
    - `tests/test_gui_progress.py`
    - `tests/test_gui_symbol_navigation.py`
    - `tests/test_gui_synthesis.py`
    - `tests/test_log_management_ui.py`
    - `tests/test_mma_approval_indicators.py`
    - `tests/test_mma_dashboard_streams.py`
    - `tests/test_project_settings_rename.py`
    - `tests/test_rag_gui_presence.py`
    - `tests/test_selectable_ui.py`
    - `tests/test_session_hub_merge.py`
    - `tests/test_shader_live_editor.py`
    - `tests/test_takes_panel.py`
    - `tests/test_thinking_gui.py`
    - `tests/test_token_viz.py`
    - `tests/test_ui_summary_only_removal.py`

### Phase 3: Address Specific Logic Failures
- [ ] `tests/test_py_struct_tools.py`: Investigate and fix why definitions are not found.
- [ ] `tests/test_rag_phase4_final_verify.py`: Investigate why RAG context is missing in history.
- [ ] `tests/test_rag_phase4_stress.py`: Investigate timing issues (incremental indexing duration).
- [ ] `tests/test_gui_kill_button.py`: Investigate missing "Actions" column in ticket queue.

## Verification & Testing
- [ ] Run the full test suite using the batch script: `uv run python scripts/run_tests_batched.py`.
- [ ] Ensure all 243 test files pass.
