Files
hermes-webui/tests/test_issue3869_thinking_dots.py
T
35098632ea Release v0.51.341 — Release LE (stale thinking-dot placeholder fix #3869/#3876) (#3886)
Fixes #3869: empty legacy three-dot thinking spinners piled up as stale
rows after the agent finished thinking. The live-to-final redesign (#3401)
made the thinking-card-row wrapper class unconditional, which broke
finalizeThinkingCard()'s dots-only detection — it treated the wrapper class
itself as a "has content" signal, so the dots-only removal branch went dead.
Narrow hasContent to the actual .thinking-card element so dots-only spinners
are removed on finalize while real Worklog Thinking Cards are preserved.

Includes #3869 regression coverage (brace-walks finalizeThinkingCard, asserts
the narrowed check + that real thinking cards are not removed).

Co-authored-by: nesquena-hermes <[email protected]>
Co-authored-by: franksong2702 <franksong2702@users.noreply.github.com>
2026-06-09 10:19:22 -07:00

44 lines
1.6 KiB
Python

from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
UI_JS = (REPO_ROOT / "static" / "ui.js").read_text()
def _function_body(src: str, name: str) -> str:
marker = f"function {name}("
start = src.find(marker)
assert start != -1, f"{name} not found"
brace = src.find("{", start)
assert brace != -1, f"{name} body not found"
depth = 0
for idx in range(brace, len(src)):
ch = src[idx]
if ch == "{":
depth += 1
elif ch == "}":
depth -= 1
if depth == 0:
return src[brace + 1 : idx]
raise AssertionError(f"{name} body not closed")
def test_finalize_removes_dot_only_legacy_thinking_placeholder():
"""#3869: an empty legacy thinking row is only a spinner, not durable content."""
body = _function_body(UI_JS, "finalizeThinkingCard")
assert "const hasContent=!!row.querySelector('.thinking-card');" in body
assert "row.classList.contains('thinking-card-row')" not in body
assert "if(!hasContent && row.getAttribute('data-thinking-active')==='1'){" in body
assert "row.remove();" in body
def test_live_worklog_thinking_cards_are_preserved_on_finalize():
"""#3869 fix must not remove real Worklog Thinking Cards that contain text."""
body = _function_body(UI_JS, "finalizeThinkingCard")
assert "turn.querySelectorAll('.agent-activity-thinking[data-thinking-active=\"1\"]')" in body
assert "active.removeAttribute('data-thinking-active');" in body
assert "active.removeAttribute('data-live-thinking');" in body
assert "active.remove()" not in body