From 38b0019ad4cf02641b2e0093892878c53a4c03e5 Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Tue, 20 Jan 2026 22:49:55 +0530 Subject: [PATCH] Fix compile warnings and tweak error message format Warnings fixed: - Remove unused 'warn' import from retry.rs - Prefix unused 'output' param with underscore - Prefix unused 'rel_start' with underscore - Add #[allow(dead_code)] to G3Status::info() Message format tweaked per feedback: - 'g3: model overloaded [error]' (no attempt info) - 'g3: retrying in 2.2s (1/3) ... [done]' (attempt info moved here) - Handle empty error message in Status::Error to show just '[error]' --- crates/g3-cli/src/completion.rs | 2 +- crates/g3-cli/src/g3_status.rs | 9 +++++++-- crates/g3-cli/src/task_execution.rs | 6 +++--- crates/g3-core/src/retry.rs | 10 +++++----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/crates/g3-cli/src/completion.rs b/crates/g3-cli/src/completion.rs index 4aadcaa..d296bfd 100644 --- a/crates/g3-cli/src/completion.rs +++ b/crates/g3-cli/src/completion.rs @@ -224,7 +224,7 @@ impl Completer for G3Helper { let path: &str = &path_unescaped; // Complete just the path portion - let (rel_start, completions) = self.file_completer.complete(path, path.len(), ctx)?; + let (_rel_start, completions) = self.file_completer.complete(path, path.len(), ctx)?; if completions.is_empty() { return Ok((pos, vec![])); diff --git a/crates/g3-cli/src/g3_status.rs b/crates/g3-cli/src/g3_status.rs index 9a92f59..b724298 100644 --- a/crates/g3-cli/src/g3_status.rs +++ b/crates/g3-cli/src/g3_status.rs @@ -164,6 +164,7 @@ impl G3Status { /// Print an info message in dimmed/grey text. /// Format: "... " + #[allow(dead_code)] pub fn info(message: &str) { println!( "{}... {}{}", @@ -202,9 +203,13 @@ impl G3Status { ResetColor ), Status::Error(msg) => format!( - "{}[error: {}]{}", + "{}{}{}", SetForegroundColor(Color::Red), - msg, + if msg.is_empty() { + "[error]".to_string() + } else { + format!("[error: {}]", msg) + }, ResetColor ), Status::Resolved => format!( diff --git a/crates/g3-cli/src/task_execution.rs b/crates/g3-cli/src/task_execution.rs index 9907139..6cd069e 100644 --- a/crates/g3-cli/src/task_execution.rs +++ b/crates/g3-cli/src/task_execution.rs @@ -84,11 +84,11 @@ pub async fn execute_task_with_retry( // Print error status G3Status::complete( recoverable_error_name(&recoverable_error), - crate::g3_status::Status::Error(format!("attempt {}/{}", attempt, MAX_RETRIES)), + crate::g3_status::Status::Error(String::new()), ); // Print retry message (no newline, will show [done] after sleep) - G3Status::progress(&format!("retrying in {:.1}s", delay_secs)); + G3Status::progress(&format!("retrying in {:.1}s ({}/{})", delay_secs, attempt, MAX_RETRIES)); // Wait before retrying tokio::time::sleep(delay).await; @@ -106,7 +106,7 @@ pub async fn execute_task_with_retry( } /// Handle execution errors with detailed logging and user-friendly output. -pub fn handle_execution_error(e: &anyhow::Error, input: &str, output: &SimpleOutput, attempt: u32) { +pub fn handle_execution_error(e: &anyhow::Error, input: &str, _output: &SimpleOutput, attempt: u32) { // Check if this is a recoverable error type (for logging level decision) let error_type = classify_error(e); let is_recoverable = matches!(error_type, ErrorType::Recoverable(_)); diff --git a/crates/g3-core/src/retry.rs b/crates/g3-core/src/retry.rs index 79bfdc4..24d6feb 100644 --- a/crates/g3-core/src/retry.rs +++ b/crates/g3-core/src/retry.rs @@ -10,7 +10,7 @@ use crate::ui_writer::UiWriter; use crate::{Agent, DiscoveryOptions, TaskResult}; use anyhow::Result; use std::time::Instant; -use tracing::{debug, warn}; +use tracing::debug; /// Configuration for retry behavior #[derive(Debug, Clone)] @@ -206,11 +206,11 @@ where let delay_secs = delay.as_secs_f64(); // Clean error message - let msg = format!("g3: {:?} [error: attempt {}/{}]", recoverable_type, retry_count, config.max_retries); + let msg = format!("g3: {:?} [error]", recoverable_type); print_fn(&msg); // Retry message - note: can't show [done] here since we don't control when sleep finishes - let retry_msg = format!("g3: retrying in {:.1}s ...", delay_secs); + let retry_msg = format!("g3: retrying in {:.1}s ({}/{}) ...", delay_secs, retry_count, config.max_retries); print_fn(&retry_msg); debug!( @@ -283,10 +283,10 @@ where let delay_secs = delay.as_secs_f64(); // Clean error message - let msg = format!("g3: {:?} [error: attempt {}/{}]", recoverable_type, retry_count, max_retries); + let msg = format!("g3: {:?} [error]", recoverable_type); print_fn(&msg); - let retry_msg = format!("g3: retrying in {:.1}s ...", delay_secs); + let retry_msg = format!("g3: retrying in {:.1}s ({}/{}) ...", delay_secs, retry_count, max_retries); print_fn(&retry_msg); tokio::time::sleep(delay).await;