mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-22 00:20:23 +01:00
5255d9c721
## Summary When `disable_ai: true` is set, Zed still sent model-discovery HTTP requests to local providers at startup: constructing `LmStudioLanguageModelProvider` and `LlamaCppLanguageModelProvider` kicked off an eager fetch to `http://localhost:1234/api/v0/models` and `http://localhost:8080/v1/models` respectively, before any AI UI was opened. #66029 gated credential reads behind `ai_disabled`, but these discovery fetches read no credentials, so the probes kept firing. This gates `restart_fetch_models_task` in both providers on the existing `ai_disabled` helper, so no discovery request is made while AI is disabled. The gate covers the eager construction-time fetch, restarts on settings changes, and `refresh_models`, and clearing `fetch_model_task` cancels any fetch that is in flight when AI gets disabled mid-run. Once `disable_ai` is set to false, discovery resumes through the existing flows (opening the agent panel or the provider's settings page). Closes #66792 ## Testing - Added a regression test per provider (`does_not_fetch_models_when_ai_is_disabled`): with `disable_ai: true`, constructing the provider results in zero HTTP requests; after re-enabling AI, restarting discovery fetches models normally. - `cargo test -p language_models` - 132 passed, 0 failed (Linux). - `./script/clippy -p language_models` - clean. To verify manually: put a listener on the probed ports (`nc -lv 1234` and `nc -lv 8080`), launch Zed with `"disable_ai": true` in settings, and observe no connection is attempted at startup. Then set `disable_ai: false`, open the agent panel, and discovery connects. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). (This pr makes no UI changes.) - [x] Tests cover the new or changed behavior. Release Notes: - Fixed LM Studio and llama.cpp model discovery requests being sent at startup despite `disable_ai` being true