mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-08-20 01:09:06 +08:00
feat: add auto-scroll functionality to ScrollContainer and disable auto-scroll after report completed
This commit is contained in:
parent
f35131da19
commit
5f22cfc124
@ -76,6 +76,7 @@ export function MessageListView({
|
||||
<ScrollContainer
|
||||
className={cn("flex h-full w-full flex-col overflow-hidden", className)}
|
||||
scrollShadowColor="var(--app-background)"
|
||||
autoScrollToBottom
|
||||
>
|
||||
<ul className="flex flex-col">
|
||||
{messageIds.map((messageId) => (
|
||||
|
@ -133,6 +133,7 @@ export function ResearchBlock({
|
||||
<ScrollContainer
|
||||
className="px-5pb-20 h-full"
|
||||
scrollShadowColor="var(--card)"
|
||||
autoScrollToBottom={!hasReport || reportStreaming}
|
||||
>
|
||||
{reportId && researchId && (
|
||||
<ResearchReportBlock
|
||||
@ -149,7 +150,11 @@ export function ResearchBlock({
|
||||
forceMount
|
||||
hidden={activeTab !== "activities"}
|
||||
>
|
||||
<ScrollContainer className="h-full" scrollShadowColor="var(--card)">
|
||||
<ScrollContainer
|
||||
className="h-full"
|
||||
scrollShadowColor="var(--card)"
|
||||
autoScrollToBottom={!hasReport || reportStreaming}
|
||||
>
|
||||
{researchId && (
|
||||
<ResearchActivitiesBlock
|
||||
className="mt-4"
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useStickToBottom } from "use-stick-to-bottom";
|
||||
|
||||
import { ScrollArea } from "~/components/ui/scroll-area";
|
||||
@ -11,15 +12,25 @@ export function ScrollContainer({
|
||||
children,
|
||||
scrollShadow = true,
|
||||
scrollShadowColor = "var(--background)",
|
||||
autoScrollToBottom = false,
|
||||
}: {
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
scrollShadow?: boolean;
|
||||
scrollShadowColor?: string;
|
||||
autoScrollToBottom?: boolean;
|
||||
}) {
|
||||
const { scrollRef, contentRef } = useStickToBottom({
|
||||
initial: "instant",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!autoScrollToBottom) {
|
||||
scrollRef.current = null;
|
||||
contentRef.current = null;
|
||||
}
|
||||
}, [autoScrollToBottom, contentRef, scrollRef]);
|
||||
|
||||
return (
|
||||
<div className={cn("relative", className)}>
|
||||
{scrollShadow && (
|
||||
|
Loading…
x
Reference in New Issue
Block a user