acp: Model-specific prompt capabilities for 1PA (#36879)

Adds support for per-session prompt capabilities and capability changes
on the Zed side (ACP itself still only has per-connection static
capabilities for now), and uses it to reflect image support accurately
in 1PA threads based on the currently-selected model.

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-08-25 14:28:11 -04:00 committed by GitHub
parent f1204dfc33
commit 5fd29d37a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 98 additions and 53 deletions

View file

@ -373,7 +373,7 @@ impl MessageEditor {
if Img::extensions().contains(&extension) && !extension.contains("svg") {
if !self.prompt_capabilities.get().image {
return Task::ready(Err(anyhow!("This agent does not support images yet")));
return Task::ready(Err(anyhow!("This model does not support images yet")));
}
let task = self
.project

View file

@ -474,7 +474,7 @@ impl AcpThreadView {
let action_log = thread.read(cx).action_log().clone();
this.prompt_capabilities
.set(connection.prompt_capabilities());
.set(thread.read(cx).prompt_capabilities());
let count = thread.read(cx).entries().len();
this.list_state.splice(0..0, count);
@ -1163,6 +1163,10 @@ impl AcpThreadView {
});
}
}
AcpThreadEvent::PromptCapabilitiesUpdated => {
self.prompt_capabilities
.set(thread.read(cx).prompt_capabilities());
}
AcpThreadEvent::TokenUsageUpdated => {}
}
cx.notify();
@ -5367,6 +5371,12 @@ pub(crate) mod tests {
project,
action_log,
SessionId("test".into()),
watch::Receiver::constant(acp::PromptCapabilities {
image: true,
audio: true,
embedded_context: true,
}),
cx,
)
})))
}
@ -5375,14 +5385,6 @@ pub(crate) mod tests {
&[]
}
fn prompt_capabilities(&self) -> acp::PromptCapabilities {
acp::PromptCapabilities {
image: true,
audio: true,
embedded_context: true,
}
}
fn authenticate(
&self,
_method_id: acp::AuthMethodId,

View file

@ -1529,6 +1529,7 @@ impl AgentDiff {
| AcpThreadEvent::TokenUsageUpdated
| AcpThreadEvent::EntriesRemoved(_)
| AcpThreadEvent::ToolAuthorizationRequired
| AcpThreadEvent::PromptCapabilitiesUpdated
| AcpThreadEvent::Retry(_) => {}
}
}