Files
hermes-webui/tests/test_issue3162_ensure_messages_loaded.py
nesquena-hermes 9d94298278
Some checks failed
Release & Docker / release (push) Has been cancelled
Release v0.51.321 — Release KK (Phase 3 light: load renderable transcript tails, #3790) (#3798)
Phase-3-light. #3790 (@ai-ag2026): expand cold-load transcript window to ~msg_limit renderable rows so tool-heavy sessions don't open showing 1-2 messages. Codex CORE fix: explicit expand_renderable flag (cold-load only; Load-earlier keeps raw cap). Also fixed a recurring CI timing flake (git-parallel test → deterministic Barrier). Full suite 8228, Codex SAFE, Opus SHIP, CI 11/11. Co-authored-by: ai-ag2026 <ai-ag2026@users.noreply.github.com>
2026-06-07 15:22:44 -07:00

44 lines
2.0 KiB
Python

"""Regression test pinning the #3162 fix.
#3162: `_ensureMessagesLoaded` in static/sessions.js declared `const msgs` but the
#3018 ephemeral-field carry-forward reassigns it (`msgs = window._carryForwardEphemeralTurnFields(...)`).
`const` -> runtime TypeError -> "Failed to load conversation messages" toast on every
mobile message (v0.51.161-166). Fix: `const` -> `let`.
This is the targeted pin; tests/test_static_js_runtime_lint.py is the general guard.
"""
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
SESSIONS_JS = (REPO / "static" / "sessions.js").read_text(encoding="utf-8")
def _ensure_messages_loaded_body() -> str:
start = SESSIONS_JS.index("async function _ensureMessagesLoaded")
# Window widened (#3326 added reload-width-hint handling inside this function,
# pushing the carry-forward reassignment further down; #3790 added the
# cold-load expand_renderable param + comment, pushing it further still).
return SESSIONS_JS[start: start + 3000]
def test_ensure_messages_loaded_declares_msgs_with_let():
body = _ensure_messages_loaded_body()
assert "let msgs = (data.session.messages" in body, (
"_ensureMessagesLoaded must declare `let msgs` — it is reassigned by the #3018 "
"carry-forward, and `const` throws a runtime TypeError on every mobile message (#3162)"
)
assert "const msgs = (data.session.messages" not in body, (
"found `const msgs` in _ensureMessagesLoaded — this is the #3162 brick-class bug; "
"must be `let` because msgs is reassigned"
)
def test_ensure_messages_loaded_reassignment_still_present():
"""Keep this test meaningful: confirm the reassignment that requires `let` exists.
If the carry-forward is removed, revisit whether `let` is still needed."""
body = _ensure_messages_loaded_body().replace(" ", "")
assert "msgs=window._carryForwardEphemeralTurnFields" in body, (
"the #3018 carry-forward reassignment of msgs is gone — re-evaluate the let/const "
"decision in _ensureMessagesLoaded"
)