@lukeashford/aurelius 3.8.0 → 3.9.0

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.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React$1 from 'react';
1
+ import React$1, { ReactNode } from 'react';
2
2
  import { Config } from 'dompurify';
3
3
 
4
4
  type ButtonVariant = 'primary' | 'important' | 'elevated' | 'outlined' | 'featured' | 'ghost' | 'danger';
@@ -737,6 +737,158 @@ interface MarkdownContentProps extends React$1.HTMLAttributes<HTMLDivElement> {
737
737
  }
738
738
  declare const MarkdownContent: React$1.ForwardRefExoticComponent<MarkdownContentProps & React$1.RefAttributes<HTMLDivElement>>;
739
739
 
740
+ /**
741
+ * Conversation Tree Types
742
+ *
743
+ * These types support branching conversations where users can:
744
+ * - Edit their messages (creating a new branch)
745
+ * - Retry assistant responses (creating a new branch)
746
+ * - Navigate between different conversation branches
747
+ */
748
+
749
+ /**
750
+ * A node in the conversation tree
751
+ */
752
+ interface MessageNode {
753
+ /**
754
+ * Unique identifier for this message
755
+ */
756
+ id: string;
757
+ /**
758
+ * The role of the message author
759
+ */
760
+ role: 'user' | 'assistant';
761
+ /**
762
+ * The message content (may include HTML/markdown or React components)
763
+ */
764
+ content: ReactNode;
765
+ /**
766
+ * ID of the parent message (null for root messages)
767
+ */
768
+ parentId: string | null;
769
+ /**
770
+ * IDs of child messages (branches/continuations)
771
+ */
772
+ children: string[];
773
+ /**
774
+ * Which sibling branch this message is (0, 1, 2...)
775
+ * Used for UI display like "1/3"
776
+ */
777
+ branchIndex?: number;
778
+ /**
779
+ * Whether this message is currently being streamed
780
+ */
781
+ isStreaming?: boolean;
782
+ /**
783
+ * Timestamp when the message was created
784
+ */
785
+ createdAt?: number;
786
+ }
787
+ /**
788
+ * The full conversation tree structure
789
+ */
790
+ interface ConversationTree {
791
+ /**
792
+ * All nodes indexed by their ID
793
+ */
794
+ nodes: Record<string, MessageNode>;
795
+ /**
796
+ * IDs of root-level messages (messages with no parent)
797
+ */
798
+ rootIds: string[];
799
+ /**
800
+ * The current "head" of the viewed branch
801
+ * This is the leaf node that determines which path we're viewing
802
+ */
803
+ activeLeafId: string | null;
804
+ }
805
+ /**
806
+ * Attachment types for file uploads
807
+ */
808
+ type AttachmentStatus = 'pending' | 'uploading' | 'complete' | 'error';
809
+ interface Attachment {
810
+ /**
811
+ * Unique identifier for the attachment
812
+ */
813
+ id: string;
814
+ /**
815
+ * The File object
816
+ */
817
+ file: File;
818
+ /**
819
+ * Blob URL for image previews
820
+ */
821
+ previewUrl?: string;
822
+ /**
823
+ * Current upload status
824
+ */
825
+ status: AttachmentStatus;
826
+ /**
827
+ * Error message if status is 'error'
828
+ */
829
+ error?: string;
830
+ /**
831
+ * Upload progress (0-100)
832
+ */
833
+ progress?: number;
834
+ }
835
+ /**
836
+ * Helper to check if a file is an image
837
+ */
838
+ declare function isImageFile(file: File): boolean;
839
+ /**
840
+ * Helper to create a preview URL for an image file
841
+ */
842
+ declare function createPreviewUrl(file: File): string | undefined;
843
+ /**
844
+ * Helper to revoke a preview URL when no longer needed
845
+ */
846
+ declare function revokePreviewUrl(url: string | undefined): void;
847
+ /**
848
+ * Generate a unique ID
849
+ */
850
+ declare function generateId(): string;
851
+ /**
852
+ * Create an empty conversation tree
853
+ */
854
+ declare function createEmptyTree(): ConversationTree;
855
+ /**
856
+ * Add a message to the tree
857
+ */
858
+ declare function addMessageToTree(tree: ConversationTree, message: Omit<MessageNode, 'children' | 'branchIndex'>, parentId?: string | null): ConversationTree;
859
+ /**
860
+ * Get the linear path from root to the active leaf
861
+ */
862
+ declare function getActivePathMessages(tree: ConversationTree): MessageNode[];
863
+ /**
864
+ * Get sibling count and current index for a node
865
+ */
866
+ declare function getSiblingInfo(tree: ConversationTree, nodeId: string): {
867
+ total: number;
868
+ current: number;
869
+ };
870
+ /**
871
+ * Switch to a different branch at a given node
872
+ */
873
+ declare function switchBranch(tree: ConversationTree, nodeId: string, direction: 'prev' | 'next'): ConversationTree;
874
+ /**
875
+ * Update a node's content (e.g., during streaming)
876
+ */
877
+ declare function updateNodeContent(tree: ConversationTree, nodeId: string, content: ReactNode, isStreaming?: boolean): ConversationTree;
878
+ /**
879
+ * Convert a flat message array to a conversation tree
880
+ */
881
+ declare function messagesToTree(messages: Array<{
882
+ id: string;
883
+ role: 'user' | 'assistant';
884
+ content: ReactNode;
885
+ isStreaming?: boolean;
886
+ }>): ConversationTree;
887
+ /**
888
+ * Check if a node has multiple children (is a branch point)
889
+ */
890
+ declare function isBranchPoint(tree: ConversationTree, nodeId: string): boolean;
891
+
740
892
  interface ChatInputNotice {
741
893
  /**
742
894
  * Visual severity: 'warning' shows a dismissible amber notice, 'error' shows a persistent red
@@ -757,15 +909,6 @@ interface ChatInputNotice {
757
909
  onDismiss?: () => void;
758
910
  }
759
911
  type ChatInputPosition = 'centered' | 'bottom';
760
- type AttachmentStatus = 'pending' | 'uploading' | 'complete' | 'error';
761
- interface Attachment {
762
- id: string;
763
- file: File;
764
- previewUrl?: string;
765
- status: AttachmentStatus;
766
- error?: string;
767
- progress?: number;
768
- }
769
912
  interface ChatInputProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, 'onSubmit'> {
770
913
  /**
771
914
  * Position of the input: 'centered' for empty state, 'bottom' for conversation mode
@@ -807,6 +950,10 @@ interface ChatInputProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, 'o
807
950
  * Called when attachments change (controlled mode)
808
951
  */
809
952
  onAttachmentsChange?: (attachments: Attachment[]) => void;
953
+ /**
954
+ * Called when an attachment is removed by the user (clicking the "x")
955
+ */
956
+ onAttachmentRemove?: (attachment: Attachment) => void;
810
957
  /**
811
958
  * Whether to show the attachment button
812
959
  */
@@ -1177,145 +1324,6 @@ interface ArtifactNode {
1177
1324
  children: ArtifactNode[];
1178
1325
  }
1179
1326
 
1180
- /**
1181
- * Conversation Tree Types
1182
- *
1183
- * These types support branching conversations where users can:
1184
- * - Edit their messages (creating a new branch)
1185
- * - Retry assistant responses (creating a new branch)
1186
- * - Navigate between different conversation branches
1187
- */
1188
- /**
1189
- * A node in the conversation tree
1190
- */
1191
- interface MessageNode {
1192
- /**
1193
- * Unique identifier for this message
1194
- */
1195
- id: string;
1196
- /**
1197
- * The role of the message author
1198
- */
1199
- role: 'user' | 'assistant';
1200
- /**
1201
- * The message content (may include HTML/markdown)
1202
- */
1203
- content: string;
1204
- /**
1205
- * ID of the parent message (null for root messages)
1206
- */
1207
- parentId: string | null;
1208
- /**
1209
- * IDs of child messages (branches/continuations)
1210
- */
1211
- children: string[];
1212
- /**
1213
- * Which sibling branch this message is (0, 1, 2...)
1214
- * Used for UI display like "1/3"
1215
- */
1216
- branchIndex?: number;
1217
- /**
1218
- * Whether this message is currently being streamed
1219
- */
1220
- isStreaming?: boolean;
1221
- /**
1222
- * Timestamp when the message was created
1223
- */
1224
- createdAt?: number;
1225
- }
1226
- /**
1227
- * The full conversation tree structure
1228
- */
1229
- interface ConversationTree {
1230
- /**
1231
- * All nodes indexed by their ID
1232
- */
1233
- nodes: Record<string, MessageNode>;
1234
- /**
1235
- * IDs of root-level messages (messages with no parent)
1236
- */
1237
- rootIds: string[];
1238
- /**
1239
- * The current "head" of the viewed branch
1240
- * This is the leaf node that determines which path we're viewing
1241
- */
1242
- activeLeafId: string | null;
1243
- }
1244
- /**
1245
- * Helper to check if a file is an image
1246
- */
1247
- declare function isImageFile(file: File): boolean;
1248
- /**
1249
- * Helper to create a preview URL for an image file
1250
- */
1251
- declare function createPreviewUrl(file: File): string | undefined;
1252
- /**
1253
- * Helper to revoke a preview URL when no longer needed
1254
- */
1255
- declare function revokePreviewUrl(url: string | undefined): void;
1256
- /**
1257
- * Generate a unique ID
1258
- */
1259
- declare function generateId(): string;
1260
- /**
1261
- * Create an empty conversation tree
1262
- */
1263
- declare function createEmptyTree(): ConversationTree;
1264
- /**
1265
- * Add a message to the tree
1266
- */
1267
- declare function addMessageToTree(tree: ConversationTree, message: Omit<MessageNode, 'children' | 'branchIndex'>, parentId?: string | null): ConversationTree;
1268
- /**
1269
- * Get the linear path from root to the active leaf
1270
- */
1271
- declare function getActivePathMessages(tree: ConversationTree): MessageNode[];
1272
- /**
1273
- * Get sibling count and current index for a node
1274
- */
1275
- declare function getSiblingInfo(tree: ConversationTree, nodeId: string): {
1276
- total: number;
1277
- current: number;
1278
- };
1279
- /**
1280
- * Switch to a different branch at a given node
1281
- */
1282
- declare function switchBranch(tree: ConversationTree, nodeId: string, direction: 'prev' | 'next'): ConversationTree;
1283
- /**
1284
- * Update a node's content (e.g., during streaming)
1285
- */
1286
- declare function updateNodeContent(tree: ConversationTree, nodeId: string, content: string, isStreaming?: boolean): ConversationTree;
1287
- /**
1288
- * Convert a flat message array to a conversation tree
1289
- */
1290
- declare function messagesToTree(messages: Array<{
1291
- id: string;
1292
- role: 'user' | 'assistant';
1293
- content: string;
1294
- isStreaming?: boolean;
1295
- }>): ConversationTree;
1296
- /**
1297
- * Check if a node has multiple children (is a branch point)
1298
- */
1299
- declare function isBranchPoint(tree: ConversationTree, nodeId: string): boolean;
1300
-
1301
- interface ChatMessage {
1302
- /**
1303
- * Unique identifier for the message
1304
- */
1305
- id: string;
1306
- /**
1307
- * Whether the message is from the user or the assistant
1308
- */
1309
- variant: 'user' | 'assistant';
1310
- /**
1311
- * Message content (Markdown supported)
1312
- */
1313
- content: string;
1314
- /**
1315
- * Whether the message is currently streaming
1316
- */
1317
- isStreaming?: boolean;
1318
- }
1319
1327
  interface Conversation {
1320
1328
  /**
1321
1329
  * Unique identifier for the conversation
@@ -1345,7 +1353,7 @@ interface ChatInterfaceProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>
1345
1353
  * Array of messages in the conversation (flat mode)
1346
1354
  * Use this OR conversationTree, not both
1347
1355
  */
1348
- messages?: ChatMessage[];
1356
+ messages?: MessageNode[];
1349
1357
  /**
1350
1358
  * Conversation tree for branching support
1351
1359
  * Use this OR messages, not both
@@ -1430,6 +1438,10 @@ interface ChatInterfaceProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>
1430
1438
  * Called when attachments are added or removed in the chat input.
1431
1439
  */
1432
1440
  onAttachmentsChange?: (attachments: Attachment[]) => void;
1441
+ /**
1442
+ * Called when an attachment is removed by the user (clicking the "x")
1443
+ */
1444
+ onAttachmentRemove?: (attachment: Attachment) => void;
1433
1445
  /**
1434
1446
  * Top-level artifact tree nodes for the artifacts panel.
1435
1447
  */
@@ -2042,4 +2054,4 @@ declare const ArtifactVariantStack: React$1.ForwardRefExoticComponent<ArtifactVa
2042
2054
 
2043
2055
  declare const version = "2.0.0";
2044
2056
 
2045
- export { ARTIFACT_TYPES, Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, Alert, AlertDialog, type AlertDialogProps, type AlertProps, type AlertVariant, type Artifact, ArtifactCard, type ArtifactCardProps, ArtifactGroup, type ArtifactGroupProps, type ArtifactNode, type ArtifactType, ArtifactVariantStack, type ArtifactVariantStackProps, ArtifactsPanel, type ArtifactsPanelProps, ArtifactsPanelToggle, type ArtifactsPanelToggleProps, type AspectRatio, type AspectRatioPreset, type Attachment, type AttachmentItem, AttachmentPreview, type AttachmentPreviewProps, type AttachmentStatus, AudioCard, type AudioCardProps, Avatar, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeVariant, BranchNavigator, type BranchNavigatorProps, BrandIcon, type BrandIconProps, type BrandIconSize, type BrandIconVariant, Breadcrumb, type BreadcrumbEntry, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkProps, type BreadcrumbProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardMediaProps, type CardProps, type CardVariant, ChatBubbleIcon, ChatInput, type ChatInputNotice, type ChatInputPosition, type ChatInputProps, ChatInterface, type ChatInterfaceProps, type ChatMessage, ChatView, type ChatViewItem, type ChatViewProps, CheckSquareIcon, Checkbox, type CheckboxProps, ChevronLeftIcon, ChevronRightIcon, CloseIcon, Col, type ColOffset, type ColOrder, type ColProps, type ColSpan, ColorSwatch, type ColorSwatchProps, ConfirmDialog, type ConfirmDialogProps, Container, type ContainerProps, type ContainerSize, type Conversation, type ConversationTree, CrossSquareIcon, Divider, type DividerProps, Drawer, type DrawerPosition, type DrawerProps, EmptySquareIcon, ExpandIcon, type ExternalToolDefinition, FileChip, type FileChipProps, type FileChipStatus, HelperText, type HelperTextProps, HistoryIcon, HistoryPanel, type HistoryPanelProps, type IconProps, ImageCard, type ImageCardProps, Input, type InputAddonProps, type InputElementProps, InputGroup, type InputGroupProps, InputLeftAddon, InputLeftElement, type InputProps, InputRightAddon, InputRightElement, InputWrapper, type InputWrapperProps, Label, type LabelProps, LayersIcon, List, ListItem, type ListItemProps, ListItemText, type ListItemTextProps, type ListProps, ListSubheader, type ListSubheaderProps, MarkdownContent, type MarkdownContentProps, MediaIcon, Menu, MenuContent, type MenuContentProps, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, MenuSeparator, MenuTrigger, type MenuTriggerProps, Message, MessageActions, type MessageActionsConfig, type MessageActionsProps, type MessageActionsVariant, type MessageBranchInfo, type MessageNode, type MessageProps, type MessageVariant, Modal, type ModalProps, NODE_TYPES, Navbar, NavbarBrand, type NavbarBrandProps, NavbarContent, type NavbarContentProps, NavbarDivider, NavbarItem, type NavbarItemProps, NavbarLink, type NavbarLinkProps, type NavbarProps, type NodeType, Pagination, type PaginationProps, PdfCard, type PdfCardProps, PlusIcon, Popover, type PopoverAlign, type PopoverPosition, type PopoverProps, Progress, type ProgressProps, PromptDialog, type PromptDialogProps, Radio, type RadioProps, Row, type RowAlign, type RowGutter, type RowJustify, type RowProps, SCRIPT_ELEMENT_TYPES, ScriptCard, type ScriptCardProps, type ScriptElement, type ScriptElementType, SectionHeading, type SectionHeadingLevel, type SectionHeadingProps, Select, type SelectOption, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderProps, Spinner, type SpinnerProps, SquareLoaderIcon, Stack, type StackDirection, type StackGap, type StackProps, type Step, type StepStatus, Stepper, type StepperProps, StreamingCursor, type StreamingCursorProps, Switch, type SwitchProps, TASK_STATUSES, Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Table, TableBody, type TableBodyProps, TableCaption, type TableCaptionProps, TableCell, type TableCellProps, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, TableHeader, type TableHeaderProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsProps, type Task, type TaskStatus, TextCard, type TextCardProps, Textarea, type TextareaProps, ThinkingIndicator, type ThinkingIndicatorProps, type ToastData, type ToastPosition, ToastProvider, type ToastProviderProps, type ToastVariant, TodosList, type TodosListProps, type ToolDefinition, type ToolGroup, ToolPanelContainer, type ToolPanelContainerProps, type ToolPanelState, ToolSidebar, type ToolSidebarProps, Tooltip, type TooltipProps, type UseArtifactTreeNavigationReturn, type UseScrollAnchorOptions, type UseScrollAnchorReturn, type VideoAspectRatio, type VideoAspectRatioPreset, VideoCard, type VideoCardProps, addMessageToTree, areAllTasksSettled, createEmptyTree, createPreviewUrl, generateId, getActivePathMessages, getSiblingInfo, isBranchPoint, isImageFile, messagesToTree, revokePreviewUrl, switchBranch, updateNodeContent, useArtifactTreeNavigation, useResizable, useScrollAnchor, useToast, version };
2057
+ export { ARTIFACT_TYPES, Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, Alert, AlertDialog, type AlertDialogProps, type AlertProps, type AlertVariant, type Artifact, ArtifactCard, type ArtifactCardProps, ArtifactGroup, type ArtifactGroupProps, type ArtifactNode, type ArtifactType, ArtifactVariantStack, type ArtifactVariantStackProps, ArtifactsPanel, type ArtifactsPanelProps, ArtifactsPanelToggle, type ArtifactsPanelToggleProps, type AspectRatio, type AspectRatioPreset, type Attachment, type AttachmentItem, AttachmentPreview, type AttachmentPreviewProps, type AttachmentStatus, AudioCard, type AudioCardProps, Avatar, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeVariant, BranchNavigator, type BranchNavigatorProps, BrandIcon, type BrandIconProps, type BrandIconSize, type BrandIconVariant, Breadcrumb, type BreadcrumbEntry, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkProps, type BreadcrumbProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardMediaProps, type CardProps, type CardVariant, ChatBubbleIcon, ChatInput, type ChatInputNotice, type ChatInputPosition, type ChatInputProps, ChatInterface, type ChatInterfaceProps, ChatView, type ChatViewItem, type ChatViewProps, CheckSquareIcon, Checkbox, type CheckboxProps, ChevronLeftIcon, ChevronRightIcon, CloseIcon, Col, type ColOffset, type ColOrder, type ColProps, type ColSpan, ColorSwatch, type ColorSwatchProps, ConfirmDialog, type ConfirmDialogProps, Container, type ContainerProps, type ContainerSize, type Conversation, type ConversationTree, CrossSquareIcon, Divider, type DividerProps, Drawer, type DrawerPosition, type DrawerProps, EmptySquareIcon, ExpandIcon, type ExternalToolDefinition, FileChip, type FileChipProps, type FileChipStatus, HelperText, type HelperTextProps, HistoryIcon, HistoryPanel, type HistoryPanelProps, type IconProps, ImageCard, type ImageCardProps, Input, type InputAddonProps, type InputElementProps, InputGroup, type InputGroupProps, InputLeftAddon, InputLeftElement, type InputProps, InputRightAddon, InputRightElement, InputWrapper, type InputWrapperProps, Label, type LabelProps, LayersIcon, List, ListItem, type ListItemProps, ListItemText, type ListItemTextProps, type ListProps, ListSubheader, type ListSubheaderProps, MarkdownContent, type MarkdownContentProps, MediaIcon, Menu, MenuContent, type MenuContentProps, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, MenuSeparator, MenuTrigger, type MenuTriggerProps, Message, MessageActions, type MessageActionsConfig, type MessageActionsProps, type MessageActionsVariant, type MessageBranchInfo, type MessageNode, type MessageProps, type MessageVariant, Modal, type ModalProps, NODE_TYPES, Navbar, NavbarBrand, type NavbarBrandProps, NavbarContent, type NavbarContentProps, NavbarDivider, NavbarItem, type NavbarItemProps, NavbarLink, type NavbarLinkProps, type NavbarProps, type NodeType, Pagination, type PaginationProps, PdfCard, type PdfCardProps, PlusIcon, Popover, type PopoverAlign, type PopoverPosition, type PopoverProps, Progress, type ProgressProps, PromptDialog, type PromptDialogProps, Radio, type RadioProps, Row, type RowAlign, type RowGutter, type RowJustify, type RowProps, SCRIPT_ELEMENT_TYPES, ScriptCard, type ScriptCardProps, type ScriptElement, type ScriptElementType, SectionHeading, type SectionHeadingLevel, type SectionHeadingProps, Select, type SelectOption, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderProps, Spinner, type SpinnerProps, SquareLoaderIcon, Stack, type StackDirection, type StackGap, type StackProps, type Step, type StepStatus, Stepper, type StepperProps, StreamingCursor, type StreamingCursorProps, Switch, type SwitchProps, TASK_STATUSES, Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Table, TableBody, type TableBodyProps, TableCaption, type TableCaptionProps, TableCell, type TableCellProps, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, TableHeader, type TableHeaderProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsProps, type Task, type TaskStatus, TextCard, type TextCardProps, Textarea, type TextareaProps, ThinkingIndicator, type ThinkingIndicatorProps, type ToastData, type ToastPosition, ToastProvider, type ToastProviderProps, type ToastVariant, TodosList, type TodosListProps, type ToolDefinition, type ToolGroup, ToolPanelContainer, type ToolPanelContainerProps, type ToolPanelState, ToolSidebar, type ToolSidebarProps, Tooltip, type TooltipProps, type UseArtifactTreeNavigationReturn, type UseScrollAnchorOptions, type UseScrollAnchorReturn, type VideoAspectRatio, type VideoAspectRatioPreset, VideoCard, type VideoCardProps, addMessageToTree, areAllTasksSettled, createEmptyTree, createPreviewUrl, generateId, getActivePathMessages, getSiblingInfo, isBranchPoint, isImageFile, messagesToTree, revokePreviewUrl, switchBranch, updateNodeContent, useArtifactTreeNavigation, useResizable, useScrollAnchor, useToast, version };
package/dist/index.js CHANGED
@@ -4658,14 +4658,13 @@ function addMessageToTree(tree, message, parentId = null) {
4658
4658
  } else if (!parentId) {
4659
4659
  branchIndex = newRootIds.length;
4660
4660
  }
4661
- const newNode = {
4661
+ newNodes[message.id] = {
4662
4662
  ...message,
4663
4663
  parentId,
4664
4664
  children: [],
4665
4665
  branchIndex,
4666
4666
  createdAt: message.createdAt ?? Date.now()
4667
4667
  };
4668
- newNodes[message.id] = newNode;
4669
4668
  if (parentId && newNodes[parentId]) {
4670
4669
  newNodes[parentId] = {
4671
4670
  ...newNodes[parentId],
@@ -4741,8 +4740,7 @@ function switchBranch(tree, nodeId, direction) {
4741
4740
  return tree;
4742
4741
  }
4743
4742
  const newIndex = direction === "next" ? (currentIndex + 1) % siblings.length : (currentIndex - 1 + siblings.length) % siblings.length;
4744
- const newNodeId = siblings[newIndex];
4745
- let leafId = newNodeId;
4743
+ let leafId = siblings[newIndex];
4746
4744
  let currentNode = tree.nodes[leafId];
4747
4745
  while (currentNode && currentNode.children.length > 0) {
4748
4746
  leafId = currentNode.children[0];
@@ -4802,6 +4800,7 @@ var ChatInput = import_react61.default.forwardRef(
4802
4800
  onStop,
4803
4801
  attachments: controlledAttachments,
4804
4802
  onAttachmentsChange,
4803
+ onAttachmentRemove,
4805
4804
  showAttachmentButton = true,
4806
4805
  acceptedFileTypes,
4807
4806
  notice,
@@ -4888,15 +4887,19 @@ var ChatInput = import_react61.default.forwardRef(
4888
4887
  );
4889
4888
  const handleRemoveAttachment = (0, import_react61.useCallback)(
4890
4889
  (id) => {
4890
+ const attachment = attachments.find((a) => a.id === id);
4891
+ if (attachment && onAttachmentRemove) {
4892
+ onAttachmentRemove(attachment);
4893
+ }
4891
4894
  setAttachments((prev) => {
4892
- const attachment = prev.find((a) => a.id === id);
4893
- if (attachment?.previewUrl) {
4894
- URL.revokeObjectURL(attachment.previewUrl);
4895
+ const attachmentToRemove = prev.find((a) => a.id === id);
4896
+ if (attachmentToRemove?.previewUrl) {
4897
+ URL.revokeObjectURL(attachmentToRemove.previewUrl);
4895
4898
  }
4896
4899
  return prev.filter((a) => a.id !== id);
4897
4900
  });
4898
4901
  },
4899
- [setAttachments]
4902
+ [attachments, onAttachmentRemove, setAttachments]
4900
4903
  );
4901
4904
  const handleDragEnter = (0, import_react61.useCallback)((e) => {
4902
4905
  e.preventDefault();
@@ -4928,7 +4931,8 @@ var ChatInput = import_react61.default.forwardRef(
4928
4931
  );
4929
4932
  const isCentered = position === "centered";
4930
4933
  const hasAttachments = attachments.length > 0;
4931
- const canSubmit = value.trim() && !disabled && !isStreaming;
4934
+ const isUploading = attachments.some((a) => a.status === "uploading");
4935
+ const canSubmit = value.trim() && !disabled && !isStreaming && !isUploading;
4932
4936
  return /* @__PURE__ */ import_react61.default.createElement(
4933
4937
  "div",
4934
4938
  {
@@ -6842,6 +6846,7 @@ var ChatInterface = import_react78.default.forwardRef(
6842
6846
  enableMessageActions = true,
6843
6847
  attachments: propsAttachments,
6844
6848
  onAttachmentsChange,
6849
+ onAttachmentRemove,
6845
6850
  artifactNodes,
6846
6851
  isArtifactsPanelOpen,
6847
6852
  onArtifactsPanelOpenChange,
@@ -6942,19 +6947,13 @@ var ChatInterface = import_react78.default.forwardRef(
6942
6947
  const isTreeMode = !!conversationTree;
6943
6948
  const effectiveMessages = (0, import_react78.useMemo)(() => {
6944
6949
  if (isTreeMode && conversationTree) {
6945
- const pathNodes = getActivePathMessages(conversationTree);
6946
- return pathNodes.map((node) => ({
6947
- id: node.id,
6948
- variant: node.role,
6949
- content: node.content,
6950
- isStreaming: node.isStreaming
6951
- }));
6950
+ return getActivePathMessages(conversationTree);
6952
6951
  }
6953
- return messages;
6952
+ return messages || [];
6954
6953
  }, [isTreeMode, conversationTree, messages]);
6955
6954
  const latestUserMessageIndex = (0, import_react78.useMemo)(() => {
6956
6955
  for (let i = effectiveMessages.length - 1; i >= 0; i--) {
6957
- if (effectiveMessages[i].variant === "user") {
6956
+ if (effectiveMessages[i].role === "user") {
6958
6957
  return i;
6959
6958
  }
6960
6959
  }
@@ -7011,10 +7010,23 @@ var ChatInterface = import_react78.default.forwardRef(
7011
7010
  }
7012
7011
  const actions = enableMessageActions ? {
7013
7012
  showCopy: true,
7014
- onEdit: msg.variant === "user" && onEditMessage ? (newContent) => onEditMessage(msg.id, newContent) : void 0,
7015
- onRetry: msg.variant === "assistant" && onRetryMessage ? () => onRetryMessage(msg.id) : void 0
7013
+ onEdit: msg.role === "user" && onEditMessage ? (newContent) => onEditMessage(msg.id, newContent) : void 0,
7014
+ onRetry: msg.role === "assistant" && onRetryMessage ? () => onRetryMessage(msg.id) : void 0
7016
7015
  } : void 0;
7017
- return { ...msg, branchInfo, actions };
7016
+ const {
7017
+ role,
7018
+ parentId,
7019
+ children,
7020
+ branchIndex,
7021
+ createdAt,
7022
+ ...rest2
7023
+ } = msg;
7024
+ return {
7025
+ ...rest2,
7026
+ variant: role,
7027
+ branchInfo,
7028
+ actions
7029
+ };
7018
7030
  });
7019
7031
  }, [
7020
7032
  effectiveMessages,
@@ -7144,6 +7156,7 @@ var ChatInterface = import_react78.default.forwardRef(
7144
7156
  showAttachmentButton,
7145
7157
  attachments: propsAttachments,
7146
7158
  onAttachmentsChange,
7159
+ onAttachmentRemove,
7147
7160
  notice: inputNotice,
7148
7161
  onInputChange,
7149
7162
  initialInputValue,