* 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>
62 lines
3.5 KiB
Python
62 lines
3.5 KiB
Python
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parents[1]
|
|
UI_JS = (REPO / "static" / "ui.js").read_text(encoding="utf-8")
|
|
SESSIONS_JS = (REPO / "static" / "sessions.js").read_text(encoding="utf-8")
|
|
CSS = (REPO / "static" / "style.css").read_text(encoding="utf-8")
|
|
|
|
|
|
def test_message_virtualization_switches_render_messages_to_scroll_driven_window():
|
|
assert "function _messageVirtualWindow(opts)" in UI_JS
|
|
assert "function _messageVirtualKeepTailCount()" in UI_JS
|
|
assert "const virtualWindow=_currentMessageVirtualWindow(visWithIdx,_messageVirtualKeepTailCount())" in UI_JS
|
|
assert "const renderHeadVisWithIdx=visWithIdx.slice(windowStart, windowEnd)" in UI_JS
|
|
assert "const renderTailStart=virtualWindow.virtualized?Math.max(windowEnd, virtualWindow.tailStart):windowEnd" in UI_JS
|
|
assert "const renderTailVisWithIdx=virtualWindow.virtualized&&renderTailStart<visWithIdx.length" in UI_JS
|
|
assert "const renderVisWithIdx=renderHeadVisWithIdx.concat(renderTailVisWithIdx)" in UI_JS
|
|
assert "if(virtualWindow.virtualized&&virtualWindow.bottomPad>0&&vi===headRenderCount)" in UI_JS
|
|
|
|
|
|
def test_load_earlier_only_pages_server_history_and_preserves_scroll():
|
|
assert "function _wireMessageWindowLoadEarlierButton()" in UI_JS
|
|
assert "if(typeof _loadOlderMessages==='function') _loadOlderMessages();" in UI_JS
|
|
assert "if(hasServerOlder){" in UI_JS
|
|
assert "if(virtualWindow.virtualized&&virtualWindow.topPad>0)" in UI_JS
|
|
assert "_messageRenderWindowSize=_currentMessageRenderWindowSize()+Math.max(addedRenderable, MESSAGE_RENDER_WINDOW_DEFAULT);" in SESSIONS_JS
|
|
assert "renderMessages({ preserveScroll: true });" in SESSIONS_JS
|
|
assert "_scheduleMessageVirtualizedRender();" in UI_JS
|
|
|
|
|
|
def test_windowed_render_keeps_streaming_and_tool_activity_anchored_to_rendered_messages():
|
|
assert "_scrollAfterMessageRender(preserveScroll, scrollSnapshot);" in UI_JS
|
|
assert "const assistantIdxs=[...assistantSegments.keys()].sort((a,b)=>a-b);" in UI_JS
|
|
assert "if(aIdx<assistantIdxs[0]) continue;" in UI_JS
|
|
assert "const renderedAssistantIdxs=[...assistantSegments.keys()].sort((a,b)=>a-b);" in UI_JS
|
|
assert "const seg=assistantSegments.get(mi);" in UI_JS
|
|
|
|
|
|
def test_window_state_participates_in_cache_and_cached_button_is_rewired():
|
|
assert "cached.renderWindowKey===renderWindowKey" in UI_JS
|
|
assert "cached.signature===renderSignature" in UI_JS
|
|
assert "_sessionHtmlCache.set(sid,{html:_html,msgCount,renderWindowKey,signature:renderSignature})" in UI_JS
|
|
assert "_messageVirtualWindowKey=renderWindowKey" in UI_JS
|
|
assert "function _wireMessageWindowLoadEarlierButton()" in UI_JS
|
|
assert "_wireMessageWindowLoadEarlierButton();" in UI_JS
|
|
assert UI_JS.count("_wireMessageWindowLoadEarlierButton();") >= 2
|
|
|
|
|
|
def test_virtualization_affordances_have_styling_hooks():
|
|
assert "message-window-load-earlier" in UI_JS
|
|
assert ".message-window-load-earlier" in CSS
|
|
assert ".message-virtual-spacer" in CSS
|
|
assert "border-radius:999px" in CSS
|
|
|
|
|
|
def test_measurement_rerenders_are_bounded_per_virtual_window_cycle():
|
|
assert "const MESSAGE_VIRTUAL_MEASUREMENT_MAX_RERENDERS=2;" in UI_JS
|
|
assert "function _messageVirtualMeasurementCycleKeyFor(windowMetrics)" in UI_JS
|
|
assert "function _scheduleMessageVirtualMeasurementRefresh(windowMetrics)" in UI_JS
|
|
assert "if(_messageVirtualMeasurementRetryCount>=MESSAGE_VIRTUAL_MEASUREMENT_MAX_RERENDERS) return;" in UI_JS
|
|
assert "_scheduleMessageVirtualMeasurementRefresh(virtualWindow);" in UI_JS
|
|
assert "_markMessageVirtualMeasurementsSettled(virtualWindow);" in UI_JS
|