Disable /search by default (#20252)

Conrad Irwin created

This stops us sending GetCachedEmbeddings requests which frequently time
out
after 10s, and block the collab connection.

Release Notes:

- N/A

Change summary

crates/assistant/src/assistant.rs                    | 33 +++++++------
crates/assistant/src/slash_command/search_command.rs |  4 +
2 files changed, 22 insertions(+), 15 deletions(-)

Detailed changes

crates/assistant/src/assistant.rs 🔗

@@ -41,6 +41,7 @@ use prompts::PromptLoadingParams;
 use semantic_index::{CloudEmbeddingProvider, SemanticDb};
 use serde::{Deserialize, Serialize};
 use settings::{update_settings_file, Settings, SettingsStore};
+use slash_command::search_command::SearchSlashCommandFeatureFlag;
 use slash_command::{
     auto_command, cargo_workspace_command, context_server_command, default_command, delta_command,
     diagnostics_command, docs_command, fetch_command, file_command, now_command, project_command,
@@ -212,21 +213,23 @@ pub fn init(
         });
     }
 
-    cx.spawn(|mut cx| {
-        let client = client.clone();
-        async move {
-            let embedding_provider = CloudEmbeddingProvider::new(client.clone());
-            let semantic_index = SemanticDb::new(
-                paths::embeddings_dir().join("semantic-index-db.0.mdb"),
-                Arc::new(embedding_provider),
-                &mut cx,
-            )
-            .await?;
-
-            cx.update(|cx| cx.set_global(semantic_index))
-        }
-    })
-    .detach();
+    if cx.has_flag::<SearchSlashCommandFeatureFlag>() {
+        cx.spawn(|mut cx| {
+            let client = client.clone();
+            async move {
+                let embedding_provider = CloudEmbeddingProvider::new(client.clone());
+                let semantic_index = SemanticDb::new(
+                    paths::embeddings_dir().join("semantic-index-db.0.mdb"),
+                    Arc::new(embedding_provider),
+                    &mut cx,
+                )
+                .await?;
+
+                cx.update(|cx| cx.set_global(semantic_index))
+            }
+        })
+        .detach();
+    }
 
     context_store::init(&client.clone().into());
     prompt_library::init(cx);

crates/assistant/src/slash_command/search_command.rs 🔗

@@ -21,6 +21,10 @@ pub(crate) struct SearchSlashCommandFeatureFlag;
 
 impl FeatureFlag for SearchSlashCommandFeatureFlag {
     const NAME: &'static str = "search-slash-command";
+
+    fn enabled_for_staff() -> bool {
+        false
+    }
 }
 
 pub(crate) struct SearchSlashCommand;