From e87b7a695ea7a0216857a27f538abc2238e37f72 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 12 May 2026 18:16:23 -0400 Subject: [PATCH] script modal method --- src/gui_2.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/gui_2.py b/src/gui_2.py index dc4084a..83b7c6f 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -1038,7 +1038,10 @@ class App: self.perf_monitor.end_frame() # Modals / Popups - + self._render_approve_script_modal() + + def _render_approve_script_modal(self) -> None: + """Renders the modal dialog for approving AI-generated PowerShell scripts.""" with self._pending_dialog_lock: dlg = self._pending_dialog if dlg: @@ -1051,6 +1054,37 @@ class App: if imgui.begin_popup_modal("Approve PowerShell Command", None, imgui.WindowFlags_.always_auto_resize)[0]: if not dlg: imgui.close_current_popup() + else: + imgui.text("The AI wants to run the following PowerShell script:") + imgui.text_colored(vec4(200, 200, 100), f"base_dir: {dlg._base_dir}") + imgui.separator() + # Checkbox to toggle full preview inside modal + _, self.show_text_viewer = imgui.checkbox("Show Full Preview", self.show_text_viewer) + if self.show_text_viewer: + imgui.begin_child("preview_child", imgui.ImVec2(600, 300), True) + imgui.text_unformatted(dlg._script) + imgui.end_child() + else: + ch, dlg._script = imgui.input_text_multiline("##confirm_script", dlg._script, imgui.ImVec2(-1, 200)) + imgui.separator() + if imgui.button("Approve & Run", imgui.ImVec2(120, 0)): + with dlg._condition: + dlg._approved = True + dlg._done = True + dlg._condition.notify_all() + with self._pending_dialog_lock: + self._pending_dialog = None + imgui.close_current_popup() + imgui.same_line() + if imgui.button("Reject", imgui.ImVec2(120, 0)): + with dlg._condition: + dlg._approved = False + dlg._done = True + dlg._condition.notify_all() + with self._pending_dialog_lock: + self._pending_dialog = None + imgui.close_current_popup() + imgui.end_popup() def _render_project_settings_hub(self) -> None: with imscope.tab_bar('context_hub_tabs'):