Disable zeta predictions in assistant completion menu (#23573)

Agus Zubiaga created

We don't want the zeta predictions entry to show in the assistant
context editor when completing slash commands. Zeta will still make
suggestions in the rest of the context editor, like the other providers
do.

Release Notes:

- N/A

Change summary

crates/assistant_context_editor/src/context_editor.rs |  5 ++-
crates/editor/src/editor.rs                           | 19 ++++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)

Detailed changes

crates/assistant_context_editor/src/context_editor.rs 🔗

@@ -15,8 +15,8 @@ use editor::{
         CustomBlockId, FoldId, RenderBlock, ToDisplayPoint,
     },
     scroll::{Autoscroll, AutoscrollStrategy},
-    Anchor, Editor, EditorEvent, ProposedChangeLocation, ProposedChangesEditor, RowExt,
-    ToOffset as _, ToPoint,
+    Anchor, Editor, EditorEvent, MenuInlineCompletionsPolicy, ProposedChangeLocation,
+    ProposedChangesEditor, RowExt, ToOffset as _, ToPoint,
 };
 use editor::{display_map::CreaseId, FoldPlaceholder};
 use fs::Fs;
@@ -220,6 +220,7 @@ impl ContextEditor {
             editor.set_show_wrap_guides(false, cx);
             editor.set_show_indent_guides(false, cx);
             editor.set_completion_provider(Some(Box::new(completion_provider)));
+            editor.set_menu_inline_completions_policy(MenuInlineCompletionsPolicy::Never);
             editor.set_collaboration_hub(Box::new(project.clone()));
             editor
         });

crates/editor/src/editor.rs 🔗

@@ -507,6 +507,11 @@ struct InlineCompletionState {
 
 enum InlineCompletionHighlight {}
 
+pub enum MenuInlineCompletionsPolicy {
+    Never,
+    ByProvider,
+}
+
 #[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Debug, Default)]
 struct EditorActionId(usize);
 
@@ -678,6 +683,7 @@ pub struct Editor {
     // inline completions based on its mode.
     enable_inline_completions: bool,
     show_inline_completions_override: Option<bool>,
+    menu_inline_completions_policy: MenuInlineCompletionsPolicy,
     inlay_hint_cache: InlayHintCache,
     diff_map: DiffMap,
     next_inlay_id: usize,
@@ -1336,6 +1342,7 @@ impl Editor {
             editor_actions: Rc::default(),
             show_inline_completions_override: None,
             enable_inline_completions: true,
+            menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider,
             custom_context_menu: None,
             show_git_blame_gutter: false,
             show_git_blame_inline: false,
@@ -1757,6 +1764,10 @@ impl Editor {
         }
     }
 
+    pub fn set_menu_inline_completions_policy(&mut self, value: MenuInlineCompletionsPolicy) {
+        self.menu_inline_completions_policy = value;
+    }
+
     pub fn set_autoindent(&mut self, autoindent: bool) {
         if autoindent {
             self.autoindent_mode = Some(AutoindentMode::EachLine);
@@ -5037,7 +5048,13 @@ impl Editor {
     }
 
     fn show_inline_completions_in_menu(&self, cx: &AppContext) -> bool {
-        EditorSettings::get_global(cx).show_inline_completions_in_menu
+        let by_provider = matches!(
+            self.menu_inline_completions_policy,
+            MenuInlineCompletionsPolicy::ByProvider
+        );
+
+        by_provider
+            && EditorSettings::get_global(cx).show_inline_completions_in_menu
             && self
                 .inline_completion_provider()
                 .map_or(false, |provider| provider.show_completions_in_menu())