Skip to content

Commit ad24ef1

Browse files
authored
update tooluse ux (#3330)
1 parent 6b06774 commit ad24ef1

File tree

10 files changed

+103
-113
lines changed

10 files changed

+103
-113
lines changed

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

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,8 @@ fn trust_all_text() -> String {
463463
ui_text::trust_all_warning()
464464
}
465465

466-
const TOOL_BULLET: &str = " ";
466+
const TOOL_BULLET: &str = "- ";
467467
const CONTINUATION_LINE: &str = " ⋮ ";
468-
const PURPOSE_ARROW: &str = " ↳ ";
469468
const SUCCESS_TICK: &str = " ✓ ";
470469
const ERROR_EXCLAMATION: &str = " ❗ ";
471470
const DELEGATE_NOTIFIER: &str = "[BACKGROUND TASK READY]";
@@ -1906,19 +1905,19 @@ impl ChatSession {
19061905
self.stderr,
19071906
StyledText::secondary_fg(),
19081907
style::Print("\nAllow this action? Use '"),
1909-
StyledText::success_fg(),
1908+
StyledText::current_item_fg(),
19101909
style::Print("t"),
19111910
StyledText::secondary_fg(),
19121911
style::Print("' to trust (always allow) this tool for the session. ["),
1913-
StyledText::success_fg(),
1912+
StyledText::current_item_fg(),
19141913
style::Print("y"),
19151914
StyledText::secondary_fg(),
19161915
style::Print("/"),
1917-
StyledText::success_fg(),
1916+
StyledText::current_item_fg(),
19181917
style::Print("n"),
19191918
StyledText::secondary_fg(),
19201919
style::Print("/"),
1921-
StyledText::success_fg(),
1920+
StyledText::current_item_fg(),
19221921
style::Print("t"),
19231922
StyledText::secondary_fg(),
19241923
style::Print("]:\n\n"),
@@ -2496,12 +2495,8 @@ impl ChatSession {
24962495
debug!("tool result output: {:#?}", result);
24972496
execute!(
24982497
self.stdout,
2499-
style::Print(CONTINUATION_LINE),
2498+
style::Print(format!(" - Completed in {tool_time}s")),
25002499
style::Print("\n"),
2501-
StyledText::success_fg(),
2502-
style::SetAttribute(Attribute::Bold),
2503-
style::Print(format!(" ● Completed in {tool_time}s")),
2504-
StyledText::reset(),
25052500
)?;
25062501
if let Some(tag) = checkpoint_tag {
25072502
execute!(
@@ -3386,35 +3381,15 @@ impl ChatSession {
33863381
parent_message_id: None,
33873382
};
33883383
self.stdout.send(Event::ToolCallStart(tool_call_start))?;
3389-
} else {
3384+
} else if let Tool::Custom(ref tool) = tool_use.tool {
33903385
queue!(
33913386
self.stdout,
3387+
StyledText::reset(),
3388+
style::Print(" from mcp server "),
33923389
StyledText::emphasis_fg(),
3393-
style::Print(format!(
3394-
"🛠️ Using tool: {}{}",
3395-
tool_use.tool.display_name(),
3396-
if trusted { " (trusted)".dark_green() } else { "".reset() }
3397-
)),
3390+
style::Print(&tool.server_name),
33983391
StyledText::reset(),
33993392
)?;
3400-
if let Tool::Custom(ref tool) = tool_use.tool {
3401-
queue!(
3402-
self.stdout,
3403-
StyledText::reset(),
3404-
style::Print(" from mcp server "),
3405-
StyledText::emphasis_fg(),
3406-
style::Print(&tool.server_name),
3407-
StyledText::reset(),
3408-
)?;
3409-
}
3410-
3411-
execute!(
3412-
self.stdout,
3413-
style::Print("\n"),
3414-
style::Print(CONTINUATION_LINE),
3415-
style::Print("\n"),
3416-
style::Print(TOOL_BULLET)
3417-
)?;
34183393
}
34193394

34203395
tool_use

crates/chat-cli/src/cli/chat/parse.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ fn bulleted_item<'a, 'b>(
238238
return Err(ErrMode::from_error_kind(i, ErrorKind::Fail));
239239
}
240240

241-
let ws = (space0, alt(("-", "*")), space1).parse_next(i)?.0;
242-
let print = format!("{ws} ");
241+
let (ws, bullet_char, _) = (space0, alt(("-", "*")), space1).parse_next(i)?;
242+
let print = format!("{ws}{bullet_char} ");
243243

244244
queue_newline_or_advance(&mut o, state, print.width())?;
245245
queue(&mut o, style::Print(print))
@@ -296,7 +296,7 @@ fn code<'a, 'b>(
296296
let out = code.replace("&amp;", "&").replace("&gt;", ">").replace("&lt;", "<");
297297

298298
queue_newline_or_advance(&mut o, state, out.width())?;
299-
queue(&mut o, StyledText::success_fg())?;
299+
queue(&mut o, StyledText::brand_fg())?;
300300
queue(&mut o, style::Print(out))?;
301301
queue(&mut o, StyledText::reset())
302302
}
@@ -572,7 +572,7 @@ fn codeblock_begin<'a, 'b>(
572572
queue(&mut o, style::Print(format!("{language}\n").bold()))?;
573573
}
574574

575-
queue(&mut o, StyledText::success_fg())?;
575+
queue(&mut o, StyledText::brand_fg())?;
576576

577577
Ok(())
578578
}
@@ -709,12 +709,12 @@ mod tests {
709709
style::SetAttribute(Attribute::Bold),
710710
style::Print("java\n"),
711711
StyledText::reset_attributes(),
712-
StyledText::success_fg(),
712+
StyledText::brand_fg(),
713713
style::Print("hello world!"),
714714
StyledText::reset(),
715715
]);
716716
validate!(code_1, "`print`", [
717-
StyledText::success_fg(),
717+
StyledText::brand_fg(),
718718
style::Print("print"),
719719
StyledText::reset(),
720720
]);
@@ -756,8 +756,8 @@ mod tests {
756756
style::SetAttribute(Attribute::Bold),
757757
style::Print("# Hello World"),
758758
]);
759-
validate!(bulleted_item_1, "- bullet", [style::Print(" bullet")]);
760-
validate!(bulleted_item_2, "* bullet", [style::Print(" bullet")]);
759+
validate!(bulleted_item_1, "- bullet", [style::Print("- bullet")]);
760+
validate!(bulleted_item_2, "* bullet", [style::Print("* bullet")]);
761761
validate!(numbered_item_1, "1. number", [style::Print("1. number")]);
762762
validate!(blockquote_1, "> hello", [
763763
StyledText::secondary_fg(),

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,23 @@ impl ExecuteCommand {
158158
}
159159

160160
pub fn queue_description(&self, output: &mut impl Write) -> Result<()> {
161-
queue!(output, style::Print("I will run the following shell command: "),)?;
162-
163-
// TODO: Could use graphemes for a better heuristic
164-
if self.command.len() > 20 {
165-
queue!(output, style::Print("\n"),)?;
166-
}
167-
161+
queue!(output, style::Print("I will run the following command: "),)?;
168162
queue!(
169163
output,
170-
StyledText::success_fg(),
164+
StyledText::brand_fg(),
171165
style::Print(&self.command),
172-
style::Print("\n"),
173166
StyledText::reset(),
167+
style::Print("\n"),
174168
)?;
175169

176-
// Add the summary if available
170+
// Add the summary as purpose if available on a separate line
177171
if let Some(ref summary) = self.summary {
178-
super::display_purpose(Some(summary), output)?;
172+
queue!(
173+
output,
174+
style::Print("Purpose: "),
175+
style::Print(summary),
176+
style::Print("\n"),
177+
)?;
179178
}
180179

181180
queue!(output, style::Print("\n"))?;

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl FsRead {
8484
queue!(
8585
updates,
8686
style::Print("Batch fs_read operation with "),
87-
StyledText::success_fg(),
87+
StyledText::brand_fg(),
8888
style::Print(self.operations.len()),
8989
StyledText::reset(),
9090
style::Print(" operations:\n")
@@ -425,7 +425,7 @@ impl FsImage {
425425
queue!(
426426
updates,
427427
style::Print("Reading images: "),
428-
StyledText::success_fg(),
428+
StyledText::brand_fg(),
429429
style::Print(&self.image_paths.join("\n")),
430430
style::Print("\n"),
431431
StyledText::reset(),
@@ -466,7 +466,7 @@ impl FsLine {
466466
queue!(
467467
updates,
468468
style::Print("Reading file: "),
469-
StyledText::success_fg(),
469+
StyledText::brand_fg(),
470470
style::Print(&self.path),
471471
StyledText::reset(),
472472
style::Print(", "),
@@ -479,19 +479,19 @@ impl FsLine {
479479
_ if end == line_count => Ok(queue!(
480480
updates,
481481
style::Print("from line "),
482-
StyledText::success_fg(),
482+
StyledText::brand_fg(),
483483
style::Print(start),
484484
StyledText::reset(),
485485
style::Print(" to end of file"),
486486
)?),
487487
_ => Ok(queue!(
488488
updates,
489489
style::Print("from line "),
490-
StyledText::success_fg(),
490+
StyledText::brand_fg(),
491491
style::Print(start),
492492
StyledText::reset(),
493493
style::Print(" to "),
494-
StyledText::success_fg(),
494+
StyledText::brand_fg(),
495495
style::Print(end),
496496
StyledText::reset(),
497497
)?),
@@ -595,11 +595,11 @@ impl FsSearch {
595595
queue!(
596596
updates,
597597
style::Print("Searching: "),
598-
StyledText::success_fg(),
598+
StyledText::brand_fg(),
599599
style::Print(&self.path),
600600
StyledText::reset(),
601601
style::Print(" for pattern: "),
602-
StyledText::success_fg(),
602+
StyledText::brand_fg(),
603603
style::Print(&self.pattern.to_lowercase()),
604604
StyledText::reset(),
605605
)?;
@@ -691,7 +691,7 @@ impl FsDirectory {
691691
queue!(
692692
updates,
693693
style::Print("Reading directory: "),
694-
StyledText::success_fg(),
694+
StyledText::brand_fg(),
695695
style::Print(&self.path),
696696
StyledText::reset(),
697697
style::Print(" "),
@@ -784,16 +784,14 @@ impl FsDirectory {
784784
);
785785
}
786786

787-
super::queue_function_result(
788-
&format!(
789-
"Successfully read directory {} ({} entries)",
790-
&path.display(),
791-
file_count
792-
),
793-
updates,
794-
false,
795-
false,
796-
)?;
787+
// Format the message with brand color for the path
788+
let formatted_message = format!(
789+
"Successfully read directory {} ({} entries)",
790+
StyledText::brand(&path.display().to_string()),
791+
file_count
792+
);
793+
794+
super::queue_function_result(&formatted_message, updates, false, false)?;
797795

798796
Ok(InvokeOutput {
799797
output: OutputKind::Text(result),

0 commit comments

Comments
 (0)