🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import { ScrollArea } from '@lobehub/ui';
import type { PropsWithChildren, RefObject } from 'react';
import { memo, useEffect } from 'react';
import { useAutoScroll } from '@/hooks/useAutoScroll';
interface AutoScrollShadowProps extends PropsWithChildren {
/**
* Content string to track for auto-scrolling
*/
content?: string;
/**
* Whether the content is currently streaming/generating
*/
streaming?: boolean;
}
const AutoScrollShadow = memo<AutoScrollShadowProps>(({ children, content, streaming }) => {
const { ref, handleScroll, resetScrollLock } = useAutoScroll<HTMLDivElement>({
deps: [content],
enabled: streaming,
});
// Reset scroll lock when content is cleared (new stream starts)
useEffect(() => {
if (!content) {
resetScrollLock();
}
}, [content, resetScrollLock]);
return (
<ScrollArea
scrollFade
style={{ background: 'transparent', borderRadius: 0 }}
viewportProps={{
ref: ref as RefObject<HTMLDivElement>,
style: { height: 'max(33vh, 480px)' },
onScroll: handleScroll,
}}
>
{children}
</ScrollArea>
);
});
export default AutoScrollShadow;