@djangocfg/ui-tools 2.1.367 → 2.1.369

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1568,6 +1568,12 @@ interface SessionInfo {
1568
1568
  hasMore?: boolean;
1569
1569
  cursor?: string | null;
1570
1570
  resumed?: boolean;
1571
+ /**
1572
+ * Optional human-readable title (typically derived from the first
1573
+ * user message). Hosts that render a session-list sidebar can read
1574
+ * this directly instead of crawling messages. Plan64.
1575
+ */
1576
+ title?: string;
1571
1577
  }
1572
1578
  interface HistoryPage {
1573
1579
  messages: ChatMessage[];
@@ -1798,6 +1804,16 @@ interface UseChatConfig {
1798
1804
  metadata?: Record<string, unknown>;
1799
1805
  /** Stamped on outgoing user messages as `message.sender`. */
1800
1806
  userPersona?: ChatPersona;
1807
+ /**
1808
+ * Rewrite the outgoing message content right before it hits the
1809
+ * transport — runs after the user bubble is added (so history shows
1810
+ * the original) but before `transport.stream/send`. Sync or async.
1811
+ * Return the original to opt out for that call.
1812
+ *
1813
+ * Use case: strip rich-display chips (e.g. mention links) so the LLM
1814
+ * sees plain text, while the bubble keeps the chip rendering. Plan64.
1815
+ */
1816
+ onBeforeSend?: (content: string) => string | Promise<string>;
1801
1817
  /**
1802
1818
  * Enable verbose dev-mode logging (consola, namespace `chat:*`).
1803
1819
  * Defaults to `isDev` from `@djangocfg/ui-core/lib`. Pass `false` to silence
@@ -1863,9 +1879,15 @@ interface ChatProviderProps {
1863
1879
  audio?: ChatAudioConfig;
1864
1880
  /** Enable verbose dev logging via consola. Defaults to `isDev`. */
1865
1881
  debug?: boolean;
1882
+ /**
1883
+ * Rewrite outgoing message content before it hits the transport.
1884
+ * History bubble keeps the original; useful for stripping rich-
1885
+ * display chips so the LLM sees plain text. See `useChat`.
1886
+ */
1887
+ onBeforeSend?: (content: string) => string | Promise<string>;
1866
1888
  children?: ReactNode;
1867
1889
  }
1868
- declare function ChatProvider({ transport, config, initialSessionId, autoCreateSession, streaming, audio, debug, children, }: ChatProviderProps): react_jsx_runtime.JSX.Element;
1890
+ declare function ChatProvider({ transport, config, initialSessionId, autoCreateSession, streaming, audio, debug, onBeforeSend, children, }: ChatProviderProps): react_jsx_runtime.JSX.Element;
1869
1891
  declare function useChatContext(): ChatContextValue;
1870
1892
  declare function useChatContextOptional(): ChatContextValue | null;
1871
1893
 
@@ -1882,6 +1904,16 @@ interface UseChatComposerOptions {
1882
1904
  size?: number;
1883
1905
  };
1884
1906
  onPasteFiles?: (files: File[]) => void;
1907
+ /**
1908
+ * Persist the current draft to `sessionStorage` under this key. The
1909
+ * draft is loaded once on mount (overrides `initialValue` if non-
1910
+ * empty) and rewritten on every value change. Cleared on `reset()`.
1911
+ *
1912
+ * Pass a per-conversation id to keep separate drafts per chat. Pass
1913
+ * `undefined` (default) to disable persistence — composer behaves
1914
+ * exactly as before. Plan64.
1915
+ */
1916
+ persistKey?: string;
1885
1917
  }
1886
1918
  interface UseChatComposerReturn {
1887
1919
  value: string;
@@ -2204,6 +2236,19 @@ declare class TransportError extends Error {
2204
2236
  constructor(message: string, code?: string);
2205
2237
  }
2206
2238
 
2239
+ /**
2240
+ * @deprecated Plan64. As of ui-tools 2.1.369, `<MessageList>` is
2241
+ * virtualized via react-virtuoso and owns its own scroll viewport.
2242
+ * Sticky-bottom + auto-follow on streaming live inside the component;
2243
+ * use the new `MessageListProps.onAtBottomChange` prop and the
2244
+ * `MessageListHandle.scrollToBottom()` imperative method instead.
2245
+ *
2246
+ * This hook is kept for hosts that render messages outside
2247
+ * `<MessageList>` (e.g. headless story shells, custom non-virtualized
2248
+ * scroll containers). It still works against any HTMLElement scroll
2249
+ * container, but it does NOT integrate with Virtuoso — passing a
2250
+ * Virtuoso-managed element here will read garbage scroll metrics.
2251
+ */
2207
2252
  interface UseChatScrollOptions {
2208
2253
  containerRef: RefObject<HTMLElement | null>;
2209
2254
  bottomRef: RefObject<HTMLElement | null>;
@@ -2338,12 +2383,55 @@ interface MessageListProps {
2338
2383
  renderItem?: (m: ChatMessage, i: number) => ReactNode;
2339
2384
  renderEmpty?: () => ReactNode;
2340
2385
  isLoadingMore?: boolean;
2386
+ /**
2387
+ * Fires when the user scrolls within `topThresholdPx` of the top of
2388
+ * the list — wire to your `loadMore()` here. Replaces the previous
2389
+ * `topSentinelRef` API. The callback is gated by Virtuoso, so it
2390
+ * won't fire repeatedly while a load is in flight (Virtuoso pauses
2391
+ * `startReached` until `data` length grows).
2392
+ */
2393
+ onStartReached?: () => void;
2394
+ /**
2395
+ * @deprecated Kept as a no-op for backwards compatibility — wire
2396
+ * `onStartReached` instead. Virtuoso owns the scroll viewport now,
2397
+ * external sentinels never see scroll events.
2398
+ */
2341
2399
  topSentinelRef?: RefObject<HTMLDivElement | null>;
2400
+ /**
2401
+ * @deprecated Kept as a no-op for backwards compatibility — Virtuoso
2402
+ * exposes `scrollToIndex` via the imperative handle instead. See
2403
+ * `useChatScroll` for the chat-friendly wrapper.
2404
+ */
2342
2405
  bottomRef?: RefObject<HTMLDivElement | null>;
2343
2406
  className?: string;
2344
2407
  itemClassName?: string;
2408
+ /**
2409
+ * Skip virtualization and render through plain `.map()`. Use for
2410
+ * stories / debugging where DevTools needs to see every node, or
2411
+ * when `messages` is guaranteed-tiny. Default: `false` — virtualize
2412
+ * always. Plan64.
2413
+ */
2414
+ noVirtualize?: boolean;
2415
+ /**
2416
+ * Initial item height estimate fed to Virtuoso's first-paint pass.
2417
+ * The library re-measures every item after mount; this just tightens
2418
+ * the initial scrollbar before measurements land. Default `120`.
2419
+ */
2420
+ defaultItemHeight?: number;
2421
+ /**
2422
+ * Fires when the viewport sticky state changes — `true` when the
2423
+ * user is pinned to the bottom (streaming token deltas keep them
2424
+ * there), `false` once they scroll up. Wire to your "Jump to
2425
+ * latest" affordance via the inverse: render the pill when
2426
+ * `!isAtBottom`. Plan64.
2427
+ */
2428
+ onAtBottomChange?: (isAtBottom: boolean) => void;
2429
+ }
2430
+ interface MessageListHandle {
2431
+ scrollToBottom: (smooth?: boolean) => void;
2432
+ scrollToIndex: (index: number, smooth?: boolean) => void;
2345
2433
  }
2346
- declare const MessageList: react.ForwardRefExoticComponent<MessageListProps & react.RefAttributes<HTMLDivElement>>;
2434
+ declare const MessageList: react.ForwardRefExoticComponent<MessageListProps & react.RefAttributes<MessageListHandle>>;
2347
2435
 
2348
2436
  interface MessageBubbleProps {
2349
2437
  message: ChatMessage;
@@ -2375,8 +2463,29 @@ interface MessageBubbleProps {
2375
2463
  onRegenerate?: () => void;
2376
2464
  onEdit?: () => void;
2377
2465
  onDelete?: () => void;
2466
+ /**
2467
+ * Extra content rendered alongside the default copy/regenerate/edit/
2468
+ * delete actions (after them, on the same row). Hosts pass app-
2469
+ * specific affordances here — e.g. "Send to plan", "Add note",
2470
+ * "Open in inspector" — without having to fork `<MessageActions>`.
2471
+ * Receives the message so renderers can branch by id / role / etc.
2472
+ * Plan64.
2473
+ */
2474
+ messageActionsExtra?: (m: ChatMessage) => ReactNode;
2475
+ /**
2476
+ * Override the default streaming indicator (the dots / pulse + tool
2477
+ * activity label). Receives the message so the host can read
2478
+ * `toolActivity`, the running tool call name, etc., and render a
2479
+ * richer affordance ("Running cmd_execute on vps-audi…"). Plan64.
2480
+ *
2481
+ * Renders in two slots: as the in-bubble pre-token affordance, and
2482
+ * as the inline label above the bubble when `toolActivity` is set.
2483
+ * The render-prop is called for both — branch on `m.content` if
2484
+ * you need different behaviour per slot.
2485
+ */
2486
+ streamingIndicator?: (m: ChatMessage) => ReactNode;
2378
2487
  }
2379
- declare const MessageBubble: react.MemoExoticComponent<({ message, isUser: isUserProp, showAvatar, avatarSrc, avatarFallback, user, assistant, showTimestamp, showActions, isCompact, className, beforeContent, afterContent, toolCallsRenderer, toolCallsProps, sourcesRenderer, attachmentsRenderer, attachmentRenderers, onAttachmentOpen, onCopy, onRegenerate, onEdit, onDelete, }: MessageBubbleProps) => react_jsx_runtime.JSX.Element>;
2488
+ declare const MessageBubble: react.MemoExoticComponent<({ message, isUser: isUserProp, showAvatar, avatarSrc, avatarFallback, user, assistant, showTimestamp, showActions, isCompact, className, beforeContent, afterContent, toolCallsRenderer, toolCallsProps, sourcesRenderer, attachmentsRenderer, attachmentRenderers, onAttachmentOpen, onCopy, onRegenerate, onEdit, onDelete, messageActionsExtra, streamingIndicator, }: MessageBubbleProps) => react_jsx_runtime.JSX.Element>;
2380
2489
 
2381
2490
  interface MessageActionsProps {
2382
2491
  role: ChatRole;
@@ -3479,4 +3588,4 @@ declare function useBlobUrlCleanup(key: string | null): void;
3479
3588
  */
3480
3589
  declare function generateContentKey(content: ArrayBuffer): string;
3481
3590
 
3482
- export { type ApiKey, ArrayFieldItemTemplate, ArrayFieldTemplate, type AspectRatioValue, type AttachmentRenderer, type AttachmentRendererArgs, type AttachmentRendererMap, Attachments, AttachmentsGrid, type AttachmentsGridProps, AttachmentsList, type AttachmentsListProps, type AttachmentsProps, Player as AudioPlayer, type PlayerProps as AudioPlayerProps, AudioToggle, type AudioToggleProps, BaseInputTemplate, type BlobSource, CHAT_EVENT_NAME, CSS_VARS, CardLoadingFallback, type ChatAction, type ChatAssistantContext, type ChatAttachment, type ChatAudioConfig, type ChatAudioEvent, type ChatAudioSounds, type ChatConfig, type ChatContextValue, type ChatDisplayMode, type ChatEventDetail, type ChatLabels, type ChatLightboxState, type ChatLogScope, type ChatLogger, type ChatMessage, type ChatPersona, type ChatPrefs, ChatProvider, type ChatProviderProps, type ChatRole, ChatRoot, type ChatRootProps, type ChatSource, type ChatState, type ChatStreamEvent, type ChatToolCall, type ChatTransport, type ChatUserContext, CheckboxWidget, ColorWidget, Composer, type ComposerProps, type CreateLazyComponentOptions, type CreateSessionOptions, type CreateVideoErrorFallbackOptions, CronScheduler, type CronSchedulerContextValue, type CronSchedulerProps, CronSchedulerProvider, type CronSchedulerState, CustomInput, type DASHSource, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, type DataUrlSource, DayChips, DiffEditor, type DiffEditorProps, type DisabledWhenRule, Editor, type EditorContextValue, type EditorFile, type EditorOptions, type EditorProps, EditorProvider, type EditorRef, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorFallbackProps, ErrorListTemplate, FieldTemplate, type HLSSource, HOTKEYS, type HistoryPage, type HttpTransportConfig, type ImageFile, ImageViewer, type ImageViewerProps, type JsonFormContext, type JsonFormDensity, JsonSchemaForm, type JsonSchemaFormProps, JsonTreeComponent as JsonTree, type JsonTreeConfig, type JsonTreeProps, JumpToLatest, type JumpToLatestProps, LIMITS, LazyPlayer as LazyAudioPlayer, LazyChat, type ChatRootProps as LazyChatProps, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, TreeRootProps as LazyTreeProps, LazyVideoPlayer, LazyWrapper, type LazyWrapperProps, type LinkRule, LoadingFallback, type LoadingFallbackProps, type LottieDirection, LottiePlayer, type LottiePlayerProps, type LottieSize, type LottieSpeed, type MapContainerProps, MapLoadingFallback, type MapStyleKey, type MapViewport, MarkdownEditor, type MarkdownEditorProps, MarkdownMessage, type MarkdownMessageProps, type MarkerData, type MentionAttrs, type MentionConfig, type MentionItem, type MentionMarkdownRenderer, Mermaid, type MermaidProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageList, type MessageListProps, type MockTransportOptions, type MonthDay, MonthDayGrid, NativeProvider, NumberWidget, ObjectFieldTemplate, Playground as OpenapiViewer, type ParseSSEOptions, type PlayerMode, type PlaygroundConfig, type PlaygroundProps$1 as PlaygroundProps, PrettyCode, type PrettyCodeProps$1 as PrettyCodeProps, type ResolveFileSourceOptions, STORAGE_KEYS, SchedulePreview, type ScheduleType, ScheduleTypeSelector, type SchemaSource, SelectWidget, type SendOptions, type SessionInfo, type SimpleStreamSource, SliderWidget, Sources, type SourcesProps, Spinner, type StreamOptions, StreamProvider, type StreamSource, StreamingIndicator, type StreamingIndicatorProps, SwitchWidget, TextWidget, TimeSelector, type TokenBuffer, ToolCalls, type ToolCallsProps, type ToolPayloadFallback, type ToolPayloadKind, type ToolPayloadMatcher, TransportError, TreeRootProps, type UiGroup, type UrlSource, type UseChatAudioReturn, type UseChatComposerOptions, type UseChatComposerReturn, type UseChatConfig, type UseChatHistoryOptions, type UseChatLayoutConfig, type UseChatLayoutReturn, type UseChatLightboxReturn, type UseChatReturn, type UseChatScrollOptions, type UseChatScrollReturn, type UseCollapsibleContentOptions, type UseCollapsibleContentResult, type UseEditorReturn, type UseLottieOptions, type UseLottieReturn, type UseMonacoReturn, VideoControls, VideoErrorFallback, type VideoErrorFallbackProps, VideoPlayer, type VideoPlayerContextValue, type VideoPlayerProps, VideoPlayerProvider, type VideoPlayerProviderProps, type VideoPlayerRef, type VideoSourceUnion, VidstackProvider, type VimeoSource, type WeekDay, type YouTubeSource, buildCron, collectImageAttachments, createHttpTransport, createId, createLazyComponent, createMockTransport, createTokenBuffer, createVideoErrorFallback, deriveInitials, dispatchToolPayload, evaluateDisabledWhen, extractTextFromChildren, generateContentKey, getChatLogger, getRequiredFields, hasRequiredFields, humanizeCron, initialState, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isSimpleStreamSource, isStringValue, isValidCron, mentionPresets, mergeDefaults, normalizeFormData, parseCron, parseSSE, reducer, resolveFileSource, resolvePersona, resolvePlayerMode, resolveStreamSource, safeJsonParse, safeJsonStringify, useAudioCache, useBlobUrlCleanup, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatLightbox, useChatScroll, useCollapsibleContent, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays, useEditor, useEditorContext, useImageCache, useLanguage, useLottie, useMediaCacheStore, useMonaco, useVideoCache, useVideoPlayerContext, useVideoPlayerSettings, validateRequiredFields, validateSchema };
3591
+ export { type ApiKey, ArrayFieldItemTemplate, ArrayFieldTemplate, type AspectRatioValue, type AttachmentRenderer, type AttachmentRendererArgs, type AttachmentRendererMap, Attachments, AttachmentsGrid, type AttachmentsGridProps, AttachmentsList, type AttachmentsListProps, type AttachmentsProps, Player as AudioPlayer, type PlayerProps as AudioPlayerProps, AudioToggle, type AudioToggleProps, BaseInputTemplate, type BlobSource, CHAT_EVENT_NAME, CSS_VARS, CardLoadingFallback, type ChatAction, type ChatAssistantContext, type ChatAttachment, type ChatAudioConfig, type ChatAudioEvent, type ChatAudioSounds, type ChatConfig, type ChatContextValue, type ChatDisplayMode, type ChatEventDetail, type ChatLabels, type ChatLightboxState, type ChatLogScope, type ChatLogger, type ChatMessage, type ChatPersona, type ChatPrefs, ChatProvider, type ChatProviderProps, type ChatRole, ChatRoot, type ChatRootProps, type ChatSource, type ChatState, type ChatStreamEvent, type ChatToolCall, type ChatTransport, type ChatUserContext, CheckboxWidget, ColorWidget, Composer, type ComposerProps, type CreateLazyComponentOptions, type CreateSessionOptions, type CreateVideoErrorFallbackOptions, CronScheduler, type CronSchedulerContextValue, type CronSchedulerProps, CronSchedulerProvider, type CronSchedulerState, CustomInput, type DASHSource, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, type DataUrlSource, DayChips, DiffEditor, type DiffEditorProps, type DisabledWhenRule, Editor, type EditorContextValue, type EditorFile, type EditorOptions, type EditorProps, EditorProvider, type EditorRef, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorFallbackProps, ErrorListTemplate, FieldTemplate, type HLSSource, HOTKEYS, type HistoryPage, type HttpTransportConfig, type ImageFile, ImageViewer, type ImageViewerProps, type JsonFormContext, type JsonFormDensity, JsonSchemaForm, type JsonSchemaFormProps, JsonTreeComponent as JsonTree, type JsonTreeConfig, type JsonTreeProps, JumpToLatest, type JumpToLatestProps, LIMITS, LazyPlayer as LazyAudioPlayer, LazyChat, type ChatRootProps as LazyChatProps, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, TreeRootProps as LazyTreeProps, LazyVideoPlayer, LazyWrapper, type LazyWrapperProps, type LinkRule, LoadingFallback, type LoadingFallbackProps, type LottieDirection, LottiePlayer, type LottiePlayerProps, type LottieSize, type LottieSpeed, type MapContainerProps, MapLoadingFallback, type MapStyleKey, type MapViewport, MarkdownEditor, type MarkdownEditorProps, MarkdownMessage, type MarkdownMessageProps, type MarkerData, type MentionAttrs, type MentionConfig, type MentionItem, type MentionMarkdownRenderer, Mermaid, type MermaidProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageList, type MessageListHandle, type MessageListProps, type MockTransportOptions, type MonthDay, MonthDayGrid, NativeProvider, NumberWidget, ObjectFieldTemplate, Playground as OpenapiViewer, type ParseSSEOptions, type PlayerMode, type PlaygroundConfig, type PlaygroundProps$1 as PlaygroundProps, PrettyCode, type PrettyCodeProps$1 as PrettyCodeProps, type ResolveFileSourceOptions, STORAGE_KEYS, SchedulePreview, type ScheduleType, ScheduleTypeSelector, type SchemaSource, SelectWidget, type SendOptions, type SessionInfo, type SimpleStreamSource, SliderWidget, Sources, type SourcesProps, Spinner, type StreamOptions, StreamProvider, type StreamSource, StreamingIndicator, type StreamingIndicatorProps, SwitchWidget, TextWidget, TimeSelector, type TokenBuffer, ToolCalls, type ToolCallsProps, type ToolPayloadFallback, type ToolPayloadKind, type ToolPayloadMatcher, TransportError, TreeRootProps, type UiGroup, type UrlSource, type UseChatAudioReturn, type UseChatComposerOptions, type UseChatComposerReturn, type UseChatConfig, type UseChatHistoryOptions, type UseChatLayoutConfig, type UseChatLayoutReturn, type UseChatLightboxReturn, type UseChatReturn, type UseChatScrollOptions, type UseChatScrollReturn, type UseCollapsibleContentOptions, type UseCollapsibleContentResult, type UseEditorReturn, type UseLottieOptions, type UseLottieReturn, type UseMonacoReturn, VideoControls, VideoErrorFallback, type VideoErrorFallbackProps, VideoPlayer, type VideoPlayerContextValue, type VideoPlayerProps, VideoPlayerProvider, type VideoPlayerProviderProps, type VideoPlayerRef, type VideoSourceUnion, VidstackProvider, type VimeoSource, type WeekDay, type YouTubeSource, buildCron, collectImageAttachments, createHttpTransport, createId, createLazyComponent, createMockTransport, createTokenBuffer, createVideoErrorFallback, deriveInitials, dispatchToolPayload, evaluateDisabledWhen, extractTextFromChildren, generateContentKey, getChatLogger, getRequiredFields, hasRequiredFields, humanizeCron, initialState, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isSimpleStreamSource, isStringValue, isValidCron, mentionPresets, mergeDefaults, normalizeFormData, parseCron, parseSSE, reducer, resolveFileSource, resolvePersona, resolvePlayerMode, resolveStreamSource, safeJsonParse, safeJsonStringify, useAudioCache, useBlobUrlCleanup, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatLightbox, useChatScroll, useCollapsibleContent, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays, useEditor, useEditorContext, useImageCache, useLanguage, useLottie, useMediaCacheStore, useMonaco, useVideoCache, useVideoPlayerContext, useVideoPlayerSettings, validateRequiredFields, validateSchema };
package/dist/index.d.ts CHANGED
@@ -1568,6 +1568,12 @@ interface SessionInfo {
1568
1568
  hasMore?: boolean;
1569
1569
  cursor?: string | null;
1570
1570
  resumed?: boolean;
1571
+ /**
1572
+ * Optional human-readable title (typically derived from the first
1573
+ * user message). Hosts that render a session-list sidebar can read
1574
+ * this directly instead of crawling messages. Plan64.
1575
+ */
1576
+ title?: string;
1571
1577
  }
1572
1578
  interface HistoryPage {
1573
1579
  messages: ChatMessage[];
@@ -1798,6 +1804,16 @@ interface UseChatConfig {
1798
1804
  metadata?: Record<string, unknown>;
1799
1805
  /** Stamped on outgoing user messages as `message.sender`. */
1800
1806
  userPersona?: ChatPersona;
1807
+ /**
1808
+ * Rewrite the outgoing message content right before it hits the
1809
+ * transport — runs after the user bubble is added (so history shows
1810
+ * the original) but before `transport.stream/send`. Sync or async.
1811
+ * Return the original to opt out for that call.
1812
+ *
1813
+ * Use case: strip rich-display chips (e.g. mention links) so the LLM
1814
+ * sees plain text, while the bubble keeps the chip rendering. Plan64.
1815
+ */
1816
+ onBeforeSend?: (content: string) => string | Promise<string>;
1801
1817
  /**
1802
1818
  * Enable verbose dev-mode logging (consola, namespace `chat:*`).
1803
1819
  * Defaults to `isDev` from `@djangocfg/ui-core/lib`. Pass `false` to silence
@@ -1863,9 +1879,15 @@ interface ChatProviderProps {
1863
1879
  audio?: ChatAudioConfig;
1864
1880
  /** Enable verbose dev logging via consola. Defaults to `isDev`. */
1865
1881
  debug?: boolean;
1882
+ /**
1883
+ * Rewrite outgoing message content before it hits the transport.
1884
+ * History bubble keeps the original; useful for stripping rich-
1885
+ * display chips so the LLM sees plain text. See `useChat`.
1886
+ */
1887
+ onBeforeSend?: (content: string) => string | Promise<string>;
1866
1888
  children?: ReactNode;
1867
1889
  }
1868
- declare function ChatProvider({ transport, config, initialSessionId, autoCreateSession, streaming, audio, debug, children, }: ChatProviderProps): react_jsx_runtime.JSX.Element;
1890
+ declare function ChatProvider({ transport, config, initialSessionId, autoCreateSession, streaming, audio, debug, onBeforeSend, children, }: ChatProviderProps): react_jsx_runtime.JSX.Element;
1869
1891
  declare function useChatContext(): ChatContextValue;
1870
1892
  declare function useChatContextOptional(): ChatContextValue | null;
1871
1893
 
@@ -1882,6 +1904,16 @@ interface UseChatComposerOptions {
1882
1904
  size?: number;
1883
1905
  };
1884
1906
  onPasteFiles?: (files: File[]) => void;
1907
+ /**
1908
+ * Persist the current draft to `sessionStorage` under this key. The
1909
+ * draft is loaded once on mount (overrides `initialValue` if non-
1910
+ * empty) and rewritten on every value change. Cleared on `reset()`.
1911
+ *
1912
+ * Pass a per-conversation id to keep separate drafts per chat. Pass
1913
+ * `undefined` (default) to disable persistence — composer behaves
1914
+ * exactly as before. Plan64.
1915
+ */
1916
+ persistKey?: string;
1885
1917
  }
1886
1918
  interface UseChatComposerReturn {
1887
1919
  value: string;
@@ -2204,6 +2236,19 @@ declare class TransportError extends Error {
2204
2236
  constructor(message: string, code?: string);
2205
2237
  }
2206
2238
 
2239
+ /**
2240
+ * @deprecated Plan64. As of ui-tools 2.1.369, `<MessageList>` is
2241
+ * virtualized via react-virtuoso and owns its own scroll viewport.
2242
+ * Sticky-bottom + auto-follow on streaming live inside the component;
2243
+ * use the new `MessageListProps.onAtBottomChange` prop and the
2244
+ * `MessageListHandle.scrollToBottom()` imperative method instead.
2245
+ *
2246
+ * This hook is kept for hosts that render messages outside
2247
+ * `<MessageList>` (e.g. headless story shells, custom non-virtualized
2248
+ * scroll containers). It still works against any HTMLElement scroll
2249
+ * container, but it does NOT integrate with Virtuoso — passing a
2250
+ * Virtuoso-managed element here will read garbage scroll metrics.
2251
+ */
2207
2252
  interface UseChatScrollOptions {
2208
2253
  containerRef: RefObject<HTMLElement | null>;
2209
2254
  bottomRef: RefObject<HTMLElement | null>;
@@ -2338,12 +2383,55 @@ interface MessageListProps {
2338
2383
  renderItem?: (m: ChatMessage, i: number) => ReactNode;
2339
2384
  renderEmpty?: () => ReactNode;
2340
2385
  isLoadingMore?: boolean;
2386
+ /**
2387
+ * Fires when the user scrolls within `topThresholdPx` of the top of
2388
+ * the list — wire to your `loadMore()` here. Replaces the previous
2389
+ * `topSentinelRef` API. The callback is gated by Virtuoso, so it
2390
+ * won't fire repeatedly while a load is in flight (Virtuoso pauses
2391
+ * `startReached` until `data` length grows).
2392
+ */
2393
+ onStartReached?: () => void;
2394
+ /**
2395
+ * @deprecated Kept as a no-op for backwards compatibility — wire
2396
+ * `onStartReached` instead. Virtuoso owns the scroll viewport now,
2397
+ * external sentinels never see scroll events.
2398
+ */
2341
2399
  topSentinelRef?: RefObject<HTMLDivElement | null>;
2400
+ /**
2401
+ * @deprecated Kept as a no-op for backwards compatibility — Virtuoso
2402
+ * exposes `scrollToIndex` via the imperative handle instead. See
2403
+ * `useChatScroll` for the chat-friendly wrapper.
2404
+ */
2342
2405
  bottomRef?: RefObject<HTMLDivElement | null>;
2343
2406
  className?: string;
2344
2407
  itemClassName?: string;
2408
+ /**
2409
+ * Skip virtualization and render through plain `.map()`. Use for
2410
+ * stories / debugging where DevTools needs to see every node, or
2411
+ * when `messages` is guaranteed-tiny. Default: `false` — virtualize
2412
+ * always. Plan64.
2413
+ */
2414
+ noVirtualize?: boolean;
2415
+ /**
2416
+ * Initial item height estimate fed to Virtuoso's first-paint pass.
2417
+ * The library re-measures every item after mount; this just tightens
2418
+ * the initial scrollbar before measurements land. Default `120`.
2419
+ */
2420
+ defaultItemHeight?: number;
2421
+ /**
2422
+ * Fires when the viewport sticky state changes — `true` when the
2423
+ * user is pinned to the bottom (streaming token deltas keep them
2424
+ * there), `false` once they scroll up. Wire to your "Jump to
2425
+ * latest" affordance via the inverse: render the pill when
2426
+ * `!isAtBottom`. Plan64.
2427
+ */
2428
+ onAtBottomChange?: (isAtBottom: boolean) => void;
2429
+ }
2430
+ interface MessageListHandle {
2431
+ scrollToBottom: (smooth?: boolean) => void;
2432
+ scrollToIndex: (index: number, smooth?: boolean) => void;
2345
2433
  }
2346
- declare const MessageList: react.ForwardRefExoticComponent<MessageListProps & react.RefAttributes<HTMLDivElement>>;
2434
+ declare const MessageList: react.ForwardRefExoticComponent<MessageListProps & react.RefAttributes<MessageListHandle>>;
2347
2435
 
2348
2436
  interface MessageBubbleProps {
2349
2437
  message: ChatMessage;
@@ -2375,8 +2463,29 @@ interface MessageBubbleProps {
2375
2463
  onRegenerate?: () => void;
2376
2464
  onEdit?: () => void;
2377
2465
  onDelete?: () => void;
2466
+ /**
2467
+ * Extra content rendered alongside the default copy/regenerate/edit/
2468
+ * delete actions (after them, on the same row). Hosts pass app-
2469
+ * specific affordances here — e.g. "Send to plan", "Add note",
2470
+ * "Open in inspector" — without having to fork `<MessageActions>`.
2471
+ * Receives the message so renderers can branch by id / role / etc.
2472
+ * Plan64.
2473
+ */
2474
+ messageActionsExtra?: (m: ChatMessage) => ReactNode;
2475
+ /**
2476
+ * Override the default streaming indicator (the dots / pulse + tool
2477
+ * activity label). Receives the message so the host can read
2478
+ * `toolActivity`, the running tool call name, etc., and render a
2479
+ * richer affordance ("Running cmd_execute on vps-audi…"). Plan64.
2480
+ *
2481
+ * Renders in two slots: as the in-bubble pre-token affordance, and
2482
+ * as the inline label above the bubble when `toolActivity` is set.
2483
+ * The render-prop is called for both — branch on `m.content` if
2484
+ * you need different behaviour per slot.
2485
+ */
2486
+ streamingIndicator?: (m: ChatMessage) => ReactNode;
2378
2487
  }
2379
- declare const MessageBubble: react.MemoExoticComponent<({ message, isUser: isUserProp, showAvatar, avatarSrc, avatarFallback, user, assistant, showTimestamp, showActions, isCompact, className, beforeContent, afterContent, toolCallsRenderer, toolCallsProps, sourcesRenderer, attachmentsRenderer, attachmentRenderers, onAttachmentOpen, onCopy, onRegenerate, onEdit, onDelete, }: MessageBubbleProps) => react_jsx_runtime.JSX.Element>;
2488
+ declare const MessageBubble: react.MemoExoticComponent<({ message, isUser: isUserProp, showAvatar, avatarSrc, avatarFallback, user, assistant, showTimestamp, showActions, isCompact, className, beforeContent, afterContent, toolCallsRenderer, toolCallsProps, sourcesRenderer, attachmentsRenderer, attachmentRenderers, onAttachmentOpen, onCopy, onRegenerate, onEdit, onDelete, messageActionsExtra, streamingIndicator, }: MessageBubbleProps) => react_jsx_runtime.JSX.Element>;
2380
2489
 
2381
2490
  interface MessageActionsProps {
2382
2491
  role: ChatRole;
@@ -3479,4 +3588,4 @@ declare function useBlobUrlCleanup(key: string | null): void;
3479
3588
  */
3480
3589
  declare function generateContentKey(content: ArrayBuffer): string;
3481
3590
 
3482
- export { type ApiKey, ArrayFieldItemTemplate, ArrayFieldTemplate, type AspectRatioValue, type AttachmentRenderer, type AttachmentRendererArgs, type AttachmentRendererMap, Attachments, AttachmentsGrid, type AttachmentsGridProps, AttachmentsList, type AttachmentsListProps, type AttachmentsProps, Player as AudioPlayer, type PlayerProps as AudioPlayerProps, AudioToggle, type AudioToggleProps, BaseInputTemplate, type BlobSource, CHAT_EVENT_NAME, CSS_VARS, CardLoadingFallback, type ChatAction, type ChatAssistantContext, type ChatAttachment, type ChatAudioConfig, type ChatAudioEvent, type ChatAudioSounds, type ChatConfig, type ChatContextValue, type ChatDisplayMode, type ChatEventDetail, type ChatLabels, type ChatLightboxState, type ChatLogScope, type ChatLogger, type ChatMessage, type ChatPersona, type ChatPrefs, ChatProvider, type ChatProviderProps, type ChatRole, ChatRoot, type ChatRootProps, type ChatSource, type ChatState, type ChatStreamEvent, type ChatToolCall, type ChatTransport, type ChatUserContext, CheckboxWidget, ColorWidget, Composer, type ComposerProps, type CreateLazyComponentOptions, type CreateSessionOptions, type CreateVideoErrorFallbackOptions, CronScheduler, type CronSchedulerContextValue, type CronSchedulerProps, CronSchedulerProvider, type CronSchedulerState, CustomInput, type DASHSource, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, type DataUrlSource, DayChips, DiffEditor, type DiffEditorProps, type DisabledWhenRule, Editor, type EditorContextValue, type EditorFile, type EditorOptions, type EditorProps, EditorProvider, type EditorRef, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorFallbackProps, ErrorListTemplate, FieldTemplate, type HLSSource, HOTKEYS, type HistoryPage, type HttpTransportConfig, type ImageFile, ImageViewer, type ImageViewerProps, type JsonFormContext, type JsonFormDensity, JsonSchemaForm, type JsonSchemaFormProps, JsonTreeComponent as JsonTree, type JsonTreeConfig, type JsonTreeProps, JumpToLatest, type JumpToLatestProps, LIMITS, LazyPlayer as LazyAudioPlayer, LazyChat, type ChatRootProps as LazyChatProps, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, TreeRootProps as LazyTreeProps, LazyVideoPlayer, LazyWrapper, type LazyWrapperProps, type LinkRule, LoadingFallback, type LoadingFallbackProps, type LottieDirection, LottiePlayer, type LottiePlayerProps, type LottieSize, type LottieSpeed, type MapContainerProps, MapLoadingFallback, type MapStyleKey, type MapViewport, MarkdownEditor, type MarkdownEditorProps, MarkdownMessage, type MarkdownMessageProps, type MarkerData, type MentionAttrs, type MentionConfig, type MentionItem, type MentionMarkdownRenderer, Mermaid, type MermaidProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageList, type MessageListProps, type MockTransportOptions, type MonthDay, MonthDayGrid, NativeProvider, NumberWidget, ObjectFieldTemplate, Playground as OpenapiViewer, type ParseSSEOptions, type PlayerMode, type PlaygroundConfig, type PlaygroundProps$1 as PlaygroundProps, PrettyCode, type PrettyCodeProps$1 as PrettyCodeProps, type ResolveFileSourceOptions, STORAGE_KEYS, SchedulePreview, type ScheduleType, ScheduleTypeSelector, type SchemaSource, SelectWidget, type SendOptions, type SessionInfo, type SimpleStreamSource, SliderWidget, Sources, type SourcesProps, Spinner, type StreamOptions, StreamProvider, type StreamSource, StreamingIndicator, type StreamingIndicatorProps, SwitchWidget, TextWidget, TimeSelector, type TokenBuffer, ToolCalls, type ToolCallsProps, type ToolPayloadFallback, type ToolPayloadKind, type ToolPayloadMatcher, TransportError, TreeRootProps, type UiGroup, type UrlSource, type UseChatAudioReturn, type UseChatComposerOptions, type UseChatComposerReturn, type UseChatConfig, type UseChatHistoryOptions, type UseChatLayoutConfig, type UseChatLayoutReturn, type UseChatLightboxReturn, type UseChatReturn, type UseChatScrollOptions, type UseChatScrollReturn, type UseCollapsibleContentOptions, type UseCollapsibleContentResult, type UseEditorReturn, type UseLottieOptions, type UseLottieReturn, type UseMonacoReturn, VideoControls, VideoErrorFallback, type VideoErrorFallbackProps, VideoPlayer, type VideoPlayerContextValue, type VideoPlayerProps, VideoPlayerProvider, type VideoPlayerProviderProps, type VideoPlayerRef, type VideoSourceUnion, VidstackProvider, type VimeoSource, type WeekDay, type YouTubeSource, buildCron, collectImageAttachments, createHttpTransport, createId, createLazyComponent, createMockTransport, createTokenBuffer, createVideoErrorFallback, deriveInitials, dispatchToolPayload, evaluateDisabledWhen, extractTextFromChildren, generateContentKey, getChatLogger, getRequiredFields, hasRequiredFields, humanizeCron, initialState, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isSimpleStreamSource, isStringValue, isValidCron, mentionPresets, mergeDefaults, normalizeFormData, parseCron, parseSSE, reducer, resolveFileSource, resolvePersona, resolvePlayerMode, resolveStreamSource, safeJsonParse, safeJsonStringify, useAudioCache, useBlobUrlCleanup, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatLightbox, useChatScroll, useCollapsibleContent, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays, useEditor, useEditorContext, useImageCache, useLanguage, useLottie, useMediaCacheStore, useMonaco, useVideoCache, useVideoPlayerContext, useVideoPlayerSettings, validateRequiredFields, validateSchema };
3591
+ export { type ApiKey, ArrayFieldItemTemplate, ArrayFieldTemplate, type AspectRatioValue, type AttachmentRenderer, type AttachmentRendererArgs, type AttachmentRendererMap, Attachments, AttachmentsGrid, type AttachmentsGridProps, AttachmentsList, type AttachmentsListProps, type AttachmentsProps, Player as AudioPlayer, type PlayerProps as AudioPlayerProps, AudioToggle, type AudioToggleProps, BaseInputTemplate, type BlobSource, CHAT_EVENT_NAME, CSS_VARS, CardLoadingFallback, type ChatAction, type ChatAssistantContext, type ChatAttachment, type ChatAudioConfig, type ChatAudioEvent, type ChatAudioSounds, type ChatConfig, type ChatContextValue, type ChatDisplayMode, type ChatEventDetail, type ChatLabels, type ChatLightboxState, type ChatLogScope, type ChatLogger, type ChatMessage, type ChatPersona, type ChatPrefs, ChatProvider, type ChatProviderProps, type ChatRole, ChatRoot, type ChatRootProps, type ChatSource, type ChatState, type ChatStreamEvent, type ChatToolCall, type ChatTransport, type ChatUserContext, CheckboxWidget, ColorWidget, Composer, type ComposerProps, type CreateLazyComponentOptions, type CreateSessionOptions, type CreateVideoErrorFallbackOptions, CronScheduler, type CronSchedulerContextValue, type CronSchedulerProps, CronSchedulerProvider, type CronSchedulerState, CustomInput, type DASHSource, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, type DataUrlSource, DayChips, DiffEditor, type DiffEditorProps, type DisabledWhenRule, Editor, type EditorContextValue, type EditorFile, type EditorOptions, type EditorProps, EditorProvider, type EditorRef, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorFallbackProps, ErrorListTemplate, FieldTemplate, type HLSSource, HOTKEYS, type HistoryPage, type HttpTransportConfig, type ImageFile, ImageViewer, type ImageViewerProps, type JsonFormContext, type JsonFormDensity, JsonSchemaForm, type JsonSchemaFormProps, JsonTreeComponent as JsonTree, type JsonTreeConfig, type JsonTreeProps, JumpToLatest, type JumpToLatestProps, LIMITS, LazyPlayer as LazyAudioPlayer, LazyChat, type ChatRootProps as LazyChatProps, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, TreeRootProps as LazyTreeProps, LazyVideoPlayer, LazyWrapper, type LazyWrapperProps, type LinkRule, LoadingFallback, type LoadingFallbackProps, type LottieDirection, LottiePlayer, type LottiePlayerProps, type LottieSize, type LottieSpeed, type MapContainerProps, MapLoadingFallback, type MapStyleKey, type MapViewport, MarkdownEditor, type MarkdownEditorProps, MarkdownMessage, type MarkdownMessageProps, type MarkerData, type MentionAttrs, type MentionConfig, type MentionItem, type MentionMarkdownRenderer, Mermaid, type MermaidProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageList, type MessageListHandle, type MessageListProps, type MockTransportOptions, type MonthDay, MonthDayGrid, NativeProvider, NumberWidget, ObjectFieldTemplate, Playground as OpenapiViewer, type ParseSSEOptions, type PlayerMode, type PlaygroundConfig, type PlaygroundProps$1 as PlaygroundProps, PrettyCode, type PrettyCodeProps$1 as PrettyCodeProps, type ResolveFileSourceOptions, STORAGE_KEYS, SchedulePreview, type ScheduleType, ScheduleTypeSelector, type SchemaSource, SelectWidget, type SendOptions, type SessionInfo, type SimpleStreamSource, SliderWidget, Sources, type SourcesProps, Spinner, type StreamOptions, StreamProvider, type StreamSource, StreamingIndicator, type StreamingIndicatorProps, SwitchWidget, TextWidget, TimeSelector, type TokenBuffer, ToolCalls, type ToolCallsProps, type ToolPayloadFallback, type ToolPayloadKind, type ToolPayloadMatcher, TransportError, TreeRootProps, type UiGroup, type UrlSource, type UseChatAudioReturn, type UseChatComposerOptions, type UseChatComposerReturn, type UseChatConfig, type UseChatHistoryOptions, type UseChatLayoutConfig, type UseChatLayoutReturn, type UseChatLightboxReturn, type UseChatReturn, type UseChatScrollOptions, type UseChatScrollReturn, type UseCollapsibleContentOptions, type UseCollapsibleContentResult, type UseEditorReturn, type UseLottieOptions, type UseLottieReturn, type UseMonacoReturn, VideoControls, VideoErrorFallback, type VideoErrorFallbackProps, VideoPlayer, type VideoPlayerContextValue, type VideoPlayerProps, VideoPlayerProvider, type VideoPlayerProviderProps, type VideoPlayerRef, type VideoSourceUnion, VidstackProvider, type VimeoSource, type WeekDay, type YouTubeSource, buildCron, collectImageAttachments, createHttpTransport, createId, createLazyComponent, createMockTransport, createTokenBuffer, createVideoErrorFallback, deriveInitials, dispatchToolPayload, evaluateDisabledWhen, extractTextFromChildren, generateContentKey, getChatLogger, getRequiredFields, hasRequiredFields, humanizeCron, initialState, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isSimpleStreamSource, isStringValue, isValidCron, mentionPresets, mergeDefaults, normalizeFormData, parseCron, parseSSE, reducer, resolveFileSource, resolvePersona, resolvePlayerMode, resolveStreamSource, safeJsonParse, safeJsonStringify, useAudioCache, useBlobUrlCleanup, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatLightbox, useChatScroll, useCollapsibleContent, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays, useEditor, useEditorContext, useImageCache, useLanguage, useLottie, useMediaCacheStore, useMonaco, useVideoCache, useVideoPlayerContext, useVideoPlayerSettings, validateRequiredFields, validateSchema };
package/dist/index.mjs CHANGED
@@ -5,8 +5,8 @@ export { NativeProvider, StreamProvider, VideoControls, VideoErrorFallback, Vide
5
5
  export { ImageViewer } from './chunk-OBRSGM64.mjs';
6
6
  export { generateContentKey, useAudioCache, useBlobUrlCleanup, useImageCache, useMediaCacheStore, useVideoCache, useVideoPlayerSettings } from './chunk-C6GXVH5J.mjs';
7
7
  export { CronSchedulerProvider, CustomInput, DayChips, MonthDayGrid, SchedulePreview, ScheduleTypeSelector, TimeSelector, buildCron, humanizeCron, isValidCron, parseCron, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays } from './chunk-PVAX67JG.mjs';
8
- import { LIMITS, createId, useChatAudioPrefs, useChatContextOptional } from './chunk-WGU5BEZX.mjs';
9
- export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, reducer, resolvePersona, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatHistory, useChatLayout, useChatScroll } from './chunk-WGU5BEZX.mjs';
8
+ import { LIMITS, createId, useChatAudioPrefs, useChatContextOptional } from './chunk-YLIYXSUO.mjs';
9
+ export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, reducer, resolvePersona, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatLayout } from './chunk-YLIYXSUO.mjs';
10
10
  export { TreeError, TreeSkeleton, createDemoTree } from './chunk-B6IR5KSC.mjs';
11
11
  export { DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, TreeRoot as Tree, TreeChevron, TreeContent, TreeEmpty, TreeIcon, TreeIndentGuides, TreeLabel, TreeProvider, TreeRoot, TreeRow, TreeSearchInput, appearanceToStyle, clearTreeState, createChildCache, flattenTree, loadTreeState, resolveAppearance, resolveChildren, saveTreeState, useTreeActions, useTreeContext, useTreeExpansion, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead } from './chunk-ZL7FH4NW.mjs';
12
12
  import { PlaygroundProvider } from './chunk-Y6UTOBF6.mjs';
@@ -348,7 +348,7 @@ var LazyTree = createLazyComponent(
348
348
  }
349
349
  );
350
350
  var LazyChat = createLazyComponent(
351
- () => import('./ChatRoot-6U7633X3.mjs').then((m) => ({ default: m.ChatRoot })),
351
+ () => import('./ChatRoot-DENECC2Q.mjs').then((m) => ({ default: m.ChatRoot })),
352
352
  {
353
353
  displayName: "LazyChat",
354
354
  fallback: /* @__PURE__ */ jsx(LoadingFallback, { minHeight: 320, text: "Loading chat\u2026" })
@@ -650,6 +650,138 @@ function createMockTransport(opts = {}) {
650
650
  };
651
651
  }
652
652
  __name(createMockTransport, "createMockTransport");
653
+ function useChatScroll(options) {
654
+ const {
655
+ containerRef,
656
+ bottomRef,
657
+ isStreaming = false,
658
+ bottomThresholdPx = 80,
659
+ messagesCount = 0
660
+ } = options;
661
+ const [isAtBottom, setIsAtBottom] = useState(true);
662
+ const [unreadCount, setUnreadCount] = useState(0);
663
+ const lastCountRef = useRef(messagesCount);
664
+ const stickyRef = useRef(true);
665
+ const wasStreamingRef = useRef(isStreaming);
666
+ const scrollToBottom = useCallback(
667
+ (smooth = false) => {
668
+ const el = containerRef.current;
669
+ if (!el) return;
670
+ el.scrollTo({
671
+ top: el.scrollHeight,
672
+ behavior: smooth ? "smooth" : "auto"
673
+ });
674
+ stickyRef.current = true;
675
+ setIsAtBottom(true);
676
+ setUnreadCount(0);
677
+ },
678
+ [containerRef]
679
+ );
680
+ const resetUnread = useCallback(() => setUnreadCount(0), []);
681
+ useEffect(() => {
682
+ const el = containerRef.current;
683
+ if (!el) return;
684
+ const onScroll = /* @__PURE__ */ __name(() => {
685
+ const distance = el.scrollHeight - el.scrollTop - el.clientHeight;
686
+ const atBottom = distance <= bottomThresholdPx;
687
+ stickyRef.current = atBottom;
688
+ setIsAtBottom(atBottom);
689
+ if (atBottom) setUnreadCount(0);
690
+ }, "onScroll");
691
+ onScroll();
692
+ el.addEventListener("scroll", onScroll, { passive: true });
693
+ return () => {
694
+ el.removeEventListener("scroll", onScroll);
695
+ };
696
+ }, [containerRef, bottomThresholdPx]);
697
+ useEffect(() => {
698
+ const el = containerRef.current;
699
+ if (!el) return;
700
+ if (isStreaming) {
701
+ wasStreamingRef.current = true;
702
+ if (!stickyRef.current) return;
703
+ let raf = 0;
704
+ const tick = /* @__PURE__ */ __name(() => {
705
+ if (!stickyRef.current) return;
706
+ el.scrollTop = el.scrollHeight;
707
+ raf = requestAnimationFrame(tick);
708
+ }, "tick");
709
+ raf = requestAnimationFrame(tick);
710
+ return () => cancelAnimationFrame(raf);
711
+ }
712
+ if (wasStreamingRef.current && stickyRef.current) {
713
+ wasStreamingRef.current = false;
714
+ let raf1 = 0;
715
+ let raf2 = 0;
716
+ raf1 = requestAnimationFrame(() => {
717
+ el.scrollTop = el.scrollHeight;
718
+ raf2 = requestAnimationFrame(() => {
719
+ el.scrollTop = el.scrollHeight;
720
+ });
721
+ });
722
+ return () => {
723
+ cancelAnimationFrame(raf1);
724
+ cancelAnimationFrame(raf2);
725
+ };
726
+ }
727
+ wasStreamingRef.current = false;
728
+ return;
729
+ }, [containerRef, isStreaming]);
730
+ useEffect(() => {
731
+ if (messagesCount > lastCountRef.current) {
732
+ if (stickyRef.current) {
733
+ const el = containerRef.current;
734
+ if (el) el.scrollTop = el.scrollHeight;
735
+ } else {
736
+ setUnreadCount((n) => n + (messagesCount - lastCountRef.current));
737
+ }
738
+ }
739
+ lastCountRef.current = messagesCount;
740
+ }, [containerRef, messagesCount]);
741
+ useEffect(() => {
742
+ }, [bottomRef]);
743
+ return { isAtBottom, unreadCount, scrollToBottom, resetUnread };
744
+ }
745
+ __name(useChatScroll, "useChatScroll");
746
+ function useChatHistory(options) {
747
+ const { enabled = true, containerRef, topSentinelRef, hasMore, isLoadingMore, loadMore } = options;
748
+ const heightBeforeRef = useRef(null);
749
+ useEffect(() => {
750
+ if (heightBeforeRef.current == null) return;
751
+ const el = containerRef.current;
752
+ if (!el) {
753
+ heightBeforeRef.current = null;
754
+ return;
755
+ }
756
+ if (!isLoadingMore) {
757
+ const delta = el.scrollHeight - heightBeforeRef.current;
758
+ if (delta > 0) {
759
+ el.scrollTop += delta;
760
+ }
761
+ heightBeforeRef.current = null;
762
+ }
763
+ }, [containerRef, isLoadingMore]);
764
+ useEffect(() => {
765
+ if (!enabled || !hasMore) return;
766
+ const sentinel = topSentinelRef.current;
767
+ const root = containerRef.current;
768
+ if (!sentinel || !root) return;
769
+ const observer = new IntersectionObserver(
770
+ (entries) => {
771
+ const entry = entries[0];
772
+ if (!entry?.isIntersecting) return;
773
+ if (isLoadingMore) return;
774
+ const el = containerRef.current;
775
+ if (el) heightBeforeRef.current = el.scrollHeight;
776
+ void loadMore();
777
+ },
778
+ { root, threshold: 0, rootMargin: "200px 0px 0px 0px" }
779
+ );
780
+ observer.observe(sentinel);
781
+ return () => observer.disconnect();
782
+ }, [enabled, hasMore, isLoadingMore, containerRef, topSentinelRef, loadMore]);
783
+ }
784
+ __name(useChatHistory, "useChatHistory");
653
785
  function useChatLightbox() {
654
786
  const [state, setState] = useState(null);
655
787
  const open = useCallback((att, gallery) => {
@@ -1761,6 +1893,6 @@ function MarkdownToolbar({ editor }) {
1761
1893
  }
1762
1894
  __name(MarkdownToolbar, "MarkdownToolbar");
1763
1895
 
1764
- export { AudioToggle, CardLoadingFallback, CronScheduler, DiffEditor, Editor, EditorProvider, LazyPlayer as LazyAudioPlayer, LazyChat, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, LazyVideoPlayer, LazyWrapper, LoadingFallback, LottiePlayer, MapLoadingFallback, MarkdownEditor, OpenapiViewer_default as OpenapiViewer, Spinner, TransportError, collectImageAttachments, createHttpTransport, createLazyComponent, createMockTransport, dispatchToolPayload, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isStringValue, mentionPresets, parseSSE, useChatLightbox, useEditor, useEditorContext, useLanguage, useMonaco };
1896
+ export { AudioToggle, CardLoadingFallback, CronScheduler, DiffEditor, Editor, EditorProvider, LazyPlayer as LazyAudioPlayer, LazyChat, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, LazyVideoPlayer, LazyWrapper, LoadingFallback, LottiePlayer, MapLoadingFallback, MarkdownEditor, OpenapiViewer_default as OpenapiViewer, Spinner, TransportError, collectImageAttachments, createHttpTransport, createLazyComponent, createMockTransport, dispatchToolPayload, isGeoJSONFeatureCollection, isLatLng, isPlainObject, isStringValue, mentionPresets, parseSSE, useChatHistory, useChatLightbox, useChatScroll, useEditor, useEditorContext, useLanguage, useMonaco };
1765
1897
  //# sourceMappingURL=index.mjs.map
1766
1898
  //# sourceMappingURL=index.mjs.map