Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fetch models right after signing in (#35711)
Antonio Scandurra6f5867fc886a
diff --git a/crates/language_models/src/provider/cloud.rs b/crates/language_models/src/provider/cloud.rsindex 134b2bef6c7..40dd1207611 100644--- a/crates/language_models/src/provider/cloud.rs+++ b/crates/language_models/src/provider/cloud.rs@@ -136,6 +136,7 @@ impl State {cx: &mut Context<Self>,) -> Self {let refresh_llm_token_listener = RefreshLlmTokenListener::global(cx);+ let mut current_user = user_store.read(cx).watch_current_user();Self {client: client.clone(),llm_api_token: LlmApiToken::default(),@@ -151,22 +152,14 @@ impl State {let (client, llm_api_token) = this.read_with(cx, |this, _cx| (client.clone(), this.llm_api_token.clone()))?;- loop {- let is_authenticated = user_store- .read_with(cx, |user_store, _cx| user_store.current_user().is_some())?;- if is_authenticated {- break;- }-- cx.background_executor()- .timer(Duration::from_millis(100))- .await;+ while current_user.borrow().is_none() {+ current_user.next().await;}- let response = Self::fetch_models(client, llm_api_token).await?;- this.update(cx, |this, cx| {- this.update_models(response, cx);- })+ let response =+ Self::fetch_models(client.clone(), llm_api_token.clone()).await?;+ this.update(cx, |this, cx| this.update_models(response, cx))?;+ anyhow::Ok(())}).await.context("failed to fetch Zed models")