Files
hermes-webui/tests/test_tool_call_history_paging.py
nesquena-hermes 042294e2a1 test: update sessions.js string-assertions for #3313 carry-forward rename
#3313 applies the ephemeral-field carry-forward at all 5 wholesale S.messages
replace sites (loadSession/_ensureMessagesLoaded/_loadOlderMessages/
_ensureAllMessagesLoaded/startGatewaySSE), renaming the replace RHS from
msgs/next to _msgsToAssign/_nextToAssign. These pre-existing tests pinned the
old literals; updated to match the new RHS (or made LHS-agnostic) while
preserving the invariants they protect (bump-before-replace, session-switch
guard, shorter-transcript guard).
2026-06-01 19:46:36 +00:00

29 lines
1.6 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SESSIONS_JS = (ROOT / "static" / "sessions.js").read_text(encoding="utf-8")
def test_sessions_js_resyncs_tool_calls_after_history_window_replacement():
"""History paging replaces S.messages with a larger window.
Legacy sessions keep tool card data in session.tool_calls, so that side data
must be refreshed alongside the message window. Otherwise renderMessages()
can keep stale anchors and show unloaded/thinking placeholders while the
user scrolls through history.
"""
assert "function _syncToolCallsForLoadedMessages(messages, sessionToolCalls)" in SESSIONS_JS
assert "_syncToolCallsForLoadedMessages(msgs, data.session.tool_calls);" in SESSIONS_JS
assert "S.messages = nextMessages;\n _syncToolCallsForLoadedMessages(nextMessages, responseSession.tool_calls);" in SESSIONS_JS
assert "S.messages = _msgsToAssign;\n _messagesTruncated = false;\n _oldestIdx = 0;\n _syncToolCallsForLoadedMessages(msgs, data.session.tool_calls);" in SESSIONS_JS
def test_sessions_js_clears_session_tool_calls_when_messages_have_own_metadata():
assert "const hasTc=Array.isArray(m.tool_calls)&&m.tool_calls.length>0;" in SESSIONS_JS
assert "const hasTu=Array.isArray(m.content)&&m.content.some(p=>p&&p.type==='tool_use');" in SESSIONS_JS
assert "windowOffset" not in SESSIONS_JS
assert "copy.assistant_msg_idx=idx-offset;" not in SESSIONS_JS
assert "S.toolCalls=sessionToolCalls.map(tc=>({...tc,done:true}));" in SESSIONS_JS
assert "S.toolCalls=[];" in SESSIONS_JS