Files
hermes-webui/tests/test_issue3539_language_dropdown_all_locales.py
nesquena-hermes 163df17410
Some checks failed
Release & Docker / release (push) Has been cancelled
Release v0.51.262 — Release ID (stage-r12) (#3617)
## Release v0.51.262 — Release ID (stage-r12)

Phase-3 light slice (no-screenshot items) — 3 PRs.

### Fixed
| Issue/PR | Author | Fix |
|----------|--------|-----|
| #3432 (#3532) | @franksong2702 | Normalize the recall-prefill terminal `user` turn so WebUI doesn't send adjacent `user` roles to strict chat templates (Mistral/Gemma/Jinja). `_normalize_prefill_messages_before_user_turn()` in both `streaming.py` + `gateway_chat.py`; drops only the terminal user tail, preserves assistant/system/mid-list context. **Rebased onto master** (was CONFLICTING). |
| #2558 (#3516) | @rodboev | "Reveal in file manager" now translates container workspace paths (`/workspace`) back to the host mount path for Docker deployments (traversal-safe via `safe_resolve` + sibling-prefix guard). |

### Changed
| Issue/PR | Author | Change |
|----------|--------|--------|
| (#3539) | @Lyr-GW | Completed the Chinese (Simplified) `zh` localization (MCP controls, tool-list pagination) with all interpolations preserved, and the language dropdown now applies the locale **instantly** on change. |

### Review fix absorbed (Codex)
#3539 also added an `allowed=['en','zh']` filter to the Settings language dropdown, which dropped the 9 other shipped locales (it/ja/ru/es/de/pt/ko/fr/tr) — and since save falls back to `en` when the select has no matching option, an existing user of those locales would be **silently reset to English** on a Settings save. Removed the filter (dropdown enumerates all `LOCALES` again, matching master); partially-translated locales fall back per-key to English at render. + regression test `test_issue3539_language_dropdown_all_locales.py`.

### Gate
- Full pytest suite: **7701 passed, 0 failed**
- ESLint: CLEAN · ruff: CLEAN · browser-smoke: CLEAN
- Codex (regression): SHIP-ONLY-WITH-FIXES (dropdown drops-locales) → fixed → **SAFE TO SHIP** (verified prefill drops only terminal user tail in both paths, Docker path-translation traversal-safe, zh interpolations preserved)

Co-authored-by: franksong2702 <franksong2702@users.noreply.github.com>
Co-authored-by: rodboev <rodboev@users.noreply.github.com>
Co-authored-by: Lyr-GW <Lyr-GW@users.noreply.github.com>
2026-06-04 17:16:31 -07:00

46 lines
2.2 KiB
Python

"""Regression: the Settings language dropdown must list ALL locales in LOCALES.
#3539 (zh localization) briefly added an `allowed=['en','zh']` filter to the
language `<select>` population in loadSettingsPanel(). Because saveSettings()
falls back to 'en' when the select has no matching option, that filter would
silently reset an existing it/ja/ru/es/de/pt/ko/fr/tr user to English on the
next Settings save. The dropdown must keep enumerating every LOCALES entry;
partially-translated locales fall back per-key to English at render time, which
is the established behavior — far better than dropping the user's choice.
"""
from pathlib import Path
PANELS_JS = (Path(__file__).resolve().parents[1] / "static" / "panels.js").read_text(encoding="utf-8")
def _language_dropdown_block() -> str:
# Anchor on the dropdown-population site (langSel.innerHTML='' precedes the
# LOCALES enumeration); there is an earlier settingsLanguage reference for
# the apply-on-load path, so don't anchor on the first match.
i = PANELS_JS.index("langSel.innerHTML=''")
return PANELS_JS[i:i + 700]
def test_language_dropdown_lists_all_locales_no_allowlist():
block = _language_dropdown_block()
# It must iterate every LOCALES entry...
assert "Object.entries(LOCALES)" in block, (
"the language dropdown must enumerate all LOCALES entries"
)
# ...with NO hardcoded allow-list filter that drops existing locales.
assert "allowed=[" not in block.replace(" ", "") and "allowed = [" not in block, (
"the language dropdown must NOT filter LOCALES to a hardcoded allow-list "
"(that silently resets existing non-en/zh users to English on save)"
)
assert "if(!allowed.includes(code))" not in block.replace(" ", ""), (
"no allow-list `continue` guard may skip locales in the dropdown"
)
def test_language_change_applies_locale_instantly():
"""#3539 keeper: changing the dropdown applies the locale live, not just on save."""
block = _language_dropdown_block()
assert "setLocale(this.value)" in block.replace(" ", "").replace("\n", "") or "setLocale(this.value)" in block, (
"language change should call setLocale() for instant apply"
)