Files
zed/crates
Zhiwei Liang 23decdeebf Refresh OpenRouter models after setting API key (#58551)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Summary

Adding an OpenRouter API key did not populate the model list until the
app was
restarted. `set_api_key` stored the credential but never triggered a
model
fetch, so until re-authentication happened (on restart or a settings
change)
the picker showed only the user-configured `settings.available_models`,
not the
models returned by the OpenRouter API.

This makes `set_api_key` refresh the models right after the key is
stored,
mirroring how `authenticate` already does it.

## Changes

- `set_api_key` awaits the credential store and then calls
`restart_fetch_models_task`, so the API model list loads immediately
after a
  key is entered (and is cleared when the key is removed).
- `fetch_models` now maps `list_models` errors via
`LanguageModelCompletionError::from`, preserving the real OpenRouter
error
  message instead of wrapping it in a generic `Other(...)`.

Release Notes:

- Fixed OpenRouter models not appearing until restart after adding an
API key

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
2026-06-04 16:03:35 +00:00
..
2026-05-27 10:31:53 +00:00
2026-05-27 10:31:53 +00:00
2026-06-03 15:50:50 +00:00
2026-05-04 06:30:47 +00:00
2026-04-29 10:27:47 +00:00
2026-06-03 15:50:50 +00:00
2026-05-04 06:30:47 +00:00
2026-04-29 10:27:47 +00:00
2026-05-27 10:31:53 +00:00
…
2026-05-27 10:31:53 +00:00
2026-05-26 07:09:47 +00:00
2026-06-01 20:48:05 +00:00
2026-04-29 10:27:47 +00:00
2026-05-27 10:31:53 +00:00
2026-05-27 10:31:53 +00:00
2026-05-27 10:31:53 +00:00
2026-06-01 20:48:05 +00:00