This commit is contained in:
2026-05-07 13:42:31 -04:00
parent 40f0c04a91
commit 7d12806ce6
5 changed files with 521 additions and 30 deletions
+16 -4
View File
@@ -100,6 +100,7 @@ _gemini_cli_adapter: Optional[GeminiCliAdapter] = None
confirm_and_run_callback: Optional[Callable[[str, str, Optional[Callable[[str], str]], Optional[Callable[[str, str], Optional[str]]]], Optional[str]]] = None
# Injected by gui.py - called whenever a comms entry is appended.
# Use get_comms_log_callback/set_comms_log_callback for thread-safe access.
comms_log_callback: Optional[Callable[[dict[str, Any]], None]] = None
# Injected by gui.py - called whenever a tool call completes.
@@ -117,6 +118,14 @@ def set_current_tier(tier: Optional[str]) -> None:
"""Sets the current tier in thread-local storage."""
_local_storage.current_tier = tier
def get_comms_log_callback() -> Optional[Callable[[dict[str, Any]], None]]:
"""Returns the comms log callback from thread-local storage."""
return getattr(_local_storage, "comms_log_callback", None)
def set_comms_log_callback(cb: Optional[Callable[[dict[str, Any]], None]]) -> None:
"""Sets the comms log callback in thread-local storage."""
_local_storage.comms_log_callback = cb
# Increased to allow thorough code exploration before forcing a summary
MAX_TOOL_ROUNDS: int = 10
@@ -203,8 +212,9 @@ def _append_comms(direction: str, kind: str, payload: dict[str, Any]) -> None:
"local_ts": time.time(),
}
_comms_log.append(entry)
if comms_log_callback is not None:
comms_log_callback(entry)
_cb = get_comms_log_callback()
if _cb is not None:
_cb(entry)
def get_comms_log() -> list[dict[str, Any]]:
return list(_comms_log)
@@ -1225,8 +1235,10 @@ def _send_gemini_cli(md_content: str, user_message: str, base_dir: str,
"tool_calls": log_calls,
"usage": usage
})
if txt and calls and comms_log_callback:
comms_log_callback({
if txt and calls:
cb = get_comms_log_callback()
if cb:
cb({
"ts": project_manager.now_ts(),
"direction": "IN",
"kind": "history_add",
+13 -13
View File
@@ -1099,19 +1099,19 @@ class App:
imgui.close_current_popup()
imgui.end_popup()
# MMA Step Approval Modal
if self._pending_mma_approval:
if self._pending_mma_approvals:
if not self._mma_approval_open:
imgui.open_popup("MMA Step Approval")
self._mma_approval_open = True
self._mma_approval_edit_mode = False
self._mma_approval_payload = self._pending_mma_approval.get("payload", "")
self._mma_approval_payload = self._pending_mma_approvals[0].get("payload", "")
else:
self._mma_approval_open = False
if imgui.begin_popup_modal("MMA Step Approval", None, imgui.WindowFlags_.always_auto_resize)[0]:
if not self._pending_mma_approval:
if not self._pending_mma_approvals:
imgui.close_current_popup()
else:
ticket_id = self._pending_mma_approval.get("ticket_id", "??")
ticket_id = self._pending_mma_approvals[0].get("ticket_id", "??")
imgui.text(f"Ticket {ticket_id} is waiting for tool execution approval.")
imgui.separator()
if self._mma_approval_edit_mode:
@@ -1120,7 +1120,7 @@ class App:
else:
imgui.text("Proposed Tool Call:")
imgui.begin_child("mma_preview", imgui.ImVec2(600, 300), True)
imgui.text_unformatted(str(self._pending_mma_approval.get("payload", "")))
imgui.text_unformatted(str(self._pending_mma_approvals[0].get("payload", "")))
imgui.end_child()
imgui.separator()
if imgui.button("Approve", imgui.ImVec2(120, 0)):
@@ -1135,21 +1135,21 @@ class App:
imgui.close_current_popup()
imgui.end_popup()
# MMA Spawn Approval Modal
if self._pending_mma_spawn:
if self._pending_mma_spawns:
if not self._mma_spawn_open:
imgui.open_popup("MMA Spawn Approval")
self._mma_spawn_open = True
self._mma_spawn_edit_mode = False
self._mma_spawn_prompt = self._pending_mma_spawn.get("prompt", "")
self._mma_spawn_context = self._pending_mma_spawn.get("context_md", "")
self._mma_spawn_prompt = self._pending_mma_spawns[0].get("prompt", "")
self._mma_spawn_context = self._pending_mma_spawns[0].get("context_md", "")
else:
self._mma_spawn_open = False
if imgui.begin_popup_modal("MMA Spawn Approval", None, imgui.WindowFlags_.always_auto_resize)[0]:
if not self._pending_mma_spawn:
if not self._pending_mma_spawns:
imgui.close_current_popup()
else:
role = self._pending_mma_spawn.get("role", "??")
ticket_id = self._pending_mma_spawn.get("ticket_id", "??")
role = self._pending_mma_spawns[0].get("role", "??")
ticket_id = self._pending_mma_spawns[0].get("ticket_id", "??")
imgui.text(f"Spawning {role} for Ticket {ticket_id}")
imgui.separator()
if self._mma_spawn_edit_mode:
@@ -4264,8 +4264,8 @@ def hello():
imgui.text_colored(C_VAL, f"| Active: {self.active_tier}")
# Approval pending indicator
any_pending = (
self._pending_mma_spawn is not None or
self._pending_mma_approval is not None or
len(self._pending_mma_spawns) > 0 or
len(self._pending_mma_approvals) > 0 or
self._pending_ask_dialog
)
if any_pending: