{/* Document types from the search space */}
- {activeDocumentTypes.map(([docType, count]) => (
+ {activeDocumentTypes.map(([docType]) => (
{
const thinkingStepsMap = useContext(ThinkingStepsContext);
// Get the current message ID to look up thinking steps
- const messageId = useMessage((m) => m.id);
+ const messageId = useAssistantState(({ message }) => message?.id);
const thinkingSteps = thinkingStepsMap.get(messageId) || [];
// Check if thread is still running (for stopping the spinner when cancelled)
diff --git a/surfsense_web/components/new-chat/DocumentsDataTable.tsx b/surfsense_web/components/new-chat/DocumentsDataTable.tsx
index 290417e53..d97096317 100644
--- a/surfsense_web/components/new-chat/DocumentsDataTable.tsx
+++ b/surfsense_web/components/new-chat/DocumentsDataTable.tsx
@@ -1,49 +1,21 @@
"use client";
import { useQuery } from "@tanstack/react-query";
-import {
- type ColumnDef,
- flexRender,
- getCoreRowModel,
- type SortingState,
- useReactTable,
-} from "@tanstack/react-table";
-import { useAtomValue } from "jotai";
-import { ArrowUpDown, Calendar, FileText, Filter, Plus, Search } from "lucide-react";
-import { useRouter } from "next/navigation";
+import { FileText, Search } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
-import { documentTypeCountsAtom } from "@/atoms/documents/document-query.atoms";
-import { Button } from "@/components/ui/button";
-import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/components/ui/table";
+import { ScrollArea } from "@/components/ui/scroll-area";
import { getConnectorIcon } from "@/contracts/enums/connectorIcons";
-import type { Document, DocumentTypeEnum } from "@/contracts/types/document.types";
+import type { Document } from "@/contracts/types/document.types";
import { documentsApiService } from "@/lib/apis/documents-api.service";
import { cacheKeys } from "@/lib/query-client/cache-keys";
+import { cn } from "@/lib/utils";
interface DocumentsDataTableProps {
searchSpaceId: number;
onSelectionChange: (documents: Document[]) => void;
onDone: () => void;
initialSelectedDocuments?: Document[];
- viewOnly?: boolean;
}
function useDebounced
(value: T, delay = 300) {
@@ -55,551 +27,190 @@ function useDebounced(value: T, delay = 300) {
return debounced;
}
-const columns: ColumnDef[] = [
- {
- id: "select",
- header: ({ table }) => (
- table.toggleAllPageRowsSelected(!!value)}
- aria-label="Select all"
- />
- ),
- cell: ({ row }) => (
- row.toggleSelected(!!value)}
- aria-label="Select row"
- />
- ),
- enableSorting: false,
- enableHiding: false,
- size: 40,
- },
- {
- accessorKey: "title",
- header: ({ column }) => (
-
- ),
- cell: ({ row }) => {
- const title = row.getValue("title") as string;
- return (
-
- {title}
-
- );
- },
- },
- {
- accessorKey: "document_type",
- header: "Type",
- cell: ({ row }) => {
- const type = row.getValue("document_type") as DocumentType;
- return (
-
- {getConnectorIcon(String(type))}
-
- );
- },
- size: 80,
- meta: {
- className: "hidden sm:table-cell",
- },
- },
- {
- accessorKey: "content",
- header: "Preview",
- cell: ({ row }) => {
- const content = row.getValue("content") as string;
- return (
-
- {content.substring(0, 30)}...
- {content.substring(0, 100)}...
-
- );
- },
- enableSorting: false,
- meta: {
- className: "hidden md:table-cell",
- },
- },
- {
- accessorKey: "created_at",
- header: ({ column }) => (
-
- ),
- cell: ({ row }) => {
- const date = new Date(row.getValue("created_at"));
- return (
-
-
- {date.toLocaleDateString("en-US", {
- month: "short",
- day: "numeric",
- year: "numeric",
- })}
-
-
- {date.toLocaleDateString("en-US", {
- month: "numeric",
- day: "numeric",
- })}
-
-
- );
- },
- size: 80,
- },
-];
-
export function DocumentsDataTable({
searchSpaceId,
onSelectionChange,
onDone,
initialSelectedDocuments = [],
}: DocumentsDataTableProps) {
- const router = useRouter();
- const [sorting, setSorting] = useState([]);
const [search, setSearch] = useState("");
const debouncedSearch = useDebounced(search, 300);
- const [documentTypeFilter, setDocumentTypeFilter] = useState([]);
- const [pageIndex, setPageIndex] = useState(0);
- const [pageSize, setPageSize] = useState(10);
- const { data: typeCounts } = useAtomValue(documentTypeCountsAtom);
+ const [highlightedIndex, setHighlightedIndex] = useState(0);
+ const listRef = useRef(null);
+ const itemRefs = useRef