assistant panel: Fix panel not reloading after entering credentials (#15531)

This is the revised version of #15527.

We also added new events to notify subscribers when new providers are
added or removed.

Co-Authored-by: Thorsten <thorsten@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This commit is contained in:
Bennet Bo Fenner 2024-07-31 14:12:17 +02:00 committed by GitHub
parent a31dba9fc1
commit 821ce2fc7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 119 additions and 68 deletions

View file

@ -89,7 +89,20 @@ pub trait LanguageModelProvider: 'static {
}
pub trait LanguageModelProviderState: 'static {
fn subscribe<T: 'static>(&self, cx: &mut gpui::ModelContext<T>) -> Option<gpui::Subscription>;
type ObservableEntity;
fn observable_entity(&self) -> Option<gpui::Model<Self::ObservableEntity>>;
fn subscribe<T: 'static>(
&self,
cx: &mut gpui::ModelContext<T>,
callback: impl Fn(&mut T, &mut gpui::ModelContext<T>) + 'static,
) -> Option<gpui::Subscription> {
let entity = self.observable_entity()?;
Some(cx.observe(&entity, move |this, _, cx| {
callback(this, cx);
}))
}
}
#[derive(Clone, Eq, PartialEq, Hash, Debug, Ord, PartialOrd)]