Fully support all mention kinds (#36134)

Feature parity with the agent1 @mention kinds:
- File
- Symbols
- Selections
- Threads
- Rules
- Fetch


Release Notes:

- N/A

---------

Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
Agus Zubiaga 2025-08-13 17:11:32 -03:00 committed by GitHub
parent 389d382f42
commit 389d24d7e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 1787 additions and 324 deletions

View file

@ -399,7 +399,7 @@ impl ContentBlock {
}
}
let new_content = self.extract_content_from_block(block);
let new_content = self.block_string_contents(block);
match self {
ContentBlock::Empty => {
@ -409,7 +409,7 @@ impl ContentBlock {
markdown.update(cx, |markdown, cx| markdown.append(&new_content, cx));
}
ContentBlock::ResourceLink { resource_link } => {
let existing_content = Self::resource_link_to_content(&resource_link.uri);
let existing_content = Self::resource_link_md(&resource_link.uri);
let combined = format!("{}\n{}", existing_content, new_content);
*self = Self::create_markdown_block(combined, language_registry, cx);
@ -417,14 +417,6 @@ impl ContentBlock {
}
}
fn resource_link_to_content(uri: &str) -> String {
if let Some(uri) = MentionUri::parse(&uri).log_err() {
uri.to_link()
} else {
uri.to_string().clone()
}
}
fn create_markdown_block(
content: String,
language_registry: &Arc<LanguageRegistry>,
@ -436,11 +428,11 @@ impl ContentBlock {
}
}
fn extract_content_from_block(&self, block: acp::ContentBlock) -> String {
fn block_string_contents(&self, block: acp::ContentBlock) -> String {
match block {
acp::ContentBlock::Text(text_content) => text_content.text.clone(),
acp::ContentBlock::ResourceLink(resource_link) => {
Self::resource_link_to_content(&resource_link.uri)
Self::resource_link_md(&resource_link.uri)
}
acp::ContentBlock::Resource(acp::EmbeddedResource {
resource:
@ -449,13 +441,21 @@ impl ContentBlock {
..
}),
..
}) => Self::resource_link_to_content(&uri),
}) => Self::resource_link_md(&uri),
acp::ContentBlock::Image(_)
| acp::ContentBlock::Audio(_)
| acp::ContentBlock::Resource(_) => String::new(),
}
}
fn resource_link_md(uri: &str) -> String {
if let Some(uri) = MentionUri::parse(&uri).log_err() {
uri.as_link().to_string()
} else {
uri.to_string()
}
}
fn to_markdown<'a>(&'a self, cx: &'a App) -> &'a str {
match self {
ContentBlock::Empty => "",