import { useState } from "react" import type React from "react" import { KnowledgeIcon } from "@/components/Option/Knowledge/KnowledgeIcon" type Props = { index: number source: { name?: string url?: string mode?: string type?: string pageContent?: string content?: string doId?: string description?: string } onSourceClick?: (source: any) => void } export const MessageSource: React.FC = ({ index, source, onSourceClick }) => { // Add state for tracking and content visibility const [showContent, setShowContent] = useState(false) if (source?.mode === "rag" || source?.mode === "chat") { return ( ) } const onContextMenu = (e: React.MouseEvent) => { e.preventDefault() e.stopPropagation setShowContent(true) } return (
{" "} {source.doId ? ( <> [{index + 1}] doid: {source.doId}
{source.name} {showContent && (
{source.content || source.pageContent || source.description}
)} ) : ( <> [{index + 1}] {source.name} {showContent && (
{source.content || source.pageContent}
)} )}
) }