conductor(checkpoint): Checkpoint end of Phase 2
This commit is contained in:
60
gui_2.py
60
gui_2.py
@@ -426,10 +426,38 @@ class App:
|
||||
# Mappings for safe hook execution
|
||||
settable_fields = {
|
||||
'ai_input': 'ui_ai_input',
|
||||
'project_git_dir': 'ui_project_git_dir',
|
||||
'auto_add_history': 'ui_auto_add_history',
|
||||
'disc_new_name_input': 'ui_disc_new_name_input',
|
||||
}
|
||||
|
||||
def _cb_new_project_automated(user_data):
|
||||
if user_data:
|
||||
name = Path(user_data).stem
|
||||
proj = project_manager.default_project(name)
|
||||
project_manager.save_project(proj, user_data)
|
||||
if user_data not in self.project_paths:
|
||||
self.project_paths.append(user_data)
|
||||
self._switch_project(user_data)
|
||||
|
||||
def _cb_project_save():
|
||||
self._flush_to_project()
|
||||
self._save_active_project()
|
||||
self._flush_to_config()
|
||||
save_config(self.config)
|
||||
self.ai_status = "config saved"
|
||||
|
||||
def _cb_disc_create():
|
||||
nm = self.ui_disc_new_name_input.strip()
|
||||
if nm:
|
||||
self._create_discussion(nm)
|
||||
self.ui_disc_new_name_input = ""
|
||||
|
||||
clickable_actions = {
|
||||
'btn_reset': self._handle_reset_session,
|
||||
'btn_gen_send': self._handle_generate_send,
|
||||
'btn_project_save': _cb_project_save,
|
||||
'btn_disc_create': _cb_disc_create,
|
||||
}
|
||||
predefined_callbacks = {
|
||||
'_test_callback_func_write_to_file': self._test_callback_func_write_to_file
|
||||
@@ -450,8 +478,17 @@ class App:
|
||||
|
||||
elif action == "click":
|
||||
item = task.get("item")
|
||||
if item in clickable_actions:
|
||||
user_data = task.get("user_data")
|
||||
if item == "btn_project_new_automated":
|
||||
_cb_new_project_automated(user_data)
|
||||
elif item in clickable_actions:
|
||||
clickable_actions[item]()
|
||||
|
||||
elif action == "select_list_item":
|
||||
item = task.get("item")
|
||||
value = task.get("value")
|
||||
if item == "disc_listbox":
|
||||
self._switch_discussion(value)
|
||||
|
||||
elif action == "custom_callback":
|
||||
callback_name = task.get("callback")
|
||||
@@ -547,13 +584,18 @@ class App:
|
||||
|
||||
def _refresh_api_metrics(self, payload: dict):
|
||||
self._recalculate_session_usage()
|
||||
try:
|
||||
stats = ai_client.get_history_bleed_stats()
|
||||
self._token_budget_pct = stats.get("percentage", 0.0) / 100.0
|
||||
self._token_budget_current = stats.get("current", 0)
|
||||
self._token_budget_limit = stats.get("limit", 0)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def fetch_stats():
|
||||
try:
|
||||
stats = ai_client.get_history_bleed_stats()
|
||||
self._token_budget_pct = stats.get("percentage", 0.0) / 100.0
|
||||
self._token_budget_current = stats.get("current", 0)
|
||||
self._token_budget_limit = stats.get("limit", 0)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
threading.Thread(target=fetch_stats, daemon=True).start()
|
||||
|
||||
cache_stats = payload.get("cache_stats")
|
||||
if cache_stats:
|
||||
count = cache_stats.get("cache_count", 0)
|
||||
@@ -1358,7 +1400,7 @@ class App:
|
||||
ts_str = entry.get("ts", "")
|
||||
if ts_str:
|
||||
imgui.same_line()
|
||||
imgui.text_colored(vec4(120, 120, 100), ts_str)
|
||||
imgui.text_colored(vec4(120, 120, 100), str(ts_str))
|
||||
|
||||
if collapsed:
|
||||
imgui.same_line()
|
||||
|
||||
Reference in New Issue
Block a user