finally?
This commit is contained in:
+16
-4
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user