Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
assist panel: Update Zed AI notice if provider changes (#15805)
Thorsten Ball294892c470d7
diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rsindex 5a31199312e..d04ae6e3b77 100644--- a/crates/assistant/src/assistant_panel.rs+++ b/crates/assistant/src/assistant_panel.rs@@ -146,6 +146,7 @@ pub struct AssistantPanel {model_summary_editor: View<Editor>,authenticate_provider_task: Option<(LanguageModelProviderId, Task<()>)>,configuration_subscription: Option<Subscription>,+ client_status: Option<client::Status>,watch_client_status: Option<Task<()>>,show_zed_ai_notice: bool,}@@ -435,6 +436,7 @@ impl AssistantPanel {model_summary_editor,authenticate_provider_task: None,configuration_subscription: None,+ client_status: None,watch_client_status: Some(watch_client_status),show_zed_ai_notice: false,};@@ -446,18 +448,18 @@ impl AssistantPanel {let mut status_rx = client.status();cx.spawn(|this, mut cx| async move {- let mut old_status = None;while let Some(status) = status_rx.next().await {- if old_status.is_none()- || old_status.map_or(false, |old_status| old_status != status)- {- this.update(&mut cx, |this, cx| {- this.handle_client_status_change(status, cx)- })- .log_err();-- old_status = Some(status);- }+ this.update(&mut cx, |this, cx| {+ if this.client_status.is_none()+ || this+ .client_status+ .map_or(false, |old_status| old_status != status)+ {+ this.update_zed_ai_notice_visibility(status, cx);+ }+ this.client_status = Some(status);+ })+ .log_err();}this.update(&mut cx, |this, _cx| this.watch_client_status = None).log_err();@@ -554,7 +556,11 @@ impl AssistantPanel {}}- fn handle_client_status_change(&mut self, client_status: Status, cx: &mut ViewContext<Self>) {+ fn update_zed_ai_notice_visibility(+ &mut self,+ client_status: Status,+ cx: &mut ViewContext<Self>,+ ) {let active_provider = LanguageModelRegistry::read_global(cx).active_provider();// If we're signed out and don't have a provider configured, or we're signed-out AND Zed.dev is@@ -642,6 +648,10 @@ impl AssistantPanel {self.authenticate_provider_task = None;self.ensure_authenticated(cx);}++ if let Some(status) = self.client_status {+ self.update_zed_ai_notice_visibility(status, cx);+ }}fn ensure_authenticated(&mut self, cx: &mut ViewContext<Self>) {