feat(gui): Improve External Editor panel with combo selector
- Add dropdown combo to select default editor - Add _set_external_editor_default method to save selection to config - Clean up layout and improve visual hierarchy - Add better color coding for configured vs default editors
This commit is contained in:
+63
-29
@@ -2043,6 +2043,16 @@ class App:
|
||||
self.init_state()
|
||||
self.ai_status = 'paths applied and session reset'
|
||||
|
||||
def _set_external_editor_default(self, editor_name: str) -> None:
|
||||
from src import models
|
||||
if "tools" not in self.config:
|
||||
self.config["tools"] = {}
|
||||
if "default_editor" not in self.config["tools"]:
|
||||
self.config["tools"]["default_editor"] = {}
|
||||
self.config["tools"]["default_editor"]["default_editor"] = editor_name
|
||||
models.save_config(self.config)
|
||||
self.ai_status = f"Default editor set to: {editor_name}"
|
||||
|
||||
def _render_paths_panel(self) -> None:
|
||||
if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_paths_panel")
|
||||
path_info = paths.get_full_path_info()
|
||||
@@ -4841,37 +4851,61 @@ def hello():
|
||||
self.controller.event_queue.put('click', 'btn_rebuild_rag_index')
|
||||
|
||||
def _render_external_editor_panel(self) -> None:
|
||||
from src.external_editor import get_default_launcher
|
||||
launcher = get_default_launcher()
|
||||
editors = launcher.config.editors
|
||||
default_name = launcher.config.default_editor
|
||||
from src.external_editor import get_default_launcher, create_temp_modified_file
|
||||
import os
|
||||
imgui.text_colored(vec4(0.7, 0.7, 0.7, 1), "External Editor for Diff Viewing")
|
||||
imgui.separator()
|
||||
if not editors:
|
||||
imgui.text_colored(vec4(1, 0.5, 0, 1), " No editors configured")
|
||||
imgui.text("")
|
||||
imgui.text("Add editors in config.toml:")
|
||||
imgui.text_colored(vec4(0.5, 0.8, 1, 1), ' [tools.text_editors.vscode]')
|
||||
imgui.text(' path = "C:\\\\path\\\\to\\\\code.exe"')
|
||||
imgui.text(' diff_args = ["--diff"]')
|
||||
imgui.text("")
|
||||
imgui.text_colored(vec4(0.5, 0.8, 1, 1), ' [tools.text_editors.notepadpp]')
|
||||
imgui.text(' path = "C:\\\\Program Files\\\\Notepad++\\\\notepad++.exe"')
|
||||
imgui.text(' diff_args = ["-multiInst", "-nosession"]')
|
||||
imgui.text("")
|
||||
imgui.text("Then set default in [tools.default_editor]")
|
||||
else:
|
||||
imgui.text("Configured Editors:")
|
||||
for name, editor in editors.items():
|
||||
is_default = name == default_name
|
||||
marker = " (default)" if is_default else ""
|
||||
imgui.text_colored(vec4(0.3, 0.9, 0.3, 1), f" {name}{marker}")
|
||||
imgui.text(f" path: {editor.path}")
|
||||
if editor.diff_args:
|
||||
imgui.text(f" diff: {editor.diff_args}")
|
||||
imgui.text("")
|
||||
imgui.text_colored(vec4(0.7, 0.7, 0.7, 1), "Config: config.toml [tools.text_editors]")
|
||||
imgui.text_colored(vec4(0.7, 0.7, 0.7, 1), "Override: manual_slop.toml default_editor")
|
||||
try:
|
||||
launcher = get_default_launcher()
|
||||
editors = launcher.config.editors
|
||||
default_name = launcher.config.default_editor
|
||||
if not editors:
|
||||
imgui.text_colored(vec4(1, 0.5, 0, 1), " No editors configured")
|
||||
imgui.text("")
|
||||
imgui.text_colored(vec4(0.6, 0.6, 0.6, 1), "Add editors in config.toml:")
|
||||
imgui.text_colored(vec4(0.5, 0.8, 1, 1), ' [tools.text_editors.vscode]')
|
||||
imgui.text(' path = "C:\\\\path\\\\to\\\\code.exe"')
|
||||
imgui.text(' diff_args = ["--diff"]')
|
||||
imgui.text("")
|
||||
imgui.text_colored(vec4(0.5, 0.8, 1, 1), ' [tools.text_editors.notepadpp]')
|
||||
imgui.text(' path = "C:\\\\path\\\\to\\\\notepad++.exe"')
|
||||
imgui.text(' diff_args = ["-multiInst", "-nosession"]')
|
||||
imgui.text("")
|
||||
imgui.text_colored(vec4(0.6, 0.6, 0.6, 1), "Then set default in [tools.default_editor]")
|
||||
else:
|
||||
imgui.text("Default Editor:")
|
||||
editor_names = sorted(list(editors.keys()))
|
||||
if default_name and default_name in editor_names:
|
||||
current_idx = editor_names.index(default_name)
|
||||
else:
|
||||
current_idx = 0
|
||||
changed, new_idx = imgui.combo("##editor_combo", current_idx, editor_names)
|
||||
if changed:
|
||||
self._set_external_editor_default(editor_names[new_idx])
|
||||
launcher = get_default_launcher()
|
||||
editors = launcher.config.editors
|
||||
default_name = launcher.config.default_editor
|
||||
imgui.text("")
|
||||
imgui.text("Configured Editors:")
|
||||
imgui.separator()
|
||||
for name in editor_names:
|
||||
editor = editors.get(name)
|
||||
if not editor:
|
||||
continue
|
||||
is_default = name == default_name
|
||||
marker = " (default)" if is_default else ""
|
||||
if is_default:
|
||||
imgui.text_colored(vec4(0.3, 0.9, 0.3, 1), f" {name}{marker}")
|
||||
else:
|
||||
imgui.text(f" {name}{marker}")
|
||||
imgui.text(f" {editor.path}")
|
||||
if editor.diff_args:
|
||||
imgui.text_colored(vec4(0.5, 0.5, 0.5, 1), f" diff: {editor.diff_args}")
|
||||
imgui.text("")
|
||||
imgui.text_colored(vec4(0.6, 0.6, 0.6, 1), "Config: config.toml [tools.text_editors]")
|
||||
imgui.text_colored(vec4(0.6, 0.6, 0.6, 1), "Override: manual_slop.toml default_editor")
|
||||
except Exception as e:
|
||||
imgui.text_colored(vec4(1, 0.3, 0.3, 1), f"Error: {str(e)}")
|
||||
|
||||
def _render_agent_tools_panel(self) -> None:
|
||||
if imgui.collapsing_header("Active Tool Presets & Biases", imgui.TreeNodeFlags_.default_open):
|
||||
|
||||
Reference in New Issue
Block a user