From 20cc23c9bdea0ccb0ee18e8952fee3e105cdc9c7 Mon Sep 17 00:00:00 2001 From: WasserEsser Date: Thu, 4 Jun 2026 19:17:37 +0200 Subject: [PATCH] fix(models): make pinned models visible in chat UI (#2481) Two bugs prevented pinned models from appearing in the chat model picker: 1. _fetch_models() only used _cached_model_ids(), ignoring pinned_models. Since Fireworks AI doesn't list kimi-k2p6-turbo in /v1/models, the cached list was empty, so the endpoint showed as offline with no models. 2. _curate_models() filtered unknown pinned IDs into models_extra, but the chat UI only reads models (primary list). Pinned models stayed invisible. Fix: use _visible_models() to merge cached + pinned, then promote pinned IDs from models_extra to models so they appear in the dropdown. Closes #1521 follow-up --- routes/model_routes.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/routes/model_routes.py b/routes/model_routes.py index ac025ad..30c6562 100644 --- a/routes/model_routes.py +++ b/routes/model_routes.py @@ -1029,12 +1029,13 @@ def setup_model_routes(model_discovery): for ep in endpoints: base = _normalize_base(ep.base_url) provider = _detect_provider(base) - # Use cached models — background refresh keeps them updated - model_ids = _cached_model_ids(ep) + # Merge cached + pinned models, then filter out hidden ones ep_model_type = getattr(ep, "model_type", None) or "llm" - # Filter out hidden (probe-failed) models - hidden = _hidden_model_ids(ep) - model_ids = [m for m in model_ids if m not in hidden] + model_ids = _visible_models( + _cached_model_ids(ep), + ep.hidden_models, + getattr(ep, "pinned_models", None), + ) # Build correct URL based on provider chat_url = build_chat_url(base) kind = _effective_endpoint_kind(ep, base) @@ -1043,6 +1044,13 @@ def setup_model_routes(model_discovery): if model_ids: curated_key = _match_provider_curated(base, None) curated, extra = _curate_models(model_ids, curated_key) + # Pinned models are admin-selected — they always belong in the + # primary curated list, not buried in extras. + pinned = _normalize_model_ids(getattr(ep, "pinned_models", None)) + for m in pinned: + if m not in curated: + curated.append(m) + extra = [m for m in extra if m not in pinned] items.append({ "host": "custom", "port": 0,