HERMES-GIELIE/tests/test_issue3545_streaming_scroll_cue.py

86 lines
3.8 KiB
Python
Raw Permalink Normal View History

Release v0.51.334 — Release KX (new-message cue when scrolled up, #3631) (#3849) * fix(streaming): show new-message cue when preserving scroll position (#3545) # Conflicts: # static/ui.js # tests/test_issue1690_scroll_completion.py # tests/test_tars_scroll_reset_regressions.py * i18n: add missing Polish (pl) translation for session_new_message keys The PR added session_new_message / session_new_message_label to 12 of 13 locales; Polish was missing both, which fails the per-locale parity test. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * fix(streaming): keep forced follow path for pinned users in preserve-scroll branch Codex CORE catch: the PR's preserve-scroll branch used 'if(_scrollPinned) scrollIfPinned()' which skips the synchronous bottom write unless distance>500 and can have its delayed settles cancelled by the DOM-rebuild scroll event — leaving a pinned reader a few lines above the settled final response. Restore master's _followMessagesAfterDomReplace() forced-scrollToBottom() path for pinned/near-bottom users; only genuinely scrolled-up (unpinned, not near bottom) users restore their viewport and get the new-message cue. Updated the 3 structure-pinning tests to assert the corrected (safer) shape while preserving their behavioral intent. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * Release v0.51.334 — Release KX (new-message cue when scrolled up, #3631) New-message cue on the jump-to-bottom button when the user has scrolled up during a live turn (#3545/#3631, @rodboev). Deep-reviewed (Opus+Codex); maintainer fixes during re-gate: (1) restored master's forced follow path for pinned/near-bottom users (Codex CORE: scrollIfPinned could leave a pinned reader short of the settled response) + updated 3 structure-pinning tests to the corrected shape; (2) added missing Polish (pl) i18n keys (PR had 12/13). Full suite 8308, ESLint/scope-undef CLEAN, Opus SHIP-safe, Codex SAFE-TO-SHIP. Co-authored-by: rodboev <rodboev@users.noreply.github.com> --------- Co-authored-by: Rod Boev <rod.boev@gmail.com> Co-authored-by: Hermes Agent <hermes-agent@nesquena-hermes.local> Co-authored-by: rodboev <rodboev@users.noreply.github.com>
2026-06-08 22:58:13 +00:00
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
UI_JS = (REPO / "static" / "ui.js").read_text(encoding="utf-8")
I18N_JS = (REPO / "static" / "i18n.js").read_text(encoding="utf-8")
STYLE_CSS = (REPO / "static" / "style.css").read_text(encoding="utf-8")
def _function_body(src: str, signature: str) -> str:
start = src.index(signature)
brace = src.index("{", start)
depth = 0
for i in range(brace, len(src)):
if src[i] == "{":
depth += 1
elif src[i] == "}":
depth -= 1
if depth == 0:
return src[start : i + 1]
raise AssertionError(f"function body not found: {signature}")
def _scroll_listener_block() -> str:
start = UI_JS.index("el.addEventListener('scroll'")
return UI_JS[start : UI_JS.index("})();", start)]
def test_preserve_scroll_unpinned_branch_shows_new_message_cue_after_restore():
helper = _function_body(UI_JS, "function _scrollAfterMessageRender")
# The preserve-scroll branch keeps master's forced follow path for pinned /
# near-bottom users (no regression on settled-response bottom-pinning), and
# only the genuinely-scrolled-up cohort restores their viewport + gets the
# new-message cue. (Codex CORE catch: scrollIfPinned() in the pinned branch
# could leave a pinned reader short of the settled response.)
assert "if(!readerAwayFromBottom && !_messageUserUnpinned && _followMessagesAfterDomReplace()) return;" in helper
Release v0.51.334 — Release KX (new-message cue when scrolled up, #3631) (#3849) * fix(streaming): show new-message cue when preserving scroll position (#3545) # Conflicts: # static/ui.js # tests/test_issue1690_scroll_completion.py # tests/test_tars_scroll_reset_regressions.py * i18n: add missing Polish (pl) translation for session_new_message keys The PR added session_new_message / session_new_message_label to 12 of 13 locales; Polish was missing both, which fails the per-locale parity test. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * fix(streaming): keep forced follow path for pinned users in preserve-scroll branch Codex CORE catch: the PR's preserve-scroll branch used 'if(_scrollPinned) scrollIfPinned()' which skips the synchronous bottom write unless distance>500 and can have its delayed settles cancelled by the DOM-rebuild scroll event — leaving a pinned reader a few lines above the settled final response. Restore master's _followMessagesAfterDomReplace() forced-scrollToBottom() path for pinned/near-bottom users; only genuinely scrolled-up (unpinned, not near bottom) users restore their viewport and get the new-message cue. Updated the 3 structure-pinning tests to assert the corrected (safer) shape while preserving their behavioral intent. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * Release v0.51.334 — Release KX (new-message cue when scrolled up, #3631) New-message cue on the jump-to-bottom button when the user has scrolled up during a live turn (#3545/#3631, @rodboev). Deep-reviewed (Opus+Codex); maintainer fixes during re-gate: (1) restored master's forced follow path for pinned/near-bottom users (Codex CORE: scrollIfPinned could leave a pinned reader short of the settled response) + updated 3 structure-pinning tests to the corrected shape; (2) added missing Polish (pl) i18n keys (PR had 12/13). Full suite 8308, ESLint/scope-undef CLEAN, Opus SHIP-safe, Codex SAFE-TO-SHIP. Co-authored-by: rodboev <rodboev@users.noreply.github.com> --------- Co-authored-by: Rod Boev <rod.boev@gmail.com> Co-authored-by: Hermes Agent <hermes-agent@nesquena-hermes.local> Co-authored-by: rodboev <rodboev@users.noreply.github.com>
2026-06-08 22:58:13 +00:00
assert "_restoreMessageScrollSnapshot(scrollSnapshot);" in helper
assert helper.index("_restoreMessageScrollSnapshot(scrollSnapshot)") < helper.index(
"_maybeShowNewMessageScrollCue(scrollSnapshot)"
)
# The preserve-scroll cue is shown on the non-follow (restore) path, after
# restore. A separate idle/manual-unpin branch may also show the same cue.
Release v0.51.334 — Release KX (new-message cue when scrolled up, #3631) (#3849) * fix(streaming): show new-message cue when preserving scroll position (#3545) # Conflicts: # static/ui.js # tests/test_issue1690_scroll_completion.py # tests/test_tars_scroll_reset_regressions.py * i18n: add missing Polish (pl) translation for session_new_message keys The PR added session_new_message / session_new_message_label to 12 of 13 locales; Polish was missing both, which fails the per-locale parity test. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * fix(streaming): keep forced follow path for pinned users in preserve-scroll branch Codex CORE catch: the PR's preserve-scroll branch used 'if(_scrollPinned) scrollIfPinned()' which skips the synchronous bottom write unless distance>500 and can have its delayed settles cancelled by the DOM-rebuild scroll event — leaving a pinned reader a few lines above the settled final response. Restore master's _followMessagesAfterDomReplace() forced-scrollToBottom() path for pinned/near-bottom users; only genuinely scrolled-up (unpinned, not near bottom) users restore their viewport and get the new-message cue. Updated the 3 structure-pinning tests to assert the corrected (safer) shape while preserving their behavioral intent. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * Release v0.51.334 — Release KX (new-message cue when scrolled up, #3631) New-message cue on the jump-to-bottom button when the user has scrolled up during a live turn (#3545/#3631, @rodboev). Deep-reviewed (Opus+Codex); maintainer fixes during re-gate: (1) restored master's forced follow path for pinned/near-bottom users (Codex CORE: scrollIfPinned could leave a pinned reader short of the settled response) + updated 3 structure-pinning tests to the corrected shape; (2) added missing Polish (pl) i18n keys (PR had 12/13). Full suite 8308, ESLint/scope-undef CLEAN, Opus SHIP-safe, Codex SAFE-TO-SHIP. Co-authored-by: rodboev <rodboev@users.noreply.github.com> --------- Co-authored-by: Rod Boev <rod.boev@gmail.com> Co-authored-by: Hermes Agent <hermes-agent@nesquena-hermes.local> Co-authored-by: rodboev <rodboev@users.noreply.github.com>
2026-06-08 22:58:13 +00:00
assert helper.index("_followMessagesAfterDomReplace()") < helper.index(
"_maybeShowNewMessageScrollCue(scrollSnapshot)"
)
assert helper.count("_maybeShowNewMessageScrollCue(scrollSnapshot)") >= 1
Release v0.51.334 — Release KX (new-message cue when scrolled up, #3631) (#3849) * fix(streaming): show new-message cue when preserving scroll position (#3545) # Conflicts: # static/ui.js # tests/test_issue1690_scroll_completion.py # tests/test_tars_scroll_reset_regressions.py * i18n: add missing Polish (pl) translation for session_new_message keys The PR added session_new_message / session_new_message_label to 12 of 13 locales; Polish was missing both, which fails the per-locale parity test. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * fix(streaming): keep forced follow path for pinned users in preserve-scroll branch Codex CORE catch: the PR's preserve-scroll branch used 'if(_scrollPinned) scrollIfPinned()' which skips the synchronous bottom write unless distance>500 and can have its delayed settles cancelled by the DOM-rebuild scroll event — leaving a pinned reader a few lines above the settled final response. Restore master's _followMessagesAfterDomReplace() forced-scrollToBottom() path for pinned/near-bottom users; only genuinely scrolled-up (unpinned, not near bottom) users restore their viewport and get the new-message cue. Updated the 3 structure-pinning tests to assert the corrected (safer) shape while preserving their behavioral intent. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * Release v0.51.334 — Release KX (new-message cue when scrolled up, #3631) New-message cue on the jump-to-bottom button when the user has scrolled up during a live turn (#3545/#3631, @rodboev). Deep-reviewed (Opus+Codex); maintainer fixes during re-gate: (1) restored master's forced follow path for pinned/near-bottom users (Codex CORE: scrollIfPinned could leave a pinned reader short of the settled response) + updated 3 structure-pinning tests to the corrected shape; (2) added missing Polish (pl) i18n keys (PR had 12/13). Full suite 8308, ESLint/scope-undef CLEAN, Opus SHIP-safe, Codex SAFE-TO-SHIP. Co-authored-by: rodboev <rodboev@users.noreply.github.com> --------- Co-authored-by: Rod Boev <rod.boev@gmail.com> Co-authored-by: Hermes Agent <hermes-agent@nesquena-hermes.local> Co-authored-by: rodboev <rodboev@users.noreply.github.com>
2026-06-08 22:58:13 +00:00
def test_scroll_cue_uses_growth_below_restored_viewport():
maybe = _function_body(UI_JS, "function _maybeShowNewMessageScrollCue")
sync = _function_body(UI_JS, "function _syncScrollToBottomCue")
assert "el.scrollHeight>previousHeight+24" in maybe
assert "distance>80" in maybe
assert "_showNewMessageScrollCue()" in maybe
assert "scroll-to-bottom-btn--new-message" in sync
assert "session_new_message" in sync
assert "session_jump_end" in sync
def test_click_near_bottom_and_resets_clear_new_message_cue():
scroll = _function_body(UI_JS, "function scrollToBottom")
reset_direction = _function_body(UI_JS, "function _resetScrollDirectionTracker")
reset_stream = _function_body(UI_JS, "function _resetStreamScrollFollow")
listener = _scroll_listener_block()
assert scroll.index("_clearNewMessageScrollCue();") < scroll.index("_scrollPinned=true")
assert "if(nearBottom) _clearNewMessageScrollCue();" in listener
assert "_syncScrollToBottomCue(showBottomButton,{newMessage:_newMessageCueVisible})" in listener
assert "_clearNewMessageScrollCue();" in reset_direction
assert "_clearNewMessageScrollCue();" in reset_stream
def test_new_message_cue_i18n_keys_exist_in_locale_blocks():
assert I18N_JS.count("session_new_message:") >= 8
assert I18N_JS.count("session_new_message_label:") >= 8
assert "session_new_message: 'New message'" in I18N_JS
assert "session_new_message_label: 'New message available, jump to end'" in I18N_JS
def test_new_message_cue_has_stable_pill_styling():
assert ".scroll-to-bottom-btn.scroll-to-bottom-btn--new-message" in STYLE_CSS
assert "max-width:min(220px,calc(100% - 40px))" in STYLE_CSS
assert ".scroll-to-bottom-btn.scroll-to-bottom-btn--new-message .session-jump-btn__text" in STYLE_CSS