mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-24 18:50:15 +00:00
6381ab1b8a
Supersedes contributor PR #1511 (lost9999), which removed the label-suffix logic in _deduplicate_model_ids() but left the underlying shared-reference bug intact — IDs would still be silently corrupted across provider groups, just with cleaner-looking labels. ## Bug shape When multiple unconfigured providers (Ollama / HuggingFace / custom endpoints / Google Gemini CLI / Xiaomi / etc.) all fell through to the 'else' branch in api/config.py:get_models_grouped() that ends with: groups.append({..., "models": auto_detected_models}) every group ended up sharing the SAME list reference AND the SAME dicts inside. When _deduplicate_model_ids() then mutated those dicts to add @provider_id: prefixes and provider-name parentheticals, the changes were applied to every group that referenced the same dict. Visible symptom: user 'vishnu' reported the dropdown showing 'Deepseek V4 Flash (Xiaomi) (Ollama) (HuggingFace) (Google-Gemini-Cli)' on every group. Hidden symptom (worse): the 'id' field collapsed to '@xiaomi:deepseek-v4-flash' on every group too, so clicking the entry under any group routed the request to Xiaomi. ## Fix api/config.py:2078 — wrap auto_detected_models in copy.deepcopy() at the groups.append site so each group gets its own independent dicts. The existing _deduplicate_model_ids() logic is correct and unchanged; the bug was in the assignment site, not the dedup function. The single-parenthetical disambiguation in labels is retained because the composer chip (composer-model-label) shows the model label without the optgroup header context — 'Deepseek V4 Flash (Ollama)' is more useful than ambiguous 'Deepseek V4 Flash' there. ## Tests tests/test_issue1511_dedup_shared_reference.py — 3 new tests: - test_groups_have_independent_model_lists: structural invariant pin - test_unconfigured_providers_no_shared_dedup_bleed: end-to-end against the corrected code path; verifies each group gets its own @provider_id: prefix and exactly ONE provider parenthetical per disambiguated label - test_shared_reference_pre_fix_demonstrates_corruption: documents the broken state that motivated the fix Full suite: 3925 → 3928 passing (+3 new, 0 regressions). Co-authored-by: lost9999 <56498264+lost9999@users.noreply.github.com>