diff --git a/surfsense_web/components/chat/ChatCitation.tsx b/surfsense_web/components/chat/ChatCitation.tsx index 34b753410..de9b6f4ca 100644 --- a/surfsense_web/components/chat/ChatCitation.tsx +++ b/surfsense_web/components/chat/ChatCitation.tsx @@ -1,10 +1,11 @@ "use client"; -import { ExternalLink, FileText, Loader2 } from "lucide-react"; +import { ChevronDown, ChevronUp, ExternalLink, FileText, Loader2 } from "lucide-react"; import type React from "react"; import { useEffect, useRef, useState } from "react"; import { MarkdownViewer } from "@/components/markdown-viewer"; import { Button } from "@/components/ui/button"; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Sheet, @@ -24,6 +25,7 @@ export const CitationDisplay: React.FC<{ index: number; node: any }> = ({ index, const { document, loading, error, fetchDocumentByChunk, clearDocument } = useDocumentByChunk(); const chunksContainerRef = useRef(null); const highlightedChunkRef = useRef(null); + const [summaryOpen, setSummaryOpen] = useState(false); // Check if this is a source type that should render directly from node const isDirectRenderSource = sourceType === "TAVILY_API" || sourceType === "LINKUP_API"; @@ -165,7 +167,34 @@ export const CitationDisplay: React.FC<{ index: number; node: any }> = ({ index, {/* Chunks */}
-

Document Content

+
+ {/* Header row: header and button side by side */} +
+

Document Content

+ {document.content && ( + + + Summary + {summaryOpen ? ( + + ) : ( + + )} + + + )} +
+ {/* Expanded summary content: always full width, below the row */} + {document.content && ( + + +
+ +
+
+
+ )} +
{document.chunks.map((chunk, idx) => (