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
+17
View File
@@ -16,6 +16,8 @@ use ratatui::Terminal;
use std::io::{self, Write};
use std::time::Duration;
use tracing::{debug, info};
use crate::action::{apply_action, Action};
use crate::controller::input::handle_key;
use crate::state::AppStateRest;
@@ -26,8 +28,10 @@ use crate::view;
/// Flow: build `AppStateRest` → enter raw mode / alternate screen →
/// run the event loop → always restore the terminal (even on error) →
/// save settings.
#[tracing::instrument]
pub fn run_single_process() -> Result<()> {
// Create session state
info!("starting single-process TUI");
let (_store, mut state) = create_local_session()?;
// Enter raw mode and alternate screen for the TUI
@@ -60,10 +64,15 @@ pub fn run_single_process() -> Result<()> {
}
/// Run the event loop, guaranteeing terminal restoration on error.
///
/// Wraps `run_loop_inner` so that if it panics or returns an error the
/// terminal is restored to a usable state before propagating the error.
#[tracing::instrument(skip(state, terminal))]
fn run_loop(
state: &mut AppStateRest,
terminal: &mut Terminal<CrosstermBackend<io::Stdout>>,
) -> Result<()> {
debug!("entering run_loop");
let result = run_loop_inner(state, terminal);
if let Err(ref _e) = result {
let _ = terminal.clear();
@@ -83,12 +92,15 @@ fn run_loop(
/// smooth updates), 200ms when idle (no reason to busy-loop)
/// - Toast expiry is drained once here instead of in two places
/// - Chat display lines are cached and rebuilt only when content changes
#[tracing::instrument(skip(state, terminal))]
fn run_loop_inner(
state: &mut AppStateRest,
terminal: &mut Terminal<CrosstermBackend<io::Stdout>>,
) -> Result<()> {
info!("TUI event loop started");
loop {
if state.quit {
info!("TUI event loop exiting (quit=true)");
break;
}
@@ -165,8 +177,13 @@ fn run_loop_inner(
}
/// Create session state with real infrastructure wired in.
///
/// Flow: initialise `Store` → ensure data directories → generate session ID →
/// load `Settings` and `AppConfig` from disk → construct `AppStateRest`.
#[tracing::instrument]
fn create_local_session() -> Result<(zesdex_domain::core::Store, AppStateRest)> {
let store = zesdex_domain::core::Store::new();
debug!("store created at {:?}", store.base_dir);
store.ensure_dirs()?;
let session_id = uuid::Uuid::new_v4().to_string();