* 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>
82 lines
4.2 KiB
Python
82 lines
4.2 KiB
Python
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parents[1]
|
|
UI_JS = (REPO / "static" / "ui.js").read_text(encoding="utf-8")
|
|
BOOT_JS = (REPO / "static" / "boot.js").read_text(encoding="utf-8")
|
|
INDEX_HTML = (REPO / "static" / "index.html").read_text(encoding="utf-8")
|
|
STYLE_CSS = (REPO / "static" / "style.css").read_text(encoding="utf-8")
|
|
I18N_JS = (REPO / "static" / "i18n.js").read_text(encoding="utf-8")
|
|
PANELS_JS = (REPO / "static" / "panels.js").read_text(encoding="utf-8")
|
|
CONFIG_PY = (REPO / "api" / "config.py").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 test_session_jump_buttons_are_opt_in_and_keep_existing_bottom_button():
|
|
assert '"session_jump_buttons": False' in CONFIG_PY
|
|
assert '"session_jump_buttons"' in CONFIG_PY
|
|
assert "window._sessionJumpButtonsEnabled=!!s.session_jump_buttons" in BOOT_JS
|
|
assert "window._sessionJumpButtonsEnabled=false" in BOOT_JS
|
|
assert "session_jump_buttons: !!($('settingsSessionJumpButtons')||{}).checked" in PANELS_JS
|
|
|
|
scroll_listener = UI_JS[UI_JS.index("el.addEventListener('scroll'") : UI_JS.index("})();", UI_JS.index("el.addEventListener('scroll'"))]
|
|
assert "const showBottomButton=!_scrollPinned && el.scrollHeight-top-el.clientHeight>80" in scroll_listener
|
|
assert "_syncScrollToBottomCue(showBottomButton,{newMessage:_newMessageCueVisible})" in scroll_listener
|
|
assert "!_isSessionJumpButtonsEnabled()||_scrollPinned" not in UI_JS
|
|
|
|
|
|
def test_jump_to_session_start_button_loads_full_history_and_scrolls_top():
|
|
jump = _function_body(UI_JS, "async function jumpToSessionStart")
|
|
update = _function_body(UI_JS, "function _updateSessionStartJumpButton")
|
|
|
|
assert 'id="jumpToSessionStartBtn"' in INDEX_HTML
|
|
assert 'class="session-jump-btn session-jump-btn--start"' in INDEX_HTML
|
|
assert "data-i18n=\"session_jump_start\"" in INDEX_HTML
|
|
assert "data-i18n=\"session_jump_end\"" in INDEX_HTML
|
|
assert "data-i18n-aria-label=\"session_jump_start_label\"" in INDEX_HTML
|
|
assert "data-i18n-aria-label=\"session_jump_end_label\"" in INDEX_HTML
|
|
|
|
assert "_ensureAllMessagesLoaded" in jump
|
|
assert "_messageRenderWindowSize=Math.max(_currentMessageRenderWindowSize(),_messageRenderableMessageCount())" in jump
|
|
assert "renderMessages({ preserveScroll:true })" in jump
|
|
assert "container.scrollTop=0" in jump
|
|
assert "btn.style.display=(hasSession&&canRevealStart&&awayFromStart)?'flex':'none'" in update
|
|
|
|
|
|
def test_session_jump_buttons_match_pill_layout_without_regressing_default_arrow():
|
|
assert ".session-jump-btn" in STYLE_CSS
|
|
assert ".session-jump-btn--start{top:16px" in STYLE_CSS
|
|
assert ".session-jump-btn__text{display:none" in STYLE_CSS
|
|
assert ".messages.session-nav-enabled .scroll-to-bottom-btn" in STYLE_CSS
|
|
assert ".messages.session-nav-enabled .session-jump-btn__text{display:inline" in STYLE_CSS
|
|
assert "classList.toggle('session-nav-enabled',_isSessionJumpButtonsEnabled())" in UI_JS
|
|
|
|
|
|
def test_session_jump_buttons_are_i18n_localized_in_text_tooltip_and_aria():
|
|
english_literals = {
|
|
"session_jump_start": "Start",
|
|
"session_jump_start_label": "Jump to beginning of session",
|
|
"session_jump_end": "End",
|
|
"session_jump_end_label": "Jump to end of session",
|
|
"settings_label_session_jump_buttons": "Show session jump buttons",
|
|
"settings_desc_session_jump_buttons": "Show floating Start and End buttons while reading long session histories.",
|
|
}
|
|
for key in english_literals:
|
|
assert I18N_JS.count(f"{key}:") >= 8, f"missing locale entries for {key}"
|
|
for key, value in english_literals.items():
|
|
assert I18N_JS.count(f"{key}: '{value}'") == 1, f"non-English locale still uses English literal for {key}"
|
|
assert "document.querySelectorAll('[data-i18n-aria-label]')" in I18N_JS
|
|
assert "el.setAttribute('aria-label', val)" in I18N_JS
|