mirror of
https://github.com/zed-industries/zed.git
synced 2026-04-18 07:47:53 +00:00
e92a40a9d8
Reimplements #36722 while fixing the race that required the revert in #36932. When no default model is configured, this picks an environment fallback by authenticating all providers. It always prefers the Zed cloud provider when it's authenticated, and waits for its models to load before picking another provider as the fallback, so we don't flicker from Zed models to Anthropic while sign-in is in flight. The fallback is recomputed whenever provider state changes (via `ProviderStateChanged`/`AddedProvider`/`RemovedProvider` events), so the selection becomes correct as soon as cloud models arrive. ### What changed vs. the original PR - `language_models::init` now owns `authenticate_all_providers` (previously done in `LanguageModelPickerDelegate` and `agent`'s `LanguageModels`). - After all authentications settle, and on any subsequent provider state change, `update_environment_fallback_model` recomputes the fallback. - The fallback logic prefers Zed cloud: if the cloud provider is authenticated, only use it (waiting for its models to load). Otherwise, fall through to the first authenticated provider with a default or recommended model. - `LanguageModelRegistry::default_model()` falls back to `environment_fallback_model` when no explicit default is set. - Existing `Thread`s that are empty are updated to the new default when `DefaultModelChanged` fires, so a blank thread started before sign-in switches to Zed models once the user signs in. Release Notes: - agent: Automatically select a model when there's no selected model or configured default