Agent scripting ux improvements
This commit is contained in:
80
gui.py
80
gui.py
@@ -1,4 +1,4 @@
|
||||
# gui.py
|
||||
# gui.py
|
||||
import dearpygui.dearpygui as dpg
|
||||
import tomllib
|
||||
import tomli_w
|
||||
@@ -391,6 +391,11 @@ class App:
|
||||
self._is_blinking = False
|
||||
self._blink_start_time = 0.0
|
||||
|
||||
# Script Blink State
|
||||
self._trigger_script_blink = False
|
||||
self._is_script_blinking = False
|
||||
self._script_blink_start_time = 0.0
|
||||
|
||||
session_logger.open_session()
|
||||
ai_client.set_provider(self.current_provider, self.current_model)
|
||||
ai_client.confirm_and_run_callback = self._confirm_and_run
|
||||
@@ -683,6 +688,12 @@ class App:
|
||||
def _append_tool_log(self, script: str, result: str):
|
||||
self._tool_log.append((script, result))
|
||||
self._rebuild_tool_log()
|
||||
|
||||
if dpg.does_item_exist("last_script_text"):
|
||||
dpg.set_value("last_script_text", script)
|
||||
if dpg.does_item_exist("last_script_output"):
|
||||
dpg.set_value("last_script_output", result)
|
||||
self._trigger_script_blink = True
|
||||
|
||||
def _rebuild_tool_log(self):
|
||||
if not dpg.does_item_exist("tool_log_scroll"):
|
||||
@@ -1722,6 +1733,34 @@ class App:
|
||||
|
||||
self._build_theme_window()
|
||||
|
||||
# ---- Script Output Popup ----
|
||||
with dpg.window(
|
||||
label="Last Script Output",
|
||||
tag="win_script_output",
|
||||
show=False,
|
||||
width=700,
|
||||
height=500,
|
||||
pos=(100, 100),
|
||||
no_collapse=True
|
||||
):
|
||||
dpg.add_text("Script:")
|
||||
dpg.add_input_text(
|
||||
tag="last_script_text",
|
||||
multiline=True,
|
||||
readonly=True,
|
||||
width=-1,
|
||||
height=150,
|
||||
)
|
||||
dpg.add_separator()
|
||||
dpg.add_text("Output:")
|
||||
dpg.add_input_text(
|
||||
tag="last_script_output",
|
||||
multiline=True,
|
||||
readonly=True,
|
||||
width=-1,
|
||||
height=-1,
|
||||
)
|
||||
|
||||
def run(self):
|
||||
dpg.create_context()
|
||||
dpg.configure_app(docking=True, docking_space=True, init_file="dpg_layout.ini")
|
||||
@@ -1763,6 +1802,42 @@ class App:
|
||||
dpg.set_y_scroll("disc_scroll", 99999)
|
||||
|
||||
# Handle retro arcade blinking effect
|
||||
if self._trigger_script_blink:
|
||||
self._trigger_script_blink = False
|
||||
self._is_script_blinking = True
|
||||
self._script_blink_start_time = time.time()
|
||||
if dpg.does_item_exist("win_script_output"):
|
||||
dpg.show_item("win_script_output")
|
||||
# dpg.focus_item("win_script_output") # Focus can sometimes be jarring, but requested
|
||||
|
||||
if self._is_script_blinking:
|
||||
elapsed = time.time() - self._script_blink_start_time
|
||||
if elapsed > 1.5:
|
||||
self._is_script_blinking = False
|
||||
if dpg.does_item_exist("script_blink_theme"):
|
||||
try:
|
||||
dpg.bind_item_theme("last_script_output", 0)
|
||||
dpg.bind_item_theme("last_script_text", 0)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
val = math.sin(elapsed * 8 * math.pi)
|
||||
alpha = 60 if val > 0 else 0
|
||||
|
||||
if not dpg.does_item_exist("script_blink_theme"):
|
||||
with dpg.theme(tag="script_blink_theme"):
|
||||
with dpg.theme_component(dpg.mvInputText):
|
||||
dpg.add_theme_color(dpg.mvThemeCol_FrameBg, (0, 100, 255, alpha), tag="script_blink_color")
|
||||
else:
|
||||
dpg.set_value("script_blink_color", [0, 100, 255, alpha])
|
||||
|
||||
if dpg.does_item_exist("last_script_output"):
|
||||
try:
|
||||
dpg.bind_item_theme("last_script_output", "script_blink_theme")
|
||||
dpg.bind_item_theme("last_script_text", "script_blink_theme")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if self._trigger_blink:
|
||||
self._trigger_blink = False
|
||||
self._is_blinking = True
|
||||
@@ -1782,7 +1857,7 @@ class App:
|
||||
else:
|
||||
# Square-wave style retro blink (4 times per second)
|
||||
val = math.sin(elapsed * 8 * math.pi)
|
||||
alpha = 120 if val > 0 else 0
|
||||
alpha = 50 if val > 0 else 0
|
||||
|
||||
if not dpg.does_item_exist("response_blink_theme"):
|
||||
with dpg.theme(tag="response_blink_theme"):
|
||||
@@ -1820,3 +1895,4 @@ def main():
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user