mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 04:44:30 +00:00
context_servers: Add ability to provide labels for prompt outputs (#17077)
Server can now include an optional description in a `prompts/get` response. Zed will displayed the description as label of the slash command. Release Notes: - context_servers: Servers can provide an optional description in `prompts/get` responses that is displayed as the slash command label.
This commit is contained in:
parent
4b6cd60b89
commit
cf0a8a7a1a
3 changed files with 10 additions and 5 deletions
|
@ -84,11 +84,15 @@ impl SlashCommand for ContextServerSlashCommand {
|
||||||
|
|
||||||
Ok(SlashCommandOutput {
|
Ok(SlashCommandOutput {
|
||||||
sections: vec![SlashCommandOutputSection {
|
sections: vec![SlashCommandOutputSection {
|
||||||
range: 0..result.len(),
|
range: 0..(result.prompt.len()),
|
||||||
icon: IconName::ZedAssistant,
|
icon: IconName::ZedAssistant,
|
||||||
label: SharedString::from(format!("Result from {}", prompt_name)),
|
label: SharedString::from(
|
||||||
|
result
|
||||||
|
.description
|
||||||
|
.unwrap_or(format!("Result from {}", prompt_name)),
|
||||||
|
),
|
||||||
}],
|
}],
|
||||||
text: result,
|
text: result.prompt,
|
||||||
run_commands_in_text: false,
|
run_commands_in_text: false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl InitializedContextServerProtocol {
|
||||||
&self,
|
&self,
|
||||||
prompt: P,
|
prompt: P,
|
||||||
arguments: HashMap<String, String>,
|
arguments: HashMap<String, String>,
|
||||||
) -> Result<String> {
|
) -> Result<types::PromptsGetResponse> {
|
||||||
self.check_capability(ServerCapability::Prompts)?;
|
self.check_capability(ServerCapability::Prompts)?;
|
||||||
|
|
||||||
let params = types::PromptsGetParams {
|
let params = types::PromptsGetParams {
|
||||||
|
@ -125,7 +125,7 @@ impl InitializedContextServerProtocol {
|
||||||
.request(types::RequestType::PromptsGet.as_str(), params)
|
.request(types::RequestType::PromptsGet.as_str(), params)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(response.prompt)
|
Ok(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,7 @@ pub struct ResourcesListResponse {
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct PromptsGetResponse {
|
pub struct PromptsGetResponse {
|
||||||
|
pub description: Option<String>,
|
||||||
pub prompt: String,
|
pub prompt: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue