diff --git a/src/apps/chat/components/composer/llmattachments/LLMAttachmentMenu.tsx b/src/apps/chat/components/composer/llmattachments/LLMAttachmentMenu.tsx index 872aa1160..7fe0178ab 100644 --- a/src/apps/chat/components/composer/llmattachments/LLMAttachmentMenu.tsx +++ b/src/apps/chat/components/composer/llmattachments/LLMAttachmentMenu.tsx @@ -49,7 +49,7 @@ export function LLMAttachmentMenu(props: { isPositionFirst: boolean, isPositionLast: boolean, onClose: () => void, - onDraftAction: (attachmentDraftId: AttachmentDraftId, actionId: LLMAttachmentDraftsAction) => void, + onDraftAction?: (attachmentDraftId: AttachmentDraftId, actionId: LLMAttachmentDraftsAction) => void, onViewDocPart: (docPart: DMessageDocPart) => void, onViewImageRefPart: (imageRefPart: DMessageImageRefPart) => void }) { @@ -223,15 +223,15 @@ export function LLMAttachmentMenu(props: { )} - {SHOW_INLINING_OPERATIONS && } - {SHOW_INLINING_OPERATIONS && ( - onDraftAction(draftId, 'inline-text')} disabled={!llmSupportsTextFragments || isConverting}> + {SHOW_INLINING_OPERATIONS && !!onDraftAction && } + {SHOW_INLINING_OPERATIONS && !!onDraftAction && ( + onDraftAction?.(draftId, 'inline-text')} disabled={!llmSupportsTextFragments || isConverting}> Inline text )} - {SHOW_INLINING_OPERATIONS && ( - onDraftAction(draftId, 'copy-text')} disabled={!llmSupportsTextFragments || isConverting}> + {SHOW_INLINING_OPERATIONS && !!onDraftAction && ( + onDraftAction?.(draftId, 'copy-text')} disabled={!llmSupportsTextFragments || isConverting}> Copy text diff --git a/src/apps/chat/components/composer/llmattachments/LLMAttachmentsList.tsx b/src/apps/chat/components/composer/llmattachments/LLMAttachmentsList.tsx index 67a89fdb2..13d714a24 100644 --- a/src/apps/chat/components/composer/llmattachments/LLMAttachmentsList.tsx +++ b/src/apps/chat/components/composer/llmattachments/LLMAttachmentsList.tsx @@ -37,7 +37,7 @@ export function LLMAttachmentsList(props: { attachmentDraftsStoreApi: AttachmentDraftsStoreApi, canInlineSomeFragments: boolean, llmAttachmentDrafts: LLMAttachmentDraft[], - onAttachmentDraftsAction: (attachmentDraftId: AttachmentDraftId | null, actionId: LLMAttachmentDraftsAction) => void, + onAttachmentDraftsAction?: (attachmentDraftId: AttachmentDraftId | null, actionId: LLMAttachmentDraftsAction) => void, }) { // state @@ -74,12 +74,12 @@ export function LLMAttachmentsList(props: { const handleOverallCopyText = React.useCallback(() => { handleOverallMenuHide(); - onAttachmentDraftsAction(null, 'copy-text'); + onAttachmentDraftsAction?.(null, 'copy-text'); }, [handleOverallMenuHide, onAttachmentDraftsAction]); const handleOverallInlineText = React.useCallback(() => { handleOverallMenuHide(); - onAttachmentDraftsAction(null, 'inline-text'); + onAttachmentDraftsAction?.(null, 'inline-text'); }, [handleOverallMenuHide, onAttachmentDraftsAction]); const handleOverallClear = React.useCallback(async () => { @@ -109,7 +109,7 @@ export function LLMAttachmentsList(props: { const handleDraftAction = React.useCallback((attachmentDraftId: AttachmentDraftId, actionId: LLMAttachmentDraftsAction) => { // pass-through, but close the menu as well, as the action is destructive for the caller handleDraftMenuHide(); - onAttachmentDraftsAction(attachmentDraftId, actionId); + onAttachmentDraftsAction?.(attachmentDraftId, actionId); }, [handleDraftMenuHide, onAttachmentDraftsAction]); const handleViewImageRefPart = React.useCallback((imageRefPart: DMessageImageRefPart) => { @@ -196,7 +196,7 @@ export function LLMAttachmentsList(props: { isPositionFirst={itemMenuIndex === 0} isPositionLast={itemMenuIndex === llmAttachmentDrafts.length - 1} onClose={handleDraftMenuHide} - onDraftAction={handleDraftAction} + onDraftAction={!onAttachmentDraftsAction ? undefined : handleDraftAction} onViewDocPart={handleViewDocPart} onViewImageRefPart={handleViewImageRefPart} /> @@ -218,19 +218,17 @@ export function LLMAttachmentsList(props: { What can I do? )} + {!!agiAttachmentPrompts && } - - - + {!!onAttachmentDraftsAction && Inline all text - - + } + {!!onAttachmentDraftsAction && Copy all text - - - + } + {!!onAttachmentDraftsAction && }