Skip to content

Commit 35a1290

Browse files
committed
clear print res function
1 parent 8e86145 commit 35a1290

File tree

1 file changed

+11
-32
lines changed
  • crates/chat-cli/src/cli/chat/tools

1 file changed

+11
-32
lines changed

crates/chat-cli/src/cli/chat/tools/mod.rs

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -448,56 +448,35 @@ pub fn display_purpose(purpose: Option<&String>, updates: &mut impl Write) -> Re
448448
/// * `is_error` - Whether this is an error message (changes formatting)
449449
/// * `use_bullet` - Whether to use a bullet point instead of a tick/exclamation
450450
pub fn queue_function_result(result: &str, updates: &mut impl Write, is_error: bool, use_bullet: bool) -> Result<()> {
451-
use crossterm::queue;
452-
use crossterm::style::{
453-
self,
454-
Color,
455-
};
456-
457-
// Split the result into lines for proper formatting
458451
let lines = result.lines().collect::<Vec<_>>();
459-
let color = if is_error { Color::Red } else { Color::Reset };
452+
453+
// Determine symbol and color
454+
let (symbol, color) = match (is_error, use_bullet) {
455+
(true, _) => (super::ERROR_EXCLAMATION, Color::Red),
456+
(false, true) => (super::TOOL_BULLET, Color::Reset),
457+
(false, false) => (super::SUCCESS_TICK, Color::Green),
458+
};
460459

461460
queue!(updates, style::Print("\n"))?;
462461

463-
// Use appropriate symbol based on parameters
462+
// Print first line with symbol
464463
if let Some(first_line) = lines.first() {
465-
// Select symbol: bullet for summaries, tick/exclamation for operations
466-
let symbol = if is_error {
467-
super::ERROR_EXCLAMATION
468-
} else if use_bullet {
469-
super::TOOL_BULLET
470-
} else {
471-
super::SUCCESS_TICK
472-
};
473-
474-
// Set color to green for success ticks
475-
let text_color = if is_error {
476-
Color::Red
477-
} else if !use_bullet {
478-
Color::Green
479-
} else {
480-
Color::Reset
481-
};
482-
483464
queue!(
484465
updates,
485-
style::SetForegroundColor(text_color),
466+
style::SetForegroundColor(color),
486467
style::Print(symbol),
487468
style::ResetColor,
488469
style::Print(first_line),
489470
style::Print("\n"),
490471
)?;
491472
}
492473

493-
// For any additional lines, indent them properly
474+
// Print remaining lines with indentation
494475
for line in lines.iter().skip(1) {
495476
queue!(
496477
updates,
497-
style::Print(" "), // Same indentation as the bullet
498-
style::SetForegroundColor(color),
478+
style::Print(" "), // 3 spaces for alignment
499479
style::Print(line),
500-
style::ResetColor,
501480
style::Print("\n"),
502481
)?;
503482
}

0 commit comments

Comments
 (0)