fix(gui2): Correct Response panel rendering and fix automation crashes

This commit is contained in:
2026-02-24 21:56:26 -05:00
parent fb9ee27b38
commit 14984c5233
12 changed files with 103 additions and 64 deletions

View File

@@ -505,16 +505,19 @@ class App:
self._clickable_actions[item]()
elif action == "select_list_item":
item = task.get("item")
value = task.get("value")
item = task.get("listbox", task.get("item"))
value = task.get("item_value", task.get("value"))
if item == "disc_listbox":
self._switch_discussion(value)
elif action == "custom_callback":
callback_name = task.get("callback")
cb = task.get("callback")
args = task.get("args", [])
if callback_name in self._predefined_callbacks:
self._predefined_callbacks[callback_name](*args)
if callable(cb):
try: cb(*args)
except Exception as e: print(f"Error in direct custom callback: {e}")
elif cb in self._predefined_callbacks:
self._predefined_callbacks[cb](*args)
except Exception as e:
print(f"Error executing GUI task: {e}")
@@ -525,6 +528,14 @@ class App:
ai_client.clear_comms_log()
self._tool_log.clear()
self._comms_log.clear()
self.disc_entries.clear()
# Clear history in project dict too
disc_sec = self.project.get("discussion", {})
discussions = disc_sec.get("discussions", {})
if self.active_discussion in discussions:
discussions[self.active_discussion]["history"] = []
self.ai_status = "session reset"
self.ai_response = ""
@@ -1033,7 +1044,10 @@ class App:
self._trigger_script_blink = False
self._is_script_blinking = True
self._script_blink_start_time = time.time()
imgui.set_window_focus_str("Last Script Output")
try:
imgui.set_window_focus("Last Script Output")
except:
pass
if self._is_script_blinking:
elapsed = time.time() - self._script_blink_start_time
@@ -1546,38 +1560,44 @@ class App:
self.disc_entries.append({"role": "User", "content": self.ui_ai_input, "collapsed": False, "ts": project_manager.now_ts()})
def _render_response_panel(self):
if self._trigger_blink:
self._trigger_blink = False
self._is_blinking = True
self._blink_start_time = time.time()
imgui.set_window_focus_str("Response")
try:
imgui.set_window_focus("Response")
except:
pass
is_blinking = False
if self._is_blinking:
elapsed = time.time() - self._blink_start_time
if elapsed > 1.5:
self._is_blinking = False
else:
is_blinking = True
val = math.sin(elapsed * 8 * math.pi)
alpha = 50/255 if val > 0 else 0
imgui.push_style_color(imgui.Col_.frame_bg, vec4(0, 255, 0, alpha))
imgui.push_style_color(imgui.Col_.child_bg, vec4(0, 255, 0, alpha))
if self.ui_word_wrap:
imgui.begin_child("resp_wrap", imgui.ImVec2(-1, -40), True)
imgui.push_text_wrap_pos(imgui.get_content_region_avail().x)
imgui.text(self.ai_response)
imgui.pop_text_wrap_pos()
imgui.end_child()
else:
imgui.input_text_multiline("##ai_out", self.ai_response, imgui.ImVec2(-1, -40), imgui.InputTextFlags_.read_only)
imgui.separator()
if imgui.button("-> History"):
if self.ai_response:
self.disc_entries.append({"role": "AI", "content": self.ai_response, "collapsed": False, "ts": project_manager.now_ts()})
# --- Always Render Content ---
if self.ui_word_wrap:
imgui.begin_child("resp_wrap", imgui.ImVec2(-1, -40), True)
imgui.push_text_wrap_pos(imgui.get_content_region_avail().x)
imgui.text(self.ai_response)
imgui.pop_text_wrap_pos()
imgui.end_child()
else:
imgui.input_text_multiline("##ai_out", self.ai_response, imgui.ImVec2(-1, -40), imgui.InputTextFlags_.read_only)
if self._is_blinking:
imgui.pop_style_color(2)
imgui.separator()
if imgui.button("-> History"):
if self.ai_response:
self.disc_entries.append({"role": "AI", "content": self.ai_response, "collapsed": False, "ts": project_manager.now_ts()})
if is_blinking:
imgui.pop_style_color(2)
def _render_tool_calls_panel(self):
imgui.text("Tool call history")