feat(gui): Add auto-scroll, blinking history, and reactive API events

This commit is contained in:
2026-02-25 00:41:45 -05:00
parent 3113e3c103
commit fb80ce8c5a
24 changed files with 575 additions and 172 deletions

View File

@@ -108,6 +108,27 @@ class ApiHookClient:
"value": value
})
def get_value(self, item):
"""Gets the value of a GUI item via its mapped field."""
try:
res = self._make_request('GET', f'/api/gui/value/{item}')
return res.get("value")
except Exception as e:
# Fallback for thinking/live/prior which are in diagnostics
diag = self._make_request('GET', '/api/gui/diagnostics')
if item in diag:
return diag[item]
# Map common indicator tags to diagnostics keys
mapping = {
"thinking_indicator": "thinking",
"operations_live_indicator": "live",
"prior_session_indicator": "prior"
}
key = mapping.get(item)
if key and key in diag:
return diag[key]
return None
def click(self, item, *args, **kwargs):
"""Simulates a click on a GUI button or item."""
user_data = kwargs.pop('user_data', None)
@@ -134,6 +155,24 @@ class ApiHookClient:
except Exception as e:
return {"tag": tag, "shown": False, "error": str(e)}
def get_events(self):
"""Fetches and clears the event queue from the server."""
try:
return self._make_request('GET', '/api/events').get("events", [])
except Exception:
return []
def wait_for_event(self, event_type, timeout=10):
"""Polls for a specific event type."""
start = time.time()
while time.time() - start < timeout:
events = self.get_events()
for ev in events:
if ev.get("type") == event_type:
return ev
time.sleep(1.0)
return None
def reset_session(self):
"""Simulates clicking the 'Reset Session' button in the GUI."""
return self.click("btn_reset")