diff --git a/frontend/src/app/knowledge/chunks/page.tsx b/frontend/src/app/knowledge/chunks/page.tsx index 254eb511..450032a8 100644 --- a/frontend/src/app/knowledge/chunks/page.tsx +++ b/frontend/src/app/knowledge/chunks/page.tsx @@ -2,18 +2,13 @@ import { ArrowLeft, - Building2, - Cloud, + Copy, File as FileIcon, - FileText, - HardDrive, Loader2, Search, } from "lucide-react"; import { Suspense, useCallback, useEffect, useState } from "react"; import { useRouter, useSearchParams } from "next/navigation"; -import { SiGoogledrive } from "react-icons/si"; -import { TbBrandOnedrive } from "react-icons/tb"; import { ProtectedRoute } from "@/components/protected-route"; import { Button } from "@/components/ui/button"; import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context"; @@ -27,22 +22,6 @@ import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import { Input } from "@/components/ui/input"; -// Function to get the appropriate icon for a connector type -function getSourceIcon(connectorType?: string) { - switch (connectorType) { - case "google_drive": - return ; - case "onedrive": - return ; - case "sharepoint": - return ; - case "s3": - return ; - default: - return ; - } -} - function ChunksPageContent() { const router = useRouter(); const searchParams = useSearchParams(); @@ -51,12 +30,32 @@ function ChunksPageContent() { const filename = searchParams.get("filename"); const [chunks, setChunks] = useState([]); + const [chunksFilteredByQuery, setChunksFilteredByQuery] = useState< + ChunkResult[] + >([]); const [selectAll, setSelectAll] = useState(false); const [queryInputText, setQueryInputText] = useState( parsedFilterData?.query ?? "" ); + useEffect(() => { + if (queryInputText === "") { + setChunksFilteredByQuery(chunks); + } else { + setChunksFilteredByQuery((prevChunks) => + prevChunks.filter((chunk) => + chunk.text.toLowerCase().includes(queryInputText.toLowerCase()) + ) + ); + } + }, [queryInputText, chunks]); + + const handleCopy = useCallback((text: string) => { + console.log("copying text to clipboard:", text); + navigator.clipboard.writeText(text); + }, []); + // Use the same search query as the knowledge page, but we'll filter for the specific file const { data = [], isFetching } = useGetSearchQuery("*", parsedFilterData); console.log({ data }); @@ -118,7 +117,7 @@ function ChunksPageContent() { -
+
- {/*
- {!isFetching && chunks.length > 0 && ( - - {chunks.length} chunk{chunks.length !== 1 ? "s" : ""} found - - )} -
*/}
{/* Content Area - matches knowledge page structure */} @@ -180,35 +172,48 @@ function ChunksPageContent() { ) : (
- {chunks.map((chunk, index) => ( + {chunksFilteredByQuery.map((chunk, index) => (
-
- - - {chunk.filename} +
+
+ +
+ + Chunk {chunk.page} - {chunk.connector_type && ( -
- {getSourceIcon(chunk.connector_type)} -
- )} + + {chunk.text.length} chars + +
+ +
- - {chunk.score.toFixed(2)} - + + {/* TODO: Update to use active toggle */} + {/* + + Active + */}
-
- {chunk.mimetype} - Page {chunk.page} - {chunk.owner_name && Owner: {chunk.owner_name}} +
+
+ {chunk.text} +
-

- {chunk.text} -

))}