Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): switched threads and Scroll to end land on the real end #24622

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/24622/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 3 changed files with 114 additions and 45 deletions.

x
0 of 3 viewed, 3 left
14 additions and 3 deletionsapps/web/src/components/chat/useTimelineFollow.tsModified
View file
@@ -28,6 +28,7 @@
import { createPageScrollController, type PageScrollKey } from "./pageScrollController";
import { createUpwardScrollDetector, isTimelineScrollTarget } from "./timelineScrollTarget";
import { resolveTimelineIsAtEnd } from "./MessagesTimeline.logic";
+import { measuredEndOffset, settleListScroll } from "./useTimelinePositionRestore";
import { shouldReleaseTimelineAnchorForToolActivity } from "../ChatView.logic";
import { releaseChatTimelineAnchor } from "../ChatView.logic";
import type { Dispatch, RefObject } from "react";
@@ -272,9 +273,19 @@
// The anchored end space must be gone before the scroll measures, or the
// list lands short of the real end (#6519).
requestAnimationFrame(() => {
- void legendListRef.current?.scrollToEnd?.({
- animated: animated && !window.matchMedia("(prefers-reduced-motion: reduce)").matches,
- });
+ const list = legendListRef.current;
+ if (!list) return;
+ void Promise.resolve(
+ list.scrollToEnd?.({
+ animated: animated && !window.matchMedia("(prefers-reduced-motion: reduce)").matches,
+ }),
+ ).then(() =>
+ settleListScroll(
+ list,
+ measuredEndOffset,
+ () => timelineScrollModeRef.current !== "following-end" || legendListRef.current !== list,
+ ),
+ );
});