diff --git a/src/apps/chat/components/composer/Composer.tsx b/src/apps/chat/components/composer/Composer.tsx index be721262e..cab114039 100644 --- a/src/apps/chat/components/composer/Composer.tsx +++ b/src/apps/chat/components/composer/Composer.tsx @@ -157,7 +157,7 @@ export function Composer(props: { // attachments-overlay: comes from the attachments slice of the conversation overlay const { /* items */ attachmentDrafts, - /* append */ attachAppendClipboardItems, attachAppendDataTransfer, attachAppendEgoContent, attachAppendFile, + /* append */ attachAppendClipboardItems, attachAppendDataTransfer, attachAppendEgoFragments, attachAppendFile, /* take */ attachmentsRemoveAll, attachmentsTakeAllFragments, attachmentsTakeTextFragments, } = useAttachmentDrafts(conversationOverlayStore, enableLoadURLsInComposer); @@ -315,22 +315,21 @@ export function Composer(props: { } }, [composerTextAreaRef, setComposeText]); - const onActileEmbedMessage = React.useCallback(async (starredItem: StarredMessageItem) => { + const onActileEmbedMessage = React.useCallback(async ({ conversationId, messageId }: StarredMessageItem) => { // get the message - const conversation = getConversation(starredItem.conversationId); - const messageToEmbed = conversation?.messages.find(m => m.id === starredItem.messageId); + const conversation = getConversation(conversationId); + const messageToEmbed = conversation?.messages.find(m => m.id === messageId); if (conversation && messageToEmbed) { - const contentToEmbed = duplicateDMessageFragments(messageToEmbed.fragments) + const fragmentsCopy = duplicateDMessageFragments(messageToEmbed.fragments) .filter(isContentFragment); - if (contentToEmbed.length) { + if (fragmentsCopy.length) { const chatTitle = conversationTitle(conversation); - const messageText = messageFragmentsReduceText(contentToEmbed); - const refLabel = `${chatTitle} > ${messageText.slice(0, 10)}...`; - const refId = `${starredItem.messageId} - ${chatTitle}`; - await attachAppendEgoContent(refLabel, refId, contentToEmbed); + const messageText = messageFragmentsReduceText(fragmentsCopy); + const label = `${chatTitle} > ${messageText.slice(0, 10)}...`; + await attachAppendEgoFragments(fragmentsCopy, label, chatTitle, conversationId, messageId); } } - }, [attachAppendEgoContent]); + }, [attachAppendEgoFragments]); const actileProviders = React.useMemo(() => { return [providerCommands(onActileCommandPaste), providerStarredMessage(onActileEmbedMessage)]; diff --git a/src/apps/chat/components/composer/llmattachments/LLMAttachmentItem.tsx b/src/apps/chat/components/composer/llmattachments/LLMAttachmentItem.tsx index 9c53c0352..30129e789 100644 --- a/src/apps/chat/components/composer/llmattachments/LLMAttachmentItem.tsx +++ b/src/apps/chat/components/composer/llmattachments/LLMAttachmentItem.tsx @@ -80,7 +80,7 @@ const converterTypeToIconMap: { [key in AttachmentDraftConverterType]: React.Com 'image-resized-low': PhotoSizeSelectSmallOutlinedIcon, 'image-to-default': ImageOutlinedIcon, 'image-ocr': AbcIcon, - 'ego-contents-inlined': TelegramIcon, + 'ego-fragments-inlined': TelegramIcon, 'unhandled': TextureIcon, }; diff --git a/src/common/attachment-drafts/attachment.pipeline.ts b/src/common/attachment-drafts/attachment.pipeline.ts index dfa899a25..331d7f73c 100644 --- a/src/common/attachment-drafts/attachment.pipeline.ts +++ b/src/common/attachment-drafts/attachment.pipeline.ts @@ -198,11 +198,11 @@ export async function attachmentLoadInputAsync(source: Readonly { + const attachAppendEgoFragments = React.useCallback((fragments: DMessageContentFragment[], label: string, conversationTitle: string, conversationId: DConversationId, messageId: DMessageId) => { if (ATTACHMENTS_DEBUG_INTAKE) - console.log('attachAppendEgoContent', label, refId, contents); + console.log('attachAppendEgoContent', fragments, label, conversationId, messageId); return _createAttachmentDraft({ - media: 'ego', method: 'ego-contents', label, refId, contents, + media: 'ego', method: 'ego-fragments', label, fragments, refConversationTitle: conversationTitle, refConversationId: conversationId, refMessageId: messageId, }); }, [_createAttachmentDraft]); @@ -201,7 +203,7 @@ export const useAttachmentDrafts = (attachmentsStoreApi: AttachmentDraftsStoreAp // create drafts attachAppendClipboardItems, attachAppendDataTransfer, - attachAppendEgoContent, + attachAppendEgoFragments, attachAppendFile, // manage attachments