feat(gui): Add 'Open in External Editor' button to patch modal

- Added button to launch external editor for reviewing agent proposed changes
- Added _open_patch_in_external_editor method to handle the launch logic
- Integrated with ExternalEditorLauncher and create_temp_modified_file
This commit is contained in:
2026-05-07 19:10:13 -04:00
parent 414d2ab561
commit c711d26eac
+28
View File
@@ -2179,6 +2179,9 @@ class App:
imgui.text(line) imgui.text(line)
imgui.end_child() imgui.end_child()
imgui.separator() imgui.separator()
if imgui.button("Open in External Editor"):
self._open_patch_in_external_editor()
imgui.same_line()
if imgui.button("Apply Patch"): if imgui.button("Apply Patch"):
self._apply_pending_patch() self._apply_pending_patch()
imgui.same_line() imgui.same_line()
@@ -2209,6 +2212,31 @@ class App:
except Exception as e: except Exception as e:
self._patch_error_message = str(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: def request_patch_from_tier4(self, error: str, file_context: str) -> None:
try: try:
from src import ai_client from src import ai_client