diff --git a/web/src/components/next-message-item/index.tsx b/web/src/components/next-message-item/index.tsx
index 647006473..d75051265 100644
--- a/web/src/components/next-message-item/index.tsx
+++ b/web/src/components/next-message-item/index.tsx
@@ -134,6 +134,51 @@ function MessageItem({
},
[currentEventListWithoutMessageById, loading],
);
+
+ const renderContent = useCallback(() => {
+ /* Show message content if there's any text besides the download */
+
+ if (pdfDownloadInfo) {
+ return null;
+ }
+
+ return (
+
+ {item.data ? (
+ children
+ ) : sendLoading && isEmpty(messageContent) ? (
+ <>{!isShare && 'running...'}>
+ ) : (
+
+ )}
+
+ );
+ }, [
+ children,
+ clickDocumentButton,
+ isAssistant,
+ isShare,
+ item.data,
+ loading,
+ messageContent,
+ pdfDownloadInfo,
+ reference,
+ sendLoading,
+ theme,
+ ]);
+
return (
)}
+
{/* Show PDF download button if download info is present */}
{pdfDownloadInfo && (
)}
- {/* Show message content if there's any text besides the download */}
- {messageContent && (
-
- {item.data ? (
- children
- ) : sendLoading && isEmpty(messageContent) ? (
- <>{!isShare && 'running...'}>
- ) : (
-
- )}
-
- )}
+ {renderContent()}
+
{isAssistant && referenceDocuments.length > 0 && (