Allow completing slash command arguments from extensions (#13240)

This PR extends the extension API with support for completing slash
command arguments for slash commands defined in extensions.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-06-18 17:58:57 -04:00 committed by GitHub
parent ad4e52842c
commit db0d843fb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 90 additions and 19 deletions

View file

@ -108,7 +108,16 @@ pub trait Extension: Send + Sync {
None
}
/// Runs the given slash command.
/// Returns the completions that should be shown when completing the provided slash command with the given query.
fn complete_slash_command_argument(
&self,
_command: SlashCommand,
_query: String,
) -> Result<Vec<String>, String> {
Ok(Vec::new())
}
/// Returns the output from running the provided slash command.
fn run_slash_command(
&self,
_command: SlashCommand,
@ -225,6 +234,13 @@ impl wit::Guest for Component {
Ok(labels)
}
fn complete_slash_command_argument(
command: SlashCommand,
query: String,
) -> Result<Vec<String>, String> {
extension().complete_slash_command_argument(command, query)
}
fn run_slash_command(
command: SlashCommand,
argument: Option<String>,