Fix _normalizeConfiguredModelKey in frontend to match backend behavior#1474
Conversation
The JavaScript _normalizeConfiguredModelKey function had the same bug as the Python _norm_model_id function that was fixed in commit d6164cd. It used substring(indexOf(':')+1) which only removes the first colon-separated segment, leaving provider names in the normalized model ID. For example, '@Custom:jingdong:GLM-5' became 'jingdong:glm.5' instead of 'glm.5'. This caused duplicate Primary badges to appear in the model dropdown when using custom providers with @Provider:model ID format. Changes: - Replace substring(indexOf(':')+1) with split(':').pop() to strip all colon prefixes - Add provider name to badge label for clarity (e.g., 'Primary (jingdong)')
|
Thanks for the matching frontend follow-up — the diagnosis is correct and the JS/Python normalizers should stay in lock-step. One concern with the proposed fix that mirrors the same issue I just flagged on the backend PR (#1454):
That collapses every A more conservative shape that handles if(s.startsWith('@')&&s.includes(':')){
const parts=s.split(':');
// @custom:<provider>:<model...> → strip both prefix segments
if(parts.length>=3 && parts[0]==='@custom'){
s=parts.slice(2).join(':');
} else {
// @<provider>:<model...> → strip only the @provider segment
s=parts.length===2 ? parts[1] : parts.slice(1).join(':');
}
}This needs to land together with the backend fix in #1454 — they have to use the exact same algorithm, or the badge map keys (built server-side) won't match the lookup keys (built client-side). Whichever shape we converge on in #1454, mirror it here verbatim. Bonus badge label changeThe
TestsThis is renderer-pipeline glue + a normalizer tweak — both should have a targeted Python/JS test:
Labelling bug + frontend + needs-rework. Please rebase against #1454 once that lands and we converge on the algorithm. |
5650d11
…w-up - CHANGELOG.md: v0.50.267 entry detailing nesquena#1454/nesquena#1474/nesquena#1461/nesquena#1465/nesquena#1467/nesquena#1460/nesquena#1473 + Opus advisor SHOULD-FIX trailing-empty guard for _norm_model_id - ROADMAP.md: bump to v0.50.267, 3776 tests collected - TESTING.md: bump header + total to 3776 - api/config.py: trailing-empty fallback in _norm_model_id (parts[-1] or s) - static/ui.js: mirror trailing-empty fallback in _normalizeConfiguredModelKey - tests/test_norm_model_id_trailing_empty_guard.py: 5 regression tests
Summary
This PR fixes the same bug in the JavaScript frontend that was fixed in the Python backend in commit #d6164cd.
Problem
The JavaScript
_normalizeConfiguredModelKeyfunction usedsubstring(indexOf(:)+1)which only removes the first colon-separated segment, leaving provider names in the normalized model ID.For example,
@custom:jingdong:GLM-5becamejingdong:glm.5instead ofglm.5.This caused:
Solution
Replace
substring(indexOf(:)+1)withsplit(:).pop()to match the Python backend behavior and strip all colon prefixes.Bonus
Added provider name to badge label for clarity (e.g.,
"Primary (jingdong)"instead of just"Primary").Testing
@custom:jingdong:GLM-5format model IDsRelated