diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index 8b57c442c22..84b2e8be1a8 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -2444,6 +2444,15 @@ impl EditPredictionStore { allow_jump: bool, cx: &mut Context, ) -> Task>> { + let is_cloud_zeta = matches!(self.edit_prediction_model, EditPredictionModel::Zeta) + && !matches!( + all_language_settings(None, cx).edit_predictions.provider, + EditPredictionProvider::Ollama | EditPredictionProvider::OpenAiCompatibleApi + ); + if is_cloud_zeta && !self.client.cloud_client().has_credentials() { + return Task::ready(Ok(None)); + } + self.get_or_init_project(&project, cx); let project_state = self.projects.get(&project.entity_id()).unwrap(); let stored_events = project_state.events(cx); diff --git a/crates/edit_prediction/src/edit_prediction_tests.rs b/crates/edit_prediction/src/edit_prediction_tests.rs index 86f218b401e..32da5397886 100644 --- a/crates/edit_prediction/src/edit_prediction_tests.rs +++ b/crates/edit_prediction/src/edit_prediction_tests.rs @@ -3107,11 +3107,18 @@ async fn test_unauthenticated_without_custom_url_blocks_prediction_impl(cx: &mut let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; - let http_client = FakeHttpClient::create(|_req| async move { - Ok(gpui::http_client::Response::builder() - .status(401) - .body("Unauthorized".into()) - .unwrap()) + let request_count = Arc::new(std::sync::atomic::AtomicUsize::default()); + let http_client = FakeHttpClient::create({ + let request_count = request_count.clone(); + move |_req| { + request_count.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + async move { + Ok(gpui::http_client::Response::builder() + .status(401) + .body("Unauthorized".into()) + .unwrap()) + } + } }); let client = @@ -3144,11 +3151,8 @@ async fn test_unauthenticated_without_custom_url_blocks_prediction_impl(cx: &mut ep_store.request_prediction(&project, &buffer, cursor, Default::default(), cx) }); - let result = completion_task.await; - assert!( - result.is_err(), - "Without authentication and without custom URL, prediction should fail" - ); + assert!(completion_task.await.unwrap().is_none()); + assert_eq!(request_count.load(std::sync::atomic::Ordering::SeqCst), 0); } #[gpui::test]