fix(models): stale cross-provider model no longer shows as unavailable in picker (closes #829)

* fix(models): stale cross-provider model no longer shows as unavailable in picker

Two bugs allowed an openai/gpt-5.4-mini stale session model to appear as
'(unavailable)' under a custom provider group for users who never configured
OpenAI (#829).

Backend (api/routes.py): _resolve_compatible_session_model() had a blanket
early-return for active_provider in {custom, openrouter} that skipped all
normalization regardless of whether any catalog group could route the model's
prefix. A custom_providers-only user with a stale openai/... session model
was never corrected. Fixed: only skip normalization when the model prefix is
actually routable (matches a catalog group provider_id, or an openrouter
group is present that can route any provider/model).

Frontend (static/ui.js): renderSession() injected a bare <option> (not in
any <optgroup>) for models not found in the dropdown. renderModelDropdown()
rendered bare options without emitting a group heading, so they visually
inherited the last rendered provider heading — making the stale model appear
to belong to the custom provider group. Fixed: silently reset to the first
available model and fire a PATCH to persist the correction instead of
injecting a misleading (unavailable) option.

5 new tests in test_provider_mismatch.py cover:
- stale openai model cleared when custom_providers-only + no default_model
- stale openai model cleared when custom_providers-only + default_model set
- openrouter model preserved when openrouter group present
- custom/ namespace always preserved
- ui.js no longer injects model_unavailable option

* fix(ui): declare modelSel locally in syncTopbar reset path; fix test assertion

- Use const modelSel=$('modelSelect') instead of undeclared sel in the
  stale-model reset branch of syncTopbar() (caught in Opus review)
- Fix test assertion: or → and for model_unavailable key absence check

---------

Co-authored-by: nesquena-hermes <nesquena-hermes@users.noreply.github.com>
This commit is contained in:
nesquena-hermes
2026-04-21 22:20:08 -07:00
committed by GitHub
parent 880085a09e
commit 1239129ae2
4 changed files with 190 additions and 13 deletions

View File

@@ -1,5 +1,20 @@
# Hermes Web UI -- Changelog
## [v0.50.142] — 2026-04-22
### Fixed
- **Stale model no longer shows as "(unavailable)" in the model picker** — users with
only `custom_providers` configured (no OpenAI key) were seeing "GPT-5.4 Mini (unavailable)"
appear in the picker, visually grouped under their custom provider section and selected
as the default model. Two root causes: (1) `_resolve_compatible_session_model()` in
`api/routes.py` had a blanket skip for `active_provider == "custom"` that prevented
stale cross-provider session models (e.g. `openai/gpt-5.4-mini` from a pre-v0.50 default)
from ever being cleaned up. Fixed to only skip normalization when the model's prefix is
actually routable by a group in the catalog. (2) `renderSession()` in `static/ui.js`
injected a bare `<option>` for unavailable models, which visually inherited the last
rendered provider heading in the picker due to missing `<optgroup>` context. Fixed to
silently reset to the first available model instead. Closes #829. (#831)
## [v0.50.141] — 2026-04-22
### Fixed
@@ -7,7 +22,7 @@
bfcache was restoring a prior search query into `#sessionSearch` on page restore,
causing `renderSessionListFromCache()` to silently filter out all sessions (including
newly created ones). Added `autocomplete="off"` to the search input and an explicit
value-clear at boot before the first render. Closes #822. (#829)
value-clear at boot before the first render. Closes #822. (#830)
## [v0.50.140] — 2026-04-22