Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/ui/src/prompt-anchor-rail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ export const PromptAnchorRail = memo(function PromptAnchorRail({ turns, scrollRe

useEffect(() => {
const root = scrollRef.current;
if (!root || turns.length === 0) return;
const mountedTurnList = root?.querySelector('[data-virtual-turn-id]')?.parentElement;
if (!root || !mountedTurnList || turns.length === 0) return;

const idByElement = new Map<Element, string>();
const visible = new Set<string>();
Expand Down Expand Up @@ -381,7 +382,7 @@ export const PromptAnchorRail = memo(function PromptAnchorRail({ turns, scrollRe
},
{ root, rootMargin: '0px 0px -66% 0px', threshold: 0 },
);
for (const element of root.querySelectorAll('[data-turn-id]')) observeElement(element);
for (const element of mountedTurnList.querySelectorAll('[data-turn-id]')) observeElement(element);

const mutationObserver = new MutationObserver((records) => {
for (const record of records) {
Expand All @@ -390,7 +391,7 @@ export const PromptAnchorRail = memo(function PromptAnchorRail({ turns, scrollRe
}
resolveActive();
});
mutationObserver.observe(root, { childList: true, subtree: true });
mutationObserver.observe(mountedTurnList, { childList: true });
Comment thread
Astro-Han marked this conversation as resolved.

let frame = 0;
const onScroll = (): void => {
Expand Down