# Implementation Plan: Saved System Prompt Presets

## Phase 1: Foundation & Data Model
- [x] Task: Define the `Preset` data model and storage logic.
    - [x] Create `src/models.py` (if not existing) or update it with a `Preset` dataclass/Pydantic model.
    - [x] Implement `PresetManager` in a new file `src/presets.py` to handle loading/saving to `presets.toml` and `project_presets.toml`.
    - [x] Implement the inheritance logic where project presets override global ones.
- [x] Task: Write unit tests for `PresetManager`.
    - [x] Test loading global presets.
    - [x] Test loading project presets.
    - [x] Test the override logic (same name).
    - [x] Test saving/updating presets.
- [x] Task: Conductor - User Manual Verification 'Phase 1: Foundation & Data Model' (Protocol in workflow.md)

## Phase 2: UI: Settings Integration
- [x] Task: Add Preset Dropdown to Global AI Settings.
    - [x] Modify `gui_2.py` to include a dropdown in the "AI Settings" panel.
    - [x] Populated the dropdown with available global presets.
- [x] Task: Add Preset Dropdown to Project Settings.
    - [x] Modify `gui_2.py` to include a dropdown in the "Project Settings" panel.
    - [x] Populated the dropdown with available project-specific presets (including overridden globals).
- [x] Task: Implement "Auto-Load" logic.
    - [x] When a preset is selected, update the active system prompt and model settings in `gui_2.py`.
- [x] Task: Write integration tests for settings integration using `live_gui`.
    - [x] Verify global dropdown shows global presets.
    - [x] Verify project dropdown shows project + global presets.
    - [x] Verify selecting a preset updates the UI fields (prompt, temperature).
- [x] Task: Conductor - User Manual Verification 'Phase 2: UI: Settings Integration' (Protocol in workflow.md)

## Phase 3: UI: Preset Manager Modal
- [x] Task: Create the `PresetManagerModal` in `gui_2.py` (or a separate module).
    - [x] Implement a list view of all presets (global and project).
    - [x] Implement "Add", "Edit", and "Delete" functionality.
    - [x] Ensure validation for unique names.
- [x] Task: Add a button to open the manager modal from the settings panels.
- [x] Task: Write integration tests for the Preset Manager using `live_gui`.
    - [x] Verify creating a new preset adds it to the list and dropdown.
    - [x] Verify editing an existing preset updates it correctly.
    - [x] Verify deleting a preset removes it from the list and dropdown.
- [x] Task: Conductor - User Manual Verification 'Phase 3: UI: Preset Manager Modal' (Protocol in workflow.md)

## Phase 4: Final Integration & Polish
- [x] Task: Ensure robust error handling for missing or malformed `.toml` files.
- [x] Task: Bugfix: Correct `PresetManager` initialization to use project parent directory.
- [x] Task: Hardening: Wrap modal rendering in `try...finally` to prevent ImGui state corruption.
- [x] Task: Hardening: Ensure `PresetManager._save_file` validates that parent is a directory.
- [x] Task: Feature: Implement "Pop Out Task DAG" option in MMA Dashboard.
- [x] Task: Final UI polish (spacing, icons, tooltips).
- [x] Task: Run full suite of relevant tests.
- [x] Task: Conductor - User Manual Verification 'Phase 4: Final Integration & Polish' (Protocol in workflow.md)
