# Implementation Plan: External Text Editor Integration for Approvals

## Phase 1: Configuration & Data Modeling
- [x] Task: Define the schema for external editor configuration.
    - [x] Update `src/models.py` (or equivalent configuration parsing logic) to include a `text_editors` dictionary and `default_editor` string.
- [x] Task: Integrate configuration parsing.
    - [x] Update `config.toml` loading to support a `[tools.text_editors]` section mapping names to paths/commands.
    - [x] Update `manual_slop.toml` loading to support a project-level `default_editor` override.
- [x] Task: Conductor - User Manual Verification 'Phase 1: Configuration & Data Modeling' (Protocol in workflow.md)

## Phase 2: Editor Launch Logic
- [x] Task: Implement the `ExternalEditorLauncher` utility.
    - [x] Create a new module/class in `src/external_editor.py`.
    - [x] Implement a method to build the command-line arguments for diffing (e.g., handling `--diff` for VSCode or equivalent for 10xNotepad).
    - [x] Implement the `launch_diff(editor_name, original_file_path, modified_file_path)` method using `subprocess.Popen`.
- [x] Task: Write unit tests for `ExternalEditorLauncher` argument building and configuration resolution.
- [x] Task: Conductor - User Manual Verification 'Phase 2: Editor Launch Logic' (Protocol in workflow.md)

## Phase 3: UI Integration (Approval Popup)
- [x] Task: Add the "Open in External Editor" button to the UI.
    - [x] Modify `src/patch_modal.py` (or the equivalent file handling the `ConfirmDialog` UI).
    - [x] Add the button next to "Approve" and "Reject" when the action involves a file modification.
- [x] Task: Connect the UI button to the launch logic.
    - [x] When the button is clicked, write the agent's proposed changes to a temporary file (if not already done).
    - [x] Call `launch_diff` with the selected editor, the original target file, and the temporary file.
- [x] Task: Ensure the approval flow correctly reads the (potentially user-modified) temporary file when "Approve" is finally clicked, rather than the original agent output.
- [x] Task: Conductor - User Manual Verification 'Phase 3: UI Integration' (Protocol in workflow.md)

## Phase 4: Final Polish & Verification
- [x] Task: Add UI configuration for the default editor in the "Project Settings" and "AI Settings" panels.
    - [x] Show configured editors list
    - [x] Show configuration file locations
- [x] Task: Run end-to-end simulation tests to verify the flow.
    - [x] Agent proposes a change -> Modal opens -> Click "Open in Editor" -> (Simulate external edit) -> Click Approve -> Verify final file state.
- [x] Task: Conductor - User Manual Verification 'Phase 4: Final Polish & Verification' (Protocol in workflow.md)
