Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Allow clicking on the read file tool header to jump to the exact file location (#33161)
Max Frai089ce8f6aa1e
diff --git a/crates/assistant_tools/src/read_file_tool.rs b/crates/assistant_tools/src/read_file_tool.rsindex 5b954698173..6bbc2fc0897 100644--- a/crates/assistant_tools/src/read_file_tool.rs+++ b/crates/assistant_tools/src/read_file_tool.rs@@ -18,7 +18,6 @@ use serde::{Deserialize, Serialize};use settings::Settings;use std::sync::Arc;use ui::IconName;-use util::markdown::MarkdownInlineCode;/// If the model requests to read a file whose size exceeds this, then#[derive(Debug, Serialize, Deserialize, JsonSchema)]@@ -78,11 +77,21 @@ impl Tool for ReadFileTool {fn ui_text(&self, input: &serde_json::Value) -> String {match serde_json::from_value::<ReadFileToolInput>(input.clone()) {Ok(input) => {- let path = MarkdownInlineCode(&input.path);+ let path = &input.path;match (input.start_line, input.end_line) {- (Some(start), None) => format!("Read file {path} (from line {start})"),- (Some(start), Some(end)) => format!("Read file {path} (lines {start}-{end})"),- _ => format!("Read file {path}"),+ (Some(start), Some(end)) => {+ format!(+ "[Read file `{}` (lines {}-{})](@selection:{}:({}-{}))",+ path, start, end, path, start, end+ )+ }+ (Some(start), None) => {+ format!(+ "[Read file `{}` (from line {})](@selection:{}:({}-{}))",+ path, start, path, start, start+ )+ }+ _ => format!("[Read file `{}`](@file:{})", path, path),}}Err(_) => "Read file".to_string(),