diff --git a/src/gui_2.py b/src/gui_2.py index 149b435..66f43ca 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -2179,6 +2179,9 @@ class App: imgui.text(line) imgui.end_child() imgui.separator() + if imgui.button("Open in External Editor"): + self._open_patch_in_external_editor() + imgui.same_line() if imgui.button("Apply Patch"): self._apply_pending_patch() imgui.same_line() @@ -2209,6 +2212,31 @@ class App: except Exception as e: self._patch_error_message = str(e) + def _open_patch_in_external_editor(self) -> None: + try: + from src.external_editor import get_default_launcher, create_temp_modified_file + import os + if not self._pending_patch_files: + self._patch_error_message = "No files to edit" + return + launcher = get_default_launcher() + editor = launcher.config.get_default() + if not editor: + self._patch_error_message = "No external editor configured" + return + original_path = self._pending_patch_files[0] + if not os.path.exists(original_path): + self._patch_error_message = f"Original file not found: {original_path}" + return + temp_path = create_temp_modified_file(self._pending_patch_text) + result = launcher.launch_diff(None, original_path, temp_path) + if result is None: + self._patch_error_message = "Failed to launch external editor" + else: + self._patch_error_message = None + except Exception as e: + self._patch_error_message = str(e) + def request_patch_from_tier4(self, error: str, file_context: str) -> None: try: from src import ai_client