# Implementation Plan: Context Preservation and Warnings

## Phase 1: Context Inheritance on Creation
- [ ] Task: Update `_create_discussion`
    - [ ] In `src/app_controller.py`, modify `_create_discussion`. Before switching, capture the current `context_files` (with their current `auto_aggregate` states).
    - [ ] When initializing the new discussion via `project_manager.default_discussion()`, immediately set its `context_snapshot` to a serialization of the current `context_files`.

## Phase 2: Empty Context Warning Modal
- [ ] Task: Implement Warning Logic in App
    - [ ] In `src/gui_2.py`, add `self.show_empty_context_modal = False` and `self._pending_generation_action = None` (to store whether 'generate' or 'md_only' was requested) to `App.__init__`.
    - [ ] In `App._handle_generate_send` and `App._handle_md_only`, check if `self.ui_selected_context_files` is empty.
    - [ ] If empty, set `self.show_empty_context_modal = True` and store the action type. If not empty, call the respective controller method directly.
- [ ] Task: Render Modal
    - [ ] In `src/gui_2.py`, add a new function `render_empty_context_modal(app: App)`.
    - [ ] The modal should display a warning and have "Proceed Anyway" (which calls the controller based on `_pending_generation_action`) and "Cancel" buttons.
    - [ ] Call this new render function inside the main UI loop, likely near where `render_missing_files_modal` is called.

## Phase 3: Verification
- [ ] Task: Manual Verification
    - [ ] Verify creating a new discussion preserves checked files.
    - [ ] Verify the warning modal appears when generating with no files, and that "Proceed Anyway" works correctly.
- [ ] Task: Conductor - User Manual Verification 'Phase 3: Verification' (Protocol in workflow.md)