From 051715b6cc687ef0e29e0e1f3dd265743eab3235 Mon Sep 17 00:00:00 2001 From: Bennet Fenner Date: Tue, 14 Oct 2025 15:02:03 +0200 Subject: [PATCH] acp: Hide completion menu when typing slash command argument (#40126) Release Notes: - acp: Fix an issue where the completion menu would still be active after confirming a slash command --- crates/agent_ui/src/acp/completion_provider.rs | 13 ++++++++++++- crates/agent_ui/src/acp/message_editor.rs | 17 +++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/agent_ui/src/acp/completion_provider.rs b/crates/agent_ui/src/acp/completion_provider.rs index 40ac1aae99704c2b800a5b6cb6ccc71c426dbbe9..684b8f2d0d764fe257e61124e217242ff6df29f3 100644 --- a/crates/agent_ui/src/acp/completion_provider.rs +++ b/crates/agent_ui/src/acp/completion_provider.rs @@ -775,7 +775,7 @@ impl CompletionProvider for ContextPickerCompletionProvider { } }); } - is_missing_argument + false } })), } @@ -910,6 +910,17 @@ impl CompletionProvider for ContextPickerCompletionProvider { offset_to_line, self.prompt_capabilities.borrow().embedded_context, ) + .filter(|completion| { + // Right now we don't support completing arguments of slash commands + let is_slash_command_with_argument = matches!( + completion, + ContextCompletion::SlashCommand(SlashCommandCompletion { + argument: Some(_), + .. + }) + ); + !is_slash_command_with_argument + }) .map(|completion| { completion.source_range().start <= offset_to_line + position.column as usize && completion.source_range().end >= offset_to_line + position.column as usize diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rs index fa636084657103beacce64a203195ae759885a56..da2f210f3fa24a812ae9f002129b025e44a57a13 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/acp/message_editor.rs @@ -2020,21 +2020,11 @@ mod tests { editor.update_in(&mut cx, |editor, _window, cx| { assert_eq!(editor.text(cx), "/say-hello "); assert_eq!(editor.display_text(cx), "/say-hello "); - assert!(editor.has_visible_completions_menu()); - - assert_eq!( - current_completion_labels_with_documentation(editor), - &[("say-hello".into(), "Say hello to whoever you want".into())] - ); + assert!(!editor.has_visible_completions_menu()); }); cx.simulate_input("GPT5"); - editor.update_in(&mut cx, |editor, window, cx| { - assert!(editor.has_visible_completions_menu()); - editor.confirm_completion(&editor::actions::ConfirmCompletion::default(), window, cx); - }); - cx.run_until_parked(); editor.update_in(&mut cx, |editor, window, cx| { @@ -2043,7 +2033,7 @@ mod tests { assert!(!editor.has_visible_completions_menu()); // Delete argument - for _ in 0..4 { + for _ in 0..5 { editor.backspace(&editor::actions::Backspace, window, cx); } }); @@ -2051,13 +2041,12 @@ mod tests { cx.run_until_parked(); editor.update_in(&mut cx, |editor, window, cx| { - assert_eq!(editor.text(cx), "/say-hello "); + assert_eq!(editor.text(cx), "/say-hello"); // Hint is visible because argument was deleted assert_eq!(editor.display_text(cx), "/say-hello "); // Delete last command letter editor.backspace(&editor::actions::Backspace, window, cx); - editor.backspace(&editor::actions::Backspace, window, cx); }); cx.run_until_parked();