Skip to content

Commit c4b9ce6

Browse files
committed
feat: fixed chat Documents table
1 parent 4f6105b commit c4b9ce6

File tree

2 files changed

+300
-181
lines changed

2 files changed

+300
-181
lines changed

surfsense_web/components/chat/ChatInputGroup.tsx

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
SelectValue,
2626
} from "@/components/ui/select";
2727
import { getConnectorIcon } from "@/contracts/enums/connectorIcons";
28-
import { type Document, useDocuments } from "@/hooks/use-documents";
28+
import type { Document } from "@/hooks/use-documents";
2929
import { useLLMConfigs, useLLMPreferences } from "@/hooks/use-llm-configs";
3030
import { useSearchSourceConnectors } from "@/hooks/use-search-source-connectors";
3131

@@ -40,20 +40,9 @@ const DocumentSelector = React.memo(
4040
const { search_space_id } = useParams();
4141
const [isOpen, setIsOpen] = useState(false);
4242

43-
const { documents, loading, isLoaded, fetchDocuments } = useDocuments(Number(search_space_id), {
44-
lazy: true,
45-
pageSize: -1, // Fetch all documents with large page size
46-
});
47-
48-
const handleOpenChange = useCallback(
49-
(open: boolean) => {
50-
setIsOpen(open);
51-
if (open && !isLoaded) {
52-
fetchDocuments();
53-
}
54-
},
55-
[fetchDocuments, isLoaded]
56-
);
43+
const handleOpenChange = useCallback((open: boolean) => {
44+
setIsOpen(open);
45+
}, []);
5746

5847
const handleSelectionChange = useCallback(
5948
(documents: Document[]) => {
@@ -91,21 +80,12 @@ const DocumentSelector = React.memo(
9180
</div>
9281

9382
<div className="flex-1 min-h-0 p-4 md:p-6">
94-
{loading ? (
95-
<div className="flex items-center justify-center h-full">
96-
<div className="text-center space-y-2">
97-
<div className="animate-spin h-8 w-8 border-2 border-primary border-t-transparent rounded-full mx-auto" />
98-
<p className="text-sm text-muted-foreground">Loading documents...</p>
99-
</div>
100-
</div>
101-
) : isLoaded ? (
102-
<DocumentsDataTable
103-
documents={documents}
104-
onSelectionChange={handleSelectionChange}
105-
onDone={handleDone}
106-
initialSelectedDocuments={selectedDocuments}
107-
/>
108-
) : null}
83+
<DocumentsDataTable
84+
searchSpaceId={Number(search_space_id)}
85+
onSelectionChange={handleSelectionChange}
86+
onDone={handleDone}
87+
initialSelectedDocuments={selectedDocuments}
88+
/>
10989
</div>
11090
</div>
11191
</DialogContent>

0 commit comments

Comments
 (0)