diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx index ba9baf2c5..60ae4b2cf 100644 --- a/surfsense_web/components/assistant-ui/thread.tsx +++ b/surfsense_web/components/assistant-ui/thread.tsx @@ -21,7 +21,9 @@ import { RefreshCwIcon, SquareIcon, } from "lucide-react"; +import { useParams } from "next/navigation"; import type { FC } from "react"; +import { useRef, useState } from "react"; import { ComposerAddAttachment, ComposerAttachments, @@ -30,14 +32,10 @@ import { import { MarkdownText } from "@/components/assistant-ui/markdown-text"; import { ToolFallback } from "@/components/assistant-ui/tool-fallback"; import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button"; -import { Button } from "@/components/ui/button"; -import { cn } from "@/lib/utils"; -import { useRef, useState, useMemo } from "react"; -import { useAtomValue } from "jotai"; -import { useParams } from "next/navigation"; -import type { Document } from "@/contracts/types/document.types"; -import { documentsAtom } from "@/atoms/documents/document-query.atoms"; import { DocumentsDataTable } from "@/components/new-chat/DocumentsDataTable"; +import { Button } from "@/components/ui/button"; +import type { Document } from "@/contracts/types/document.types"; +import { cn } from "@/lib/utils"; export const Thread: FC = () => { return ( @@ -151,13 +149,9 @@ const Composer: FC = () => { const [allSelectedDocuments, setAllSelectedDocuments] = useState([]); const [mentionedDocuments, setMentionedDocuments] = useState([]); const [showDocumentPopover, setShowDocumentPopover] = useState(false); - const [mentionModalSelectedDocs, setMentionModalSelectedDocs] = useState([]); const [inputValue, setInputValue] = useState(""); const inputRef = useRef(null); - const documentsResult = useAtomValue(documentsAtom); // Atom fetches all docs for this workspace - const allDocuments = documentsResult?.data?.items || []; const { search_space_id } = useParams(); - const searchSpaceId = typeof search_space_id === "string" ? parseInt(search_space_id, 10) : 0; const handleInputOrKeyUp = ( e: React.FormEvent | React.KeyboardEvent @@ -194,8 +188,8 @@ const Composer: FC = () => { const handleDocumentsMention = (documents: Document[]) => { // Add newly selected docs to allSelectedDocuments - setAllSelectedDocuments(prev => { - const toAdd = documents.filter(doc => !prev.find(p => p.id === doc.id)); + setAllSelectedDocuments((prev) => { + const toAdd = documents.filter((doc) => !prev.find((p) => p.id === doc.id)); return [...prev, ...toAdd]; }); let newValue = inputValue; @@ -217,7 +211,7 @@ const Composer: FC = () => { titlesMentioned.push(match[1]); } setMentionedDocuments( - allSelectedDocuments.filter(doc => titlesMentioned.includes(doc.title)) + allSelectedDocuments.filter((doc) => titlesMentioned.includes(doc.title)) ); }; @@ -256,10 +250,14 @@ const Composer: FC = () => { )} {/* ---- Mention chips for selected/mentioned documents ---- */} - {mentionedDocuments.length > 0 && ( + {mentionedDocuments.length > 0 && (
{mentionedDocuments.map((doc) => ( - + {doc.title} ))} diff --git a/surfsense_web/components/new-chat/DocumentsDataTable.tsx b/surfsense_web/components/new-chat/DocumentsDataTable.tsx index 182543364..290417e53 100644 --- a/surfsense_web/components/new-chat/DocumentsDataTable.tsx +++ b/surfsense_web/components/new-chat/DocumentsDataTable.tsx @@ -182,7 +182,7 @@ export function DocumentsDataTable({ searchSpaceId, onSelectionChange, onDone, - initialSelectedDocuments = [] + initialSelectedDocuments = [], }: DocumentsDataTableProps) { const router = useRouter(); const [sorting, setSorting] = useState([]); @@ -545,18 +545,18 @@ export function DocumentsDataTable({

No documents found

-

- Get started by adding your first data source to build your knowledge - base. -

+

+ Get started by adding your first data source to build your knowledge + base. +

- +