fix: guard _autoScrollFollow access against ReferenceError before settings init

Browser race in static/ui.js: _autoScrollFollow can be undefined when
scroll/scrollpin listeners fire before boot.js initializes settings.
Bare global reference (ReferenceError) occurs on the golden path.

Fix: wrap both consumer sites with a typeof guard that defaults to
true (matching the boot.js fallback) when the variable hasn't been set.

Closes #6606
This commit is contained in:
webtecnica committed 2026-08-01 17:45:43 -03:00
1 parent 320789ae59
commit f4f9157f8d
1 file changed
+2 -2
+2 -2
View File
@@ -6104,7 +6104,7 @@ if(typeof window!=='undefined'){
if(nearBottom){
_nearBottomCount=_nearBottomCount+1;
if(_nearBottomCount>=2){_scrollPinned=true;_nearBottomCount=0;}
}else if(!movedUp && _autoScrollFollow && _scrollPinned){
}else if(!movedUp && (typeof _autoScrollFollow==='undefined'||_autoScrollFollow) && _scrollPinned){
// Content-grew-beneath-a-pinned-viewport case (NOT a user scroll-away).
// During streaming on a tall transcript (esp. mobile, where chunks land
// fast), new content increases scrollHeight under a stationary viewport,
@@ -6779,7 +6779,7 @@ function _shouldFollowMessagesOnDomReplace(){
// following only for users who are still pinned or effectively at the tail.
// A broad near-bottom window causes long answers/mobile readers who scroll up
// a little to read mid-stream to get snapped back to the bottom on completion.
return _autoScrollFollow && !_messageUserUnpinned && (_scrollPinned || _isMessagePaneNearBottom(120));
return (typeof _autoScrollFollow==='undefined'||_autoScrollFollow) && !_messageUserUnpinned && (_scrollPinned || _isMessagePaneNearBottom(120));
}
function _followMessagesAfterDomReplace(){
if(_shouldFollowMessagesOnDomReplace()){