From c4e82c61553db6af12794f81d2e183ab726e059f Mon Sep 17 00:00:00 2001 From: akrhin Date: Wed, 24 Jun 2026 09:30:20 +0300 Subject: [PATCH] chore: cleanup per Greptile review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove dead _scrollAnchorRestore variable (returns undefined) - Remove redundant _fixMobileScrollJank() call from _doRender() (CSS already gives overflow-anchor:auto on mobile via media query; desktop exits guard early — call was a no-op on every tick) - Update JSDoc on _fixMobileScrollJank to reflect actual usage --- static/messages.js | 3 --- static/ui.js | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/static/messages.js b/static/messages.js index 211d1dd7..50ca2ece 100644 --- a/static/messages.js +++ b/static/messages.js @@ -3844,9 +3844,6 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){ _renderPending=false; // Guard: a pending setTimeout+rAF can outlive stream finalization. if(_streamFinalized) return; - // Mobile scroll-jank guard: enable overflow-anchor before DOM writes so - // the browser preserves scroll position during streaming content growth. - if(typeof window._fixMobileScrollJank==='function') window._fixMobileScrollJank(); _lastRenderMs=performance.now(); const parsed=_cachedParsed&&_cachedParsedText===assistantText&&_cachedParsedReasoning===liveReasoningText ? _cachedParsed : _parseStreamState(); _cachedParsed=null; diff --git a/static/ui.js b/static/ui.js index 2701e078..8c7c01b9 100644 --- a/static/ui.js +++ b/static/ui.js @@ -10993,7 +10993,8 @@ function _restoreMessageScrollSnapshot(snapshot){ * browser preserves scroll position across the innerHTML='' + DOM rebuild gap. * Safari/Chrome on iOS/Android can paint a frame with scrollTop=0 between * innerHTML='' and snapshot restore, scroll-janking the user to the top. - * Also acts as a generic anchor-stabilizer during streaming DOM updates. + * Called from renderMessages() before the DOM wipe — not from streaming ticks, + * since CSS already gives overflow-anchor:auto on mobile via media query. */ window._fixMobileScrollJank=function _fixMobileScrollJank(){ const el=document.getElementById('messages'); @@ -11245,7 +11246,7 @@ function renderMessages(options){ // preserves scroll position across the DOM wipe-and-rebuild gap. // Safari/Chrome on iOS/Android can paint a frame with scrollTop=0 between // innerHTML='' and snapshot restore, scroll-janking the user to the top. - const _scrollAnchorRestore=window._fixMobileScrollJank&&window._fixMobileScrollJank(); + if(window._fixMobileScrollJank) window._fixMobileScrollJank(); inner.innerHTML=''; const compressionNode=compressionState?_compressionCardsNode(compressionState):null; const {message:referenceMessage, rawIdx:referenceMessageRawIdx}=_latestCompressionReferenceMessage(