# Implementation Plan: Undo/Redo History Support

This plan implements a robust undo/redo system focusing on text inputs, control states, and discussion structure.

## Phase 1: History Core Logic & State Management
- [ ] Task: Design and implement a generic `HistoryManager` class to handle undo/redo stacks and state snapshots.
- [ ] Task: Write failing tests for the `HistoryManager` core logic, including capacity limits and basic undo/redo functionality.
- [ ] Task: Implement `HistoryManager` to pass tests, ensuring it correctly manages a fixed stack of 50-100 actions.
- [ ] Task: Conductor - User Manual Verification 'Phase 1: History Core Logic & State Management' (Protocol in workflow.md)

## Phase 2: Text Input & Control Undo/Redo
- [ ] Task: Integrate `HistoryManager` with `src/gui_2.py` for system prompt and discussion entry text fields.
- [ ] Task: Implement state snapshots for AI model parameter sliders (Temperature, Top-P) and checkboxes.
- [ ] Task: Write simulation tests using `live_gui` to verify undo/redo for text edits and control changes.
- [ ] Task: Conductor - User Manual Verification 'Phase 2: Text Input & Control Undo/Redo' (Protocol in workflow.md)

## Phase 3: Discussion & Context Structure Mutation
- [ ] Task: Implement undo/redo for adding, deleting, and reordering discussion entries in `src/app_controller.py`.
- [ ] Task: Extend the history system to track context file and screenshot additions/removals in `src/aggregate.py`.
- [ ] Task: Write failing tests for reverting and redoing complex discussion tree mutations.
- [ ] Task: Implement mutation tracking and restoration logic to pass tests.
- [ ] Task: Conductor - User Manual Verification 'Phase 3: Discussion & Context Structure Mutation' (Protocol in workflow.md)

## Phase 4: UI Features - Hotkeys & History List
- [ ] Task: Implement global hotkey handling for `Ctrl+Z` and `Ctrl+Y` / `Ctrl+Shift+Z` in the main GUI loop.
- [ ] Task: Create a dedicated 'History List' panel in `src/gui_2.py` showing a scrollable list of recent actions.
- [ ] Task: Implement functionality to jump to a specific historical state via the History List.
- [ ] Task: Write final integration tests for the full undo/redo cycle across all supported areas.
- [ ] Task: Conductor - User Manual Verification 'Phase 4: UI Features - Hotkeys & History List' (Protocol in workflow.md)
