fix: log viewer auto-follow uses distance-from-bottom instead of element visibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-20 14:11:35 -06:00
parent 38162dc317
commit 53060e770c

View File

@@ -1251,11 +1251,14 @@ function LogViewer({ run, adapterType }: { run: HeartbeatRun; adapterType: strin
}, [initialEvents]);
const updateFollowingState = useCallback(() => {
const el = logEndRef.current;
if (!el) return;
const rect = el.getBoundingClientRect();
const inView = rect.top <= window.innerHeight && rect.bottom >= 0;
setIsFollowing((prev) => (prev === inView ? prev : inView));
const viewportBottom = window.scrollY + window.innerHeight;
const pageHeight = Math.max(
document.documentElement.scrollHeight,
document.body.scrollHeight,
);
const distanceFromBottom = pageHeight - viewportBottom;
const isNearBottom = distanceFromBottom <= 32;
setIsFollowing((prev) => (prev === isNearBottom ? prev : isNearBottom));
}, []);
useEffect(() => {