refactor: remove unused tracing imports across multiple files

This commit is contained in:
asepharyana
2026-07-20 07:02:55 +07:00
parent 714b4617dd
commit bceba665c0
13 changed files with 48 additions and 68 deletions
@@ -62,7 +62,7 @@ impl Drop for RunningGuard {
}
/// ─── Helpers ───
///
/// Derive a human-readable message prefix from the internal kind label.
///
/// Production callers always pass one of the three known labels
@@ -237,20 +237,46 @@ fn run_subagent_with_retry(
/// b. Creates an `AgentDefinition` and calls `run_subagent_with_retry`.
/// c. Formats the result as a `SystemNote` message.
/// d. Pushes the note onto `turn_events` for TUI consumption.
///
/// Shared configuration for a background review subagent.
///
/// Bundles arguments common across all review kinds into a single struct
/// so `spawn_background_review` stays under the clippy argument-count limit.
struct BackgroundReviewCfg {
file_paths: Vec<String>,
session_dir: std::path::PathBuf,
workspaces: Vec<std::path::PathBuf>,
turn_events: Arc<Mutex<VecDeque<TurnEvent>>>,
abort_flag: Arc<AtomicBool>,
}
impl BackgroundReviewCfg {
fn new(
file_paths: &[String],
session_dir: &Path,
workspaces: &[std::path::PathBuf],
turn_events: &Arc<Mutex<VecDeque<TurnEvent>>>,
abort_flag: Arc<AtomicBool>,
) -> Self {
Self {
file_paths: file_paths.to_vec(),
session_dir: session_dir.to_path_buf(),
workspaces: workspaces.to_vec(),
turn_events: turn_events.clone(),
abort_flag,
}
}
}
fn spawn_background_review(
kind: &str,
running_flag: &'static AtomicBool,
prompt_constant: &str,
agent_name: &str,
agent_role: &str,
file_paths: Vec<String>,
session_dir: std::path::PathBuf,
workspaces: Vec<std::path::PathBuf>,
turn_events: Arc<Mutex<VecDeque<TurnEvent>>>,
abort_flag: Arc<AtomicBool>,
cfg: BackgroundReviewCfg,
) {
// Early return: no files to review or another run of this kind is active.
if file_paths.is_empty() {
if cfg.file_paths.is_empty() {
return;
}
if running_flag
@@ -261,34 +287,26 @@ fn spawn_background_review(
return;
}
// Copy arguments into owned values for the spawned thread.
let sd = session_dir;
let ws = workspaces;
let events = turn_events;
let prompt_text = format!(
"{}\n\nModified files:\n{}",
prompt_constant,
file_paths.join("\n"),
cfg.file_paths.join("\n"),
);
let label = kind.to_string();
let agent_name = agent_name.to_string();
let agent_role = agent_role.to_string();
let prefix = message_prefix(kind);
// Spawn a dedicated OS thread for the background review.
std::thread::spawn(move || {
// RunningGuard resets the flag on drop (including panic unwind).
let _running_guard = RunningGuard(running_flag);
tracing::info!("[{label}] spawning for {} file(s)", file_paths.len());
tracing::info!("[{label}] spawning for {} file(s)", cfg.file_paths.len());
let def = AgentDefinition::new(agent_name, agent_role).with_system_prompt(prompt_text);
// Run the subagent with a single retry on failure.
let result = run_subagent_with_retry(&def, &sd, &ws, &label, Some(&abort_flag));
let result = run_subagent_with_retry(
&def, &cfg.session_dir, &cfg.workspaces, &label, Some(&cfg.abort_flag),
);
// Format the result as a user-facing SystemNote message.
// Errors that mention "aborted" get a soft "cancelled" prefix;
// other errors get an "ESCALATED:" prefix to catch the user's eye.
let message = match &result {
Ok(output) => {
let first = output.lines().next().unwrap_or(output);
@@ -298,8 +316,7 @@ fn spawn_background_review(
Err(e) => format!("ESCALATED: {prefix} {e}"),
};
// Push the SystemNote onto the shared turn_events queue.
if let Ok(mut q) = events.lock() {
if let Ok(mut q) = cfg.turn_events.lock() {
q.push_back(TurnEvent::SystemNote {
kind: label.clone(),
message,
@@ -311,24 +328,6 @@ fn spawn_background_review(
});
}
/// Collect the trailing arguments shared by all background-review spawners
/// into owned values, reducing boilerplate in each individual spawner function.
fn review_args<'a>(
file_paths: &'a [String],
session_dir: &'a Path,
workspaces: &'a [std::path::PathBuf],
turn_events: &'a Arc<Mutex<VecDeque<TurnEvent>>>,
abort_flag: Arc<AtomicBool>,
) -> (Vec<String>, std::path::PathBuf, Vec<std::path::PathBuf>, Arc<Mutex<VecDeque<TurnEvent>>>, Arc<AtomicBool>) {
(
file_paths.to_vec(),
session_dir.to_path_buf(),
workspaces.to_vec(),
turn_events.clone(),
abort_flag,
)
}
/// Spawn a background subagent that generates tests for modified files.
///
/// Only fires for production source files (non-test, non-config).
@@ -341,11 +340,11 @@ pub fn spawn_background_test_gen(
abort_flag: Arc<AtomicBool>,
) {
tracing::debug!("[auto] spawn_background_test_gen: {} file(s)", file_paths.len());
let (fps, sd, ws, te, af) = review_args(file_paths, session_dir, workspaces, turn_events, abort_flag);
let cfg = BackgroundReviewCfg::new(file_paths, session_dir, workspaces, turn_events, abort_flag);
spawn_background_review(
"bg-test-gen", &TEST_GEN_RUNNING,
crate::prompts::TEST_GENERATOR_PROMPT, "test-generator", "coder",
fps, sd, ws, te, af,
cfg,
);
}
@@ -361,11 +360,11 @@ pub fn spawn_background_arch_review(
abort_flag: Arc<AtomicBool>,
) {
tracing::debug!("[auto] spawn_background_arch_review: {} file(s)", file_paths.len());
let (fps, sd, ws, te, af) = review_args(file_paths, session_dir, workspaces, turn_events, abort_flag);
let cfg = BackgroundReviewCfg::new(file_paths, session_dir, workspaces, turn_events, abort_flag);
spawn_background_review(
"bg-arch-review", &ARCH_REVIEW_RUNNING,
crate::prompts::ARCH_REVIEWER_PROMPT, "arch-reviewer", "reviewer",
fps, sd, ws, te, af,
cfg,
);
}
@@ -384,16 +383,16 @@ pub fn spawn_background_security_review(
tracing::debug!("[auto] spawn_background_security_review: {} file(s)", file_paths.len());
// Security review only applies to production code, not tests or config.
let (_, sd, ws, te, af) = review_args(file_paths, session_dir, workspaces, turn_events, abort_flag);
let prod_paths: Vec<String> = file_paths
.iter()
.filter(|p| is_production_code(p))
.cloned()
.collect();
let cfg = BackgroundReviewCfg::new(&prod_paths, session_dir, workspaces, turn_events, abort_flag);
spawn_background_review(
"bg-security-review", &SECURITY_REVIEW_RUNNING,
crate::prompts::SECURITY_REVIEWER_PROMPT, "security-reviewer", "reviewer",
prod_paths, sd, ws, te, af,
cfg,
);
}
@@ -99,12 +99,9 @@ fn format_subagent_progress(prefix: &str, text: &str) -> String {
/// 5. Fail fast if no API key is configured.
/// 6. For each step (up to `max_steps`):
/// a. Check abort flag.
/// b. Call LLM via `chat_with_tools_streaming` with per-SSE-event
/// abort checking and up to 3 step-level retries.
/// b. Call LLM via `chat_with_tools_streaming`, per-SSE-event abort checking and up to 3 step-level retries.
/// c. Emit progress / usage / step events on the mpsc channel.
/// d. Execute tool calls in parallel via `std::thread::scope`,
/// each gated by the three-layer pipeline (allowlist → risky →
/// content-safety).
/// d. Execute tool calls in parallel via `std::thread::scope`, each gated by the three-layer pipeline (allowlist → risky → content-safety).
/// e. Auto-share read-only tool results to `workflow_findings`.
/// f. Break on first text-only (non-empty) response.
/// 7. Send `Completed` event and return the accumulated output.
@@ -67,12 +67,6 @@ impl AgentDefinition {
self
}
/// Builder method: set the temperature override for this agent's LLM calls.
pub fn with_temperature(mut self, temperature: f32) -> Self {
tracing::debug!("[subagent] AgentDefinition::with_temperature({temperature})");
self.temperature = Some(temperature);
self
}
}
/// Shared subagent spawning utility: creates an mpsc channel and spawns a
-1
View File
@@ -13,7 +13,6 @@
//! The client has no agent logic — it is a pure render frontend.
use anyhow::Result;
use tracing;
use app::state::rest::AppStateRest;
use app::state::types::{Overlay, Toast, ToastKind};
use crossterm::execute;
-1
View File
@@ -23,7 +23,6 @@
use std::path::Path;
use tracing;
/// Entry point: migrate all session databases.
///
-1
View File
@@ -15,7 +15,6 @@
//! All file writes use an atomic temp-file + rename pattern to prevent
//! partial writes from corrupting configuration files during crashes.
use tracing;
/// Entry point: initialise the store and create seed data.
///
-1
View File
@@ -9,7 +9,6 @@ use app::runtime::actions::{apply_action, Action};
use app::state::rest::AppStateRest;
use crossterm::event::KeyCode;
use ipc::protocol::{ClientRequest, DaemonFrame, MessageEntry, StatePayload, ToastEntry};
use tracing;
use zesdex_cms::domain::repository::SettingsRepository;
use zesdex_utils::CastOr;
-1
View File
@@ -14,7 +14,6 @@
//! iteration (drives streaming/background progress) → on quit, clear.
use anyhow::Result;
use tracing;
use app::runtime::actions::{apply_action, Action};
use app::state::rest::AppStateRest;
use controller::input::handle_key;
-1
View File
@@ -7,7 +7,6 @@
use anyhow::Result;
use std::sync::Mutex;
use tracing;
use zesdex_iam::domain::repository::{SessionLockRepository, SessionRepository};
-1
View File
@@ -10,7 +10,6 @@
//! the session lock is cleaned up.
use std::path::PathBuf;
use tracing;
/// RAII guard that releases a session lock on drop, restoring the
/// panic-safety net the old `entities::SessionLock`'s `Drop` impl provided
-1
View File
@@ -12,7 +12,6 @@ use sha2::Digest;
use std::path::PathBuf;
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Mutex};
use tracing;
pub mod bash_tools;
pub mod fs;
@@ -15,7 +15,6 @@ use super::Tool;
use super::ToolCtx;
use anyhow::{anyhow, Result};
use serde_json::{json, Value};
use tracing;
/// Tool that parses and executes a JSON-encoded workflow script (Agent/Parallel/Pipeline/Phase).
pub struct WorkflowRun;
-1
View File
@@ -21,7 +21,6 @@ use ratatui::widgets::{Block, Borders, Clear, Paragraph, Wrap};
use ratatui::Frame;
use theme::Theme;
use zesdex_utils::CastOr;
use tracing;
/// Minimum terminal width (columns) at which the persistent dashboard
/// sidebar is shown; below this, chat reclaims the full width.