Escape markdown in tools' ui_text
(#27502)
Escape markdown in tools' `ui_text` <img width="628" alt="Screenshot 2025-03-26 at 10 43 23 AM" src="https://github.com/user-attachments/assets/bb694821-aae7-4ccf-a35a-a3317b0222d5" /> Release Notes: - N/A
This commit is contained in:
parent
82b0881dcb
commit
9eacac62a9
11 changed files with 108 additions and 86 deletions
|
@ -8,6 +8,7 @@ use serde::{Deserialize, Serialize};
|
|||
use std::sync::Arc;
|
||||
use ui::IconName;
|
||||
use util::command::new_smol_command;
|
||||
use util::markdown::MarkdownString;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct BashToolInput {
|
||||
|
@ -43,7 +44,14 @@ impl Tool for BashTool {
|
|||
|
||||
fn ui_text(&self, input: &serde_json::Value) -> String {
|
||||
match serde_json::from_value::<BashToolInput>(input.clone()) {
|
||||
Ok(input) => format!("`{}`", input.command),
|
||||
Ok(input) => {
|
||||
let cmd = MarkdownString::escape(&input.command);
|
||||
if input.command.contains('\n') {
|
||||
format!("```bash\n{cmd}\n```")
|
||||
} else {
|
||||
format!("`{cmd}`")
|
||||
}
|
||||
}
|
||||
Err(_) => "Run bash command".to_string(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue