fix: cli tool logging (#3749)
This commit is contained in:
@@ -1040,23 +1040,21 @@ impl Session {
|
|||||||
if let Some(Value::String(msg)) = o.get("message") {
|
if let Some(Value::String(msg)) = o.get("message") {
|
||||||
// Extract subagent info for better display
|
// Extract subagent info for better display
|
||||||
let subagent_id = o.get("subagent_id")
|
let subagent_id = o.get("subagent_id")
|
||||||
.and_then(|v| v.as_str())
|
.and_then(|v| v.as_str());
|
||||||
.unwrap_or("unknown");
|
|
||||||
let notification_type = o.get("type")
|
let notification_type = o.get("type")
|
||||||
.and_then(|v| v.as_str())
|
.and_then(|v| v.as_str());
|
||||||
.unwrap_or("");
|
|
||||||
|
|
||||||
let formatted = match notification_type {
|
let formatted = match notification_type {
|
||||||
"subagent_created" | "completed" | "terminated" => {
|
Some("subagent_created") | Some("completed") | Some("terminated") => {
|
||||||
format!("🤖 {}", msg)
|
format!("🤖 {}", msg)
|
||||||
}
|
}
|
||||||
"tool_usage" | "tool_completed" | "tool_error" => {
|
Some("tool_usage") | Some("tool_completed") | Some("tool_error") => {
|
||||||
format!("🔧 {}", msg)
|
format!("🔧 {}", msg)
|
||||||
}
|
}
|
||||||
"message_processing" | "turn_progress" => {
|
Some("message_processing") | Some("turn_progress") => {
|
||||||
format!("💭 {}", msg)
|
format!("💭 {}", msg)
|
||||||
}
|
}
|
||||||
"response_generated" => {
|
Some("response_generated") => {
|
||||||
// Check verbosity setting for subagent response content
|
// Check verbosity setting for subagent response content
|
||||||
let config = Config::global();
|
let config = Config::global();
|
||||||
let min_priority = config
|
let min_priority = config
|
||||||
@@ -1080,7 +1078,7 @@ impl Session {
|
|||||||
msg.to_string()
|
msg.to_string()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(formatted, Some(subagent_id.to_string()), Some(notification_type.to_string()))
|
(formatted, subagent_id.map(str::to_string), notification_type.map(str::to_string))
|
||||||
} else if let Some(Value::String(output)) = o.get("output") {
|
} else if let Some(Value::String(output)) = o.get("output") {
|
||||||
// Fallback for other MCP notification types
|
// Fallback for other MCP notification types
|
||||||
(output.to_owned(), None, None)
|
(output.to_owned(), None, None)
|
||||||
@@ -1116,14 +1114,10 @@ impl Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if output::is_showing_thinking() {
|
||||||
// Non-subagent notification, display immediately with compact spacing
|
output::set_thinking_message(&formatted_message);
|
||||||
if interactive {
|
} else {
|
||||||
let _ = progress_bars.hide();
|
progress_bars.log(&formatted_message);
|
||||||
println!("{}", console::style(&formatted_message).green().dim());
|
|
||||||
} else {
|
|
||||||
progress_bars.log(&formatted_message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ServerNotification::ProgressNotification(notification) => {
|
ServerNotification::ProgressNotification(notification) => {
|
||||||
|
|||||||
@@ -115,6 +115,10 @@ impl ThinkingIndicator {
|
|||||||
spinner.stop("");
|
spinner.stop("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_shown(&self) -> bool {
|
||||||
|
self.spinner.is_some()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -138,7 +142,10 @@ pub fn hide_thinking() {
|
|||||||
THINKING.with(|t| t.borrow_mut().hide());
|
THINKING.with(|t| t.borrow_mut().hide());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
pub fn is_showing_thinking() -> bool {
|
||||||
|
THINKING.with(|t| t.borrow().is_shown())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_thinking_message(s: &String) {
|
pub fn set_thinking_message(s: &String) {
|
||||||
THINKING.with(|t| {
|
THINKING.with(|t| {
|
||||||
if let Some(spinner) = t.borrow_mut().spinner.as_mut() {
|
if let Some(spinner) = t.borrow_mut().spinner.as_mut() {
|
||||||
|
|||||||
Reference in New Issue
Block a user