From 0282c3a9813725b443df694d3045adce7fee0b66 Mon Sep 17 00:00:00 2001 From: David Soria Parra <167242713+dsp-ant@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:10:36 -0700 Subject: [PATCH] context_server: Fix arguments handling (#17478) We accidentally do not accept prompts with an empty list of arguments, as opposed to non given arguments list. We need to allow these. We also not really supporting non required arguments, despite the protocol describing it. This is a first iteration on fixing this as well. Release Notes: - N/A --- .../src/slash_command/context_server_command.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/assistant/src/slash_command/context_server_command.rs b/crates/assistant/src/slash_command/context_server_command.rs index 027a6baf2b..8ae9430a99 100644 --- a/crates/assistant/src/slash_command/context_server_command.rs +++ b/crates/assistant/src/slash_command/context_server_command.rs @@ -44,10 +44,9 @@ impl SlashCommand for ContextServerSlashCommand { } fn requires_argument(&self) -> bool { - self.prompt - .arguments - .as_ref() - .map_or(false, |args| !args.is_empty()) + self.prompt.arguments.as_ref().map_or(false, |args| { + args.iter().any(|arg| arg.required == Some(true)) + }) } fn complete_argument( @@ -179,6 +178,8 @@ fn prompt_arguments(prompt: &PromptInfo, arguments: &[String]) -> Result Result bool { match &prompt.arguments { None => true, - Some(args) if args.len() == 1 => true, + Some(args) if args.len() <= 1 => true, _ => false, } }