Enhance logging and documentation across utility tools and TUI overlays

- Added tracing instrumentation and improved logging messages in the Pong, Todofinish, and Todowrite tools for better debugging and monitoring.
- Enhanced documentation comments for clarity on tool functionalities and workflows.
- Implemented tracing in WorkflowRun, NoteFinding, ReadFindings, and HiveMind tools to track execution phases and findings.
- Updated TUI overlays (e.g., Bash, Clear Confirm, Editor, Effort Level, Help, Key Input, Learning, Loading, MCP, Model Selector, Plan, Quit Confirm, Rewind, Settings, Todo, Usage) with debug logging to capture rendering details.
- Improved the status bar and workflow panel rendering with additional debug information.
- Added tracing to various utility functions to facilitate better performance monitoring and error tracking.
This commit is contained in:
asepharyana
2026-07-20 15:53:43 +07:00
parent f84dfb8476
commit 16494d4b1e
69 changed files with 637 additions and 30 deletions
+15
View File
@@ -18,6 +18,11 @@ use zesdex_infrastructure::TurnEvent;
use crate::state::AppStateRest;
/// Spawn an agent turn on a background OS thread.
///
/// Flow: compare-exchange the in-flight flag → snapshot state fields →
/// clone session runtime messages → push user message → spawn OS thread
/// that runs `run_turn`.
#[tracing::instrument(skip(state))]
pub fn spawn_agent_turn(state: &mut AppStateRest, text: String) {
// compare_exchange: only mark in-flight if not already running
if state.turn_in_flight_flag
@@ -86,6 +91,10 @@ pub fn spawn_agent_turn(state: &mut AppStateRest, text: String) {
}
/// Parameters for a turn, grouped to avoid too-many-arguments lint.
///
/// Holds all the references and owned values that `run_turn` needs:
/// message history, turn-event queue, abort/in-flight flags, API credentials,
/// and environment paths.
struct TurnParams<'a> {
messages: &'a mut Vec<ChatMessage>,
session_dir: &'a Path,
@@ -99,6 +108,12 @@ struct TurnParams<'a> {
}
/// The core agent turn — LLM call → tool execution → repeat.
///
/// Flow: build `LlmClient` → compile tools → prepend system message →
/// loop (max 50 iterations): abort check → stream LLM response →
/// push events → execute tool calls → push results → break on
/// no tool calls or error → emit final `Compacted` + `Done`.
#[tracing::instrument(skip(params))]
fn run_turn(params: TurnParams) {
let client = LlmClient::new(params.api_key, params.model, params.api_base);