(feat:attachments) render in bubble

This commit is contained in:
ManishMadan2882 committed 2025-06-03 18:05:47 +05:30
1 parent 7cab5b3b09
commit e90fe117ec
3 files changed
+28 -1

No files matched your search

@@ -59,6 +59,7 @@ const ConversationBubble = forwardRef<
updated?: boolean, updated?: boolean,
index?: number, index?: number,
) => void; ) => void;
attachmentsMetadata?: { id: string; filename: string }[];
} }
>(function ConversationBubble( >(function ConversationBubble(
{ {
@@ -74,6 +75,7 @@ const ConversationBubble = forwardRef<
questionNumber, questionNumber,
isStreaming, isStreaming,
handleUpdatedQuestionSubmission, handleUpdatedQuestionSubmission,
attachmentsMetadata,
}, },
ref, ref,
) { ) {
@@ -225,11 +227,35 @@ const ConversationBubble = forwardRef<
return contentSegments; return contentSegments;
}; };
const renderAttachments = () => {
if (!attachmentsMetadata || attachmentsMetadata.length === 0) return null;
return (
<div className="mb-2 flex flex-wrap gap-2">
{attachmentsMetadata.map((attachment, index) => (
<div
key={index}
className="flex items-center rounded-[32px] border border-[#AAAAAA] bg-white px-3 py-1.5 text-[14px] text-[#5D5D5D] dark:border-purple-taupe dark:bg-[#1F2028] dark:text-bright-gray"
>
<img
src={Document}
alt="Attachment"
className="mr-2 h-[17px] w-[17px] object-fill"
/>
<span className="max-w-[150px] truncate font-medium">
{attachment.filename}
</span>
</div>
))}
</div>
);
};
bubble = ( bubble = (
<div <div
ref={ref} ref={ref}
className={`flex flex-wrap self-start ${className} group flex-col dark:text-bright-gray`} className={`flex flex-wrap self-start ${className} group flex-col dark:text-bright-gray`}
> >
{type === 'ANSWER' && renderAttachments()}
{DisableSourceFE || {DisableSourceFE ||
type === 'ERROR' || type === 'ERROR' ||
sources?.length === 0 || sources?.length === 0 ||
@@ -145,6 +145,7 @@ export default function ConversationMessages({
toolCalls={query.tool_calls} toolCalls={query.tool_calls}
feedback={query.feedback} feedback={query.feedback}
isStreaming={isCurrentlyStreaming} isStreaming={isCurrentlyStreaming}
attachmentsMetadata={query.attachments}
handleFeedback={ handleFeedback={
handleFeedback handleFeedback
? (feedback) => handleFeedback(query, feedback, index) ? (feedback) => handleFeedback(query, feedback, index)
@@ -46,7 +46,7 @@ export interface Query {
sources?: { title: string; text: string; link: string }[]; sources?: { title: string; text: string; link: string }[];
tool_calls?: ToolCallsType[]; tool_calls?: ToolCallsType[];
error?: string; error?: string;
attachments?: { fileName: string; id: string }[]; attachments?: { id: string; filename: string }[];
} }
export interface RetrievalPayload { export interface RetrievalPayload {