mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-07-18 13:40:22 +00:00
e3a7c93dc6
* Harden interrupted recovery control filtering * Redesign live-to-final assistant replies * Fix live activity anchor test fixture * Fix CI lint issues for live reply tests * Strengthen live progress prompt contract * Recover PR #3401 refresh on origin/master * Repair live-to-final refresh regressions * Fix live worklog refresh regressions * Show live footer timer on initial stream start * Restore live stream shell after reload * Preserve per-frame live SSE replay cursors * Preserve reasoning as Worklog Thinking cards * Quiet Worklog Thinking card styling * Align Worklog Thinking card styling * Scope live Worklog Thinking cards by segment * Suppress exact duplicate settled Thinking * Close #3401 merge review test gaps * fix(#3401): resolve 4 deep-review regressions (inline-think, reconnect-dup, neon skin, busy-gate worklog) Deep review (Codex diff-vs-master + live-browser drive) of the live-to-final refactor surfaced 4 regressions vs master that the rewritten suite no longer guarded: 1. Inline <think>…</think>answer reasoning vanished — _assistantReasoningPayloadText used $-anchored regexes so a leading think block + visible answer extracted nothing and the Thinking card never rendered. Removed the 3 $ anchors to match the (non-anchored) display stripper. Live: inline-think thinking-only turn now renders. 2. (CORE) reconnect/reload duplicated the live reply — _rememberRunJournalCursor advanced a closure-local seq but never wrote INFLIGHT[activeSid].lastRunJournalSeq, so a reload replayed the journal from after_seq=0 over restored lastAssistantText. Now mirrors the cursor onto INFLIGHT + schedules a throttled persist. 3. Neon skin silently broke — PR deleted the :root[data-skin="neon"] CSS but left Neon in the picker. Restored the neon CSS block from master. 4. Settled tool-worklog rebuild gated purely on !S.busy — dropped every prior settled turn's worklog when renderMessages re-ran during an active stream (switch-back to an in-progress session). Restored master's !S.busy || (S.toolCalls && S.toolCalls.length). Live: busy re-render now preserves tool cards (4→4, was 4→0). Live-verified all 4 + confirmed #3709/#3592 invariants still hold (1 thinking card, none below footer; distinct siblings preserved). + tests/test_issue3401_deep_review_fixes.py (7). * test(#3401): realign 3 stale source-shape assertions to the deep-review fixes Fix commit changed two source literals that existing stage tests scanned for: - test_live_activity_timeline.py (x2): split anchor 'if(!S.busy){' → the restored 'if(!S.busy || (S.toolCalls&&S.toolCalls.length)){' guard (fix 4). - test_run_journal_frontend_static.py: 'after_seq=0' not in source — fix 2's comment contained that literal; rephrased the comment to 'the zero floor (after_seq of 0)'. Intent of all three assertions unchanged; only the matched string updated. No code behavior change. * docs(changelog): v0.51.294 — Release JJ (stage-3401, #3401 live-to-final redesign) --------- Co-authored-by: Frank Song <franksong2702@gmail.com> Co-authored-by: Nathan-Hermes <nesquena-hermes@users.noreply.github.com> Co-authored-by: nesquena-hermes <[email protected]>
168 lines
5.5 KiB
Python
168 lines
5.5 KiB
Python
"""Regression tests for #1240 — WebUI model catalog should delegate to Hermes CLI.
|
|
|
|
The WebUI picker should not freeze ordinary providers to its static
|
|
``_PROVIDER_MODELS`` snapshot when Hermes CLI can return a fresher provider
|
|
catalog. Static lists remain a fallback only.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import types
|
|
|
|
import api.config as config
|
|
import api.profiles as profiles
|
|
|
|
|
|
_PROVIDER_ENV_VARS = (
|
|
"ANTHROPIC_API_KEY",
|
|
"OPENAI_API_KEY",
|
|
"OPENROUTER_API_KEY",
|
|
"GOOGLE_API_KEY",
|
|
"GEMINI_API_KEY",
|
|
"GLM_API_KEY",
|
|
"KIMI_API_KEY",
|
|
"DEEPSEEK_API_KEY",
|
|
"XIAOMI_API_KEY",
|
|
"OPENCODE_ZEN_API_KEY",
|
|
"OPENCODE_GO_API_KEY",
|
|
"MINIMAX_API_KEY",
|
|
"MINIMAX_CN_API_KEY",
|
|
"XAI_API_KEY",
|
|
"MISTRAL_API_KEY",
|
|
"OLLAMA_CLOUD_API_KEY",
|
|
"OLLAMA_API_KEY",
|
|
"NOUS_API_KEY",
|
|
"NVIDIA_API_KEY",
|
|
)
|
|
|
|
|
|
def _scrub_provider_env(monkeypatch):
|
|
for name in _PROVIDER_ENV_VARS:
|
|
monkeypatch.delenv(name, raising=False)
|
|
|
|
|
|
def _install_fake_hermes_cli(monkeypatch, *, provider_id: str, live_ids, raise_on_lookup: bool = False):
|
|
"""Install a hermes_cli stub that reports one authenticated provider."""
|
|
fake_pkg = types.ModuleType("hermes_cli")
|
|
fake_pkg.__path__ = []
|
|
|
|
fake_models = types.ModuleType("hermes_cli.models")
|
|
fake_models.list_available_providers = lambda: [
|
|
{"id": provider_id, "authenticated": True}
|
|
]
|
|
|
|
calls: list[str] = []
|
|
|
|
def provider_model_ids(pid):
|
|
calls.append(pid)
|
|
if raise_on_lookup:
|
|
raise RuntimeError("simulated provider_model_ids failure")
|
|
return list(live_ids) if pid == provider_id else []
|
|
|
|
fake_models.provider_model_ids = provider_model_ids
|
|
|
|
fake_auth = types.ModuleType("hermes_cli.auth")
|
|
|
|
def get_auth_status(pid):
|
|
if pid == provider_id:
|
|
return {"logged_in": True, "key_source": ""}
|
|
return {"logged_in": False, "key_source": ""}
|
|
|
|
fake_auth.get_auth_status = get_auth_status
|
|
|
|
monkeypatch.setitem(sys.modules, "hermes_cli", fake_pkg)
|
|
monkeypatch.setitem(sys.modules, "hermes_cli.models", fake_models)
|
|
monkeypatch.setitem(sys.modules, "hermes_cli.auth", fake_auth)
|
|
monkeypatch.delitem(sys.modules, "agent.credential_pool", raising=False)
|
|
monkeypatch.delitem(sys.modules, "agent", raising=False)
|
|
config.invalidate_models_cache()
|
|
return calls
|
|
|
|
|
|
def _configure(monkeypatch, tmp_path, *, provider: str, default: str = ""):
|
|
hermes_home = tmp_path / "hermes-home"
|
|
hermes_home.mkdir()
|
|
monkeypatch.setattr(profiles, "get_active_hermes_home", lambda: hermes_home)
|
|
monkeypatch.setattr(config, "_get_config_path", lambda: tmp_path / "missing-config.yaml")
|
|
monkeypatch.setattr(config, "_models_cache_path", tmp_path / "models_cache.json")
|
|
monkeypatch.setattr(
|
|
config,
|
|
"cfg",
|
|
{
|
|
"model": {"provider": provider, "default": default},
|
|
"providers": {},
|
|
"fallback_providers": [],
|
|
},
|
|
)
|
|
monkeypatch.setattr(config, "_cfg_mtime", 0.0)
|
|
config.invalidate_models_cache()
|
|
|
|
|
|
def _provider_group(result: dict, provider_id: str) -> dict:
|
|
return next(g for g in result["groups"] if g.get("provider_id") == provider_id)
|
|
|
|
|
|
def _ids(group: dict) -> list[str]:
|
|
return [m.get("id") for m in group.get("models", [])]
|
|
|
|
|
|
def test_generic_provider_uses_hermes_cli_catalog_before_static_snapshot(monkeypatch, tmp_path):
|
|
"""A normal provider should show fresh CLI-discovered models.
|
|
|
|
``claude-sonnet-5.0`` is intentionally absent from WebUI's static Anthropic
|
|
list. Before this fix the group came entirely from ``_PROVIDER_MODELS`` and
|
|
this model was invisible even though Hermes CLI knew about it.
|
|
"""
|
|
_scrub_provider_env(monkeypatch)
|
|
calls = _install_fake_hermes_cli(
|
|
monkeypatch,
|
|
provider_id="anthropic",
|
|
live_ids=["claude-opus-4.7", "claude-sonnet-5.0"],
|
|
)
|
|
_configure(monkeypatch, tmp_path, provider="anthropic", default="claude-opus-4.7")
|
|
|
|
result = config.get_available_models()
|
|
group = _provider_group(result, "anthropic")
|
|
|
|
assert calls == ["anthropic"]
|
|
assert _ids(group) == ["claude-opus-4.7", "claude-sonnet-5.0"]
|
|
assert group["models"][1]["label"] == "Claude Sonnet 5.0"
|
|
|
|
|
|
def test_generic_provider_keeps_static_catalog_as_cli_failure_fallback(monkeypatch, tmp_path):
|
|
_scrub_provider_env(monkeypatch)
|
|
calls = _install_fake_hermes_cli(
|
|
monkeypatch,
|
|
provider_id="anthropic",
|
|
live_ids=[],
|
|
raise_on_lookup=True,
|
|
)
|
|
_configure(monkeypatch, tmp_path, provider="anthropic", default="claude-opus-4.7")
|
|
|
|
result = config.get_available_models()
|
|
group = _provider_group(result, "anthropic")
|
|
|
|
assert calls == ["anthropic"]
|
|
assert "claude-opus-4.7" in _ids(group)
|
|
assert "claude-sonnet-4.6" in _ids(group)
|
|
|
|
|
|
def test_generic_provider_prefixes_live_ids_when_not_active_provider(monkeypatch, tmp_path):
|
|
"""Provider-qualified live IDs must route through the selected provider."""
|
|
_scrub_provider_env(monkeypatch)
|
|
calls = _install_fake_hermes_cli(
|
|
monkeypatch,
|
|
provider_id="anthropic",
|
|
live_ids=["claude-sonnet-5.0"],
|
|
)
|
|
# Anthropic is authenticated via Hermes CLI, but OpenAI is the active
|
|
# default. The Anthropic row still has to be pickable/routable.
|
|
_configure(monkeypatch, tmp_path, provider="openai", default="gpt-5.5")
|
|
|
|
result = config.get_available_models()
|
|
group = _provider_group(result, "anthropic")
|
|
|
|
assert "anthropic" in calls
|
|
assert _ids(group) == ["@anthropic:claude-sonnet-5.0"]
|