feat(hooks): extend ApiHookClient and GUI for tab/listbox control

This commit is contained in:
2026-02-23 19:20:20 -05:00
parent 1d674c3a1e
commit f36d539c36
3 changed files with 121 additions and 7 deletions

29
gui.py
View File

@@ -2100,10 +2100,10 @@ class App:
height=200,
)
with dpg.group(horizontal=True):
dpg.add_button(label="Gen + Send", callback=self.cb_generate_send)
dpg.add_button(label="MD Only", callback=self.cb_md_only)
dpg.add_button(label="Reset", callback=self.cb_reset_session)
dpg.add_button(label="-> History", callback=self.cb_append_message_to_history)
dpg.add_button(label="Gen + Send", tag="btn_gen_send", callback=self.cb_generate_send)
dpg.add_button(label="MD Only", tag="btn_md_only", callback=self.cb_md_only)
dpg.add_button(label="Reset", tag="btn_reset", callback=self.cb_reset_session)
dpg.add_button(label="-> History", tag="btn_to_history", callback=self.cb_append_message_to_history)
with dpg.tab(label="AI Response"):
dpg.add_input_text(
@@ -2133,8 +2133,8 @@ class App:
dpg.add_spacer(width=20)
dpg.add_text("LIVE", tag="operations_live_indicator", color=(100, 255, 100), show=False)
with dpg.tab_bar():
with dpg.tab(label="Comms Log"):
with dpg.tab_bar(tag="operations_tabs"):
with dpg.tab(label="Comms Log", tag="tab_comms"):
with dpg.group(horizontal=True):
dpg.add_text("Status: idle", tag="ai_status", color=(200, 220, 160))
dpg.add_spacer(width=16)
@@ -2148,7 +2148,7 @@ class App:
with dpg.child_window(tag="comms_scroll", height=-1, border=False, horizontal_scrollbar=True):
pass
with dpg.tab(label="Tool Log"):
with dpg.tab(label="Tool Log", tag="tab_tool"):
with dpg.group(horizontal=True):
dpg.add_text("Tool call history")
dpg.add_button(label="Clear", callback=self.cb_clear_tool_log)
@@ -2305,6 +2305,21 @@ class App:
cb = dpg.get_item_callback(item)
if cb:
cb()
elif action == "select_tab":
tab_bar = task.get("tab_bar")
tab = task.get("tab")
if tab_bar and dpg.does_item_exist(tab_bar):
dpg.set_value(tab_bar, tab)
elif action == "select_list_item":
listbox = task.get("listbox")
val = task.get("item_value")
if listbox and dpg.does_item_exist(listbox):
dpg.set_value(listbox, val)
cb = dpg.get_item_callback(listbox)
if cb:
# Dear PyGui callbacks for listbox usually receive (sender, app_data, user_data)
# app_data is the selected value.
cb(listbox, val)
elif action == "refresh_api_metrics":
self._refresh_api_metrics(task.get("payload", {}))
except Exception as e: