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
7 changes: 3 additions & 4 deletions crates/agent/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,9 @@ impl NativeAgent {

for session in self.sessions.values_mut() {
session.thread.update(cx, |thread, cx| {
let should_update_model = thread.model().is_none()
|| (thread.is_empty()
&& matches!(event, language_model::Event::DefaultModelChanged));
if should_update_model && let Some(model) = default_model.clone() {
if thread.model().is_none()
&& let Some(model) = default_model.clone()
{
thread.set_model(model, cx);
cx.notify();
}
Expand Down
13 changes: 0 additions & 13 deletions crates/language_models/src/language_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,6 @@ pub fn init(user_store: Entity<UserStore>, client: Arc<Client>, cx: &mut App) {
);
});

cx.subscribe(

@bennetbo bennetbo Apr 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed this because it causes flickering issues, e.g. if multiple providers authenticate one after another. Instead we only want to update the fallback once after all authenticate tasks completed. And because the Zed provider now actually returns a task we can rely on only calling update_environment_fallback_model once all have authenticated

&registry,
|_registry, event: &language_model::Event, cx| match event {
language_model::Event::ProviderStateChanged(_)
| language_model::Event::AddedProvider(_)
| language_model::Event::RemovedProvider(_) => {
update_environment_fallback_model(cx);
}
_ => {}
},
)
.detach();

let registry = registry.downgrade();
cx.observe_global::<SettingsStore>(move |cx| {
let Some(registry) = registry.upgrade() else {
Expand Down
17 changes: 14 additions & 3 deletions crates/language_models/src/provider/cloud.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ai_onboarding::YoungAccountBanner;
use anyhow::Result;
use client::Status;
use client::{Client, RefreshLlmTokenListener, UserStore, global_llm_token, zed_urls};
use cloud_api_client::LlmApiToken;
use cloud_api_types::OrganizationId;
Expand Down Expand Up @@ -249,11 +250,21 @@ impl LanguageModelProvider for CloudLanguageModelProvider {

fn is_authenticated(&self, cx: &App) -> bool {
let state = self.state.read(cx);
!state.is_signed_out(cx)
let status = *state.client.status().borrow();
matches!(status, Status::Authenticated | Status::Connected { .. })
}

fn authenticate(&self, _cx: &mut App) -> Task<Result<(), AuthenticateError>> {
Task::ready(Ok(()))
fn authenticate(&self, cx: &mut App) -> Task<Result<(), AuthenticateError>> {
let mut status = self.state.read(cx).client.status();
if !status.borrow().is_signing_in() {
return Task::ready(Ok(()));
}
cx.background_spawn(async move {
while status.borrow().is_signing_in() {
status.next().await;
}
Ok(())
})
}

fn configuration_view(
Expand Down
Loading