UNPKG

@promptbook/remote-server

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

45 lines (44 loc) 1.41 kB
import { type UIEvent } from 'react'; /** * Configuration for the auto-scroll behavior. * * @public exported from `@promptbook/components` */ export type ChatAutoScrollConfig = { /** * Threshold in pixels from bottom to consider as "at bottom" * @default 100 */ bottomThreshold?: number; /** * Whether to use smooth scrolling * @default true */ smoothScroll?: boolean; /** * Delay before checking scroll position after new messages (in milliseconds) * @default 100 */ scrollCheckDelay?: number; }; /** * Hook for managing auto-scroll behavior in chat components * * This hook provides: * - Automatic scrolling to bottom when new messages arrive (if user is already at bottom) * - Detection of when user scrolls away from bottom * - Scroll-to-bottom functionality with smooth animation * - Mobile-optimized scrolling behavior * * @public exported from `@promptbook/components` */ export declare function useChatAutoScroll(config?: ChatAutoScrollConfig): { isAutoScrolling: boolean; chatMessagesRef: (element: HTMLDivElement | null) => void; handleScroll: (event: UIEvent<HTMLDivElement, globalThis.UIEvent>) => void; handleMessagesChange: (isStreaming?: boolean | undefined) => void; scrollToBottom: () => void; enableAutoScroll: () => void; disableAutoScroll: () => void; isMobile: boolean; };