Skip to content

Commit 8caccfb

Browse files
committed
fix(web): prevent auto-scroll when toggling work log expansion
Expanding a work log group during a running session would trigger scheduleStickToBottom via the timelineEntries effect, yanking the viewport to the bottom. Disable auto-scroll on toggle so the user stays where they clicked; the scroll-to-bottom button is shown if they want to jump back.
1 parent 644b808 commit 8caccfb

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

apps/web/src/components/ChatView.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,12 +3434,18 @@ export default function ChatView({ threadId }: ChatViewProps) {
34343434
}
34353435
return false;
34363436
};
3437-
const onToggleWorkGroup = useCallback((groupId: string) => {
3438-
setExpandedWorkGroups((existing) => ({
3439-
...existing,
3440-
[groupId]: !existing[groupId],
3441-
}));
3442-
}, []);
3437+
const onToggleWorkGroup = useCallback(
3438+
(groupId: string) => {
3439+
cancelPendingStickToBottom();
3440+
shouldAutoScrollRef.current = false;
3441+
setShowScrollToBottom(true);
3442+
setExpandedWorkGroups((existing) => ({
3443+
...existing,
3444+
[groupId]: !existing[groupId],
3445+
}));
3446+
},
3447+
[cancelPendingStickToBottom],
3448+
);
34433449
const onExpandTimelineImage = useCallback((preview: ExpandedImagePreview) => {
34443450
setExpandedImage(preview);
34453451
}, []);

0 commit comments

Comments
 (0)