Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/edit_prediction/src/edit_prediction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2530,6 +2530,15 @@ impl EditPredictionStore {
allow_jump: bool,
cx: &mut Context<Self>,
) -> Task<Result<Option<EditPredictionResult>>> {
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);
Expand Down
24 changes: 14 additions & 10 deletions crates/edit_prediction/src/edit_prediction_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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]
Expand Down
Loading