* perf(chat): virtualize long message transcripts (#500) * fix(chat): preserve virtual height cache on append (#500) * fix(chat): bound virtual tail follow-up (#500) * fix(chat): surface older history and bound virtual rerenders (#500) * fix(chat): stabilize virtual history fallback (#500) * fix(chat): preserve virtual compression anchors (#500) * Keep virtualization regressions aligned with rebased sources (#500) * fix(chat): preserve virtual heights across prepends (#500) * test(update): isolate restart timing checks (#814) * fix(chat): restore render contracts around virtual cache * fix(chat): preserve legacy assistant anchor predicates * fix(#3714): restore worklog-disclosure capture after HTML-cache early-return Deep-review finding: the capture of _captureWorklogDetailDisclosureState was moved before the HTML-cache fast-path return, failing the invariant test test_render_rebuild_preserves_worklog_detail_disclosure_click_state (it must not traverse the previous-session DOM when the cache path returns early). Moved it back to just before inner.innerHTML='' (after the cache return). Co-authored-by: Rod Boev <rod.boev@gmail.com> * fix(#3714): restore Transparent Stream rehydration in HTML-cache fast path Full-suite gate caught test_issue3820_chat_activity_display_mode failure: the virtualization rewrite of the renderMessages HTML-cache fast-path block dropped the _rehydrateTransparentStreamDom(inner) call (master has it; PR had 2 of 3 occurrences). On a cache-restore session switch, Transparent Stream controls lost their property-assigned handlers. Restored the call in the same position master has it (right after _sessionHtmlCacheSid=sid). Co-authored-by: Rod Boev <rod.boev@gmail.com> * fix(#3714): preserve live turn on scroll-rebuild even with zero streamed text Opus ship-review residual (now fixed, not deferred): the live-turn re-attach after a scroll-triggered virtualized rebuild was gated on _preservedLen>0, so a turn showing only Activity/tool/worklog blocks with no streamed text yet (mid tool-call) would not be preserved — scrolling up into history on a >80-row transcript mid-stream could blink those live-only blocks for a frame. Broaden the gate to also restore when the preserved turn has MORE structural blocks than the rebuilt (lagging-S.messages) turn. Hoisted the _structuralCount helper above the gate; whole-turn-vs-segment restore logic unchanged. Co-authored-by: Rod Boev <rod.boev@gmail.com> * chore(release): stamp v0.51.423 (Release OJ) for #500 transcript virtualization --------- Co-authored-by: Rod Boev <rod.boev@gmail.com> Co-authored-by: nesquena-hermes <agent@nesquena-hermes>
80 lines
4.7 KiB
Python
80 lines
4.7 KiB
Python
"""Regression coverage for #2246 per-turn jump-to-question buttons."""
|
|
|
|
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parents[1]
|
|
UI_JS = (REPO / "static" / "ui.js").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")
|
|
|
|
|
|
def test_assistant_footer_gets_completed_turn_question_jump_button():
|
|
assert "function _questionJumpButtonHtml(questionRawIdx, assistantRawIdx)" in UI_JS
|
|
assert "function jumpToTurnQuestion(questionRawIdx, assistantRawIdx)" in UI_JS
|
|
assert "const questionRawIdxByAssistantRawIdx=new Map()" in UI_JS
|
|
assert "questionRawIdxByAssistantRawIdx.set(entry.rawIdx,lastQuestionRawIdx)" in UI_JS
|
|
assert "row.id=_userMessageDomId(rawIdx)" in UI_JS
|
|
assert "const isTurnFinalAssistant=!isUser&&(!nextRendered||!nextRendered.m||nextRendered.m.role!=='assistant')" in UI_JS
|
|
# #3114 superseded the turn-final-only gate: the jump-to-question button now
|
|
# renders on every assistant message that has a resolvable question target,
|
|
# not just the turn-final one (multi-step turns otherwise lost the affordance
|
|
# on intermediate assistant bubbles). The button is gated on a non-null
|
|
# resolved target instead of isTurnFinalAssistant.
|
|
assert "const _qJumpTarget=(!isUser&&!m._live)?questionRawIdxByAssistantRawIdx.get(rawIdx):undefined;" in UI_JS
|
|
assert "const questionJumpBtn = (_qJumpTarget!==undefined&&_qJumpTarget!==null)" in UI_JS
|
|
assert "_questionJumpButtonHtml(_qJumpTarget, assistantRawIdxByQuestionRawIdx.get(_qJumpTarget)??rawIdx)" in UI_JS
|
|
assert "msg-question-jump-btn" in UI_JS
|
|
|
|
|
|
def test_multi_segment_turn_jumps_to_first_assistant_segment():
|
|
# #3852: the reverse map assistantRawIdxByQuestionRawIdx resolves the FIRST
|
|
# assistant segment for a given question so multi-step turns (tool_call ->
|
|
# assistant -> tool_call -> assistant) scroll to the start of the response.
|
|
assert "const assistantRawIdxByQuestionRawIdx=new Map()" in UI_JS
|
|
assert "if(!assistantRawIdxByQuestionRawIdx.has(qIdx)) assistantRawIdxByQuestionRawIdx.set(qIdx,aIdx)" in UI_JS
|
|
assert "assistantRawIdxByQuestionRawIdx.get(_qJumpTarget)" in UI_JS
|
|
|
|
|
|
def test_question_jump_expands_windowed_history_and_highlights_question():
|
|
assert "function _messageVisibleIndexForRawIdx(rawIdx, visWithIdx)" in UI_JS
|
|
assert "function _messageVirtualScrollTopForVisibleIdx(visWithIdx, visibleIdx, container)" in UI_JS
|
|
assert "const visibleIdx=_messageVisibleIndexForRawIdx(questionRawIdx, visWithIdx);" in UI_JS
|
|
assert "container.scrollTop=_messageVirtualScrollTopForVisibleIdx(visWithIdx, visibleIdx, container);" in UI_JS
|
|
assert "_messageVirtualWindowKey='';" in UI_JS
|
|
assert "_messageRenderWindowSize=Math.max(_currentMessageRenderWindowSize(),_messageRenderableMessageCount())" in UI_JS
|
|
assert "renderMessages({ preserveScroll:true })" in UI_JS
|
|
assert "row.scrollIntoView({block:'center',behavior:'smooth'})" in UI_JS
|
|
assert "_highlightQuestionRow(row)" in UI_JS
|
|
assert "msg-question-highlight" in UI_JS
|
|
|
|
|
|
def test_question_jump_button_is_quiet_and_hidden_on_mobile():
|
|
assert ".msg-question-jump-btn" in STYLE_CSS
|
|
assert "margin-left: auto;" in STYLE_CSS
|
|
assert ".msg-question-highlight .msg-body" in STYLE_CSS
|
|
assert "@keyframes question-highlight-pulse" in STYLE_CSS
|
|
assert "@media (max-width: 600px)" in STYLE_CSS
|
|
assert ".msg-question-jump-btn { display: none; }" in STYLE_CSS
|
|
|
|
|
|
def test_question_jump_text_is_localized():
|
|
for key in ("jump_to_question", "jump_to_question_label"):
|
|
assert I18N_JS.count(f"{key}:") >= 12
|
|
|
|
|
|
def test_question_jump_skips_hidden_first_segment_and_falls_back():
|
|
# #3934 (Codex gate): a single assistant rawIdx can render multiple segment
|
|
# nodes, and the first can be display:none (assistant-segment-worklog-source /
|
|
# assistant-segment-anchor). scrollIntoView() on a hidden node silently no-ops,
|
|
# so the jump must only treat a VISIBLE segment as a successful target and
|
|
# otherwise fall through to the question-row fallback instead of suppressing it.
|
|
# Guard against regressing back to the unconditional first-match return.
|
|
assert "querySelectorAll('[data-msg-idx=\"'+assistantRawIdx+'\"]')" in UI_JS
|
|
assert "seg.getClientRects().length>0" in UI_JS
|
|
# The single-element querySelector + unconditional return must be gone.
|
|
assert "const seg=hasAssistant?container.querySelector('[data-msg-idx=\"'+assistantRawIdx+'\"]'):null;" not in UI_JS
|
|
# display:none on the hidden segment classes is what makes the guard necessary.
|
|
assert ".assistant-segment-worklog-source{" in STYLE_CSS
|
|
assert ".assistant-segment-anchor { display: none; }" in STYLE_CSS
|
|
|