Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

Fix delete table refresh and normalize long filename formatting.

Olfa Maslah4c9116662693
diff --git a/frontend/app/knowledge/page.tsx b/frontend/app/knowledge/page.tsx
index abca9792a..e28538be8 100644
--- a/frontend/app/knowledge/page.tsx
+++ b/frontend/app/knowledge/page.tsx
@@ -8,6 +8,7 @@ import {
type ValueFormatterParams,
} from "ag-grid-community";
import { AgGridReact, type CustomCellRendererProps } from "ag-grid-react";
+import { useQueryClient } from "@tanstack/react-query";
import { Cloud, FileIcon, Globe, RefreshCw } from "lucide-react";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useRef, useState } from "react";
@@ -76,6 +77,7 @@ interface IngestionStatus {
}
function SearchPage() {
+ const queryClient = useQueryClient();
const router = useRouter();
const { files: taskFiles, refreshTasks } = useTask();
const { parsedFilterData, queryOverride } = useKnowledgeFilter();
@@ -338,6 +340,9 @@ function SearchPage() {
);
await Promise.all(deletePromises);
+ await refreshTasks();
+ await queryClient.invalidateQueries({ queryKey: ["search"] });
+ await queryClient.refetchQueries({ queryKey: ["search"] });
toast.success(
`Successfully deleted ${selectedRows.length} document${
diff --git a/frontend/components/delete-confirmation-dialog.tsx b/frontend/components/delete-confirmation-dialog.tsx
index 688c31704..80663ac24 100644
--- a/frontend/components/delete-confirmation-dialog.tsx
+++ b/frontend/components/delete-confirmation-dialog.tsx
@@ -25,8 +25,17 @@ export function formatFilesToDelete(
const visibleFiles = files.slice(0, maxVisible);
const remainingCount = files.length - maxVisible;
return (
- <ul className="list-disc list-inside max-w-[29rem] sm:max-w-[calc(425px-3rem)]">
- {visibleFiles.map((file) => <li className="my-2 truncate">{file.filename}</li>)}
+ <ul className="list-disc pl-5">
+ {visibleFiles.map((file) => (
+ <li
+ key={file.filename}
+ className="my-2"
+ title={file.filename}
+ >
+ <p className="overflow-hidden text-ellipsis whitespace-nowrap max-w-[200px]"
+ >{file.filename}</p>
+ </li>
+ ))}
{remainingCount > 0 ? <li>&hellip; and {remainingCount} more document{
remainingCount > 1 ? "s" : ""
}</li> : "" }
diff --git a/frontend/components/knowledge-actions-dropdown.tsx b/frontend/components/knowledge-actions-dropdown.tsx
index 8099a84a1..0cda3d142 100644
--- a/frontend/components/knowledge-actions-dropdown.tsx
+++ b/frontend/components/knowledge-actions-dropdown.tsx
@@ -17,6 +17,7 @@ import { DeleteConfirmationDialog } from "./delete-confirmation-dialog";
import { formatFilesToDelete } from "@/lib/format-files-to-delete";
import { Button } from "./ui/button";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
+import { useTask } from "@/contexts/task-context";
interface KnowledgeActionsDropdownProps {
filename: string;
@@ -30,6 +31,7 @@ export const KnowledgeActionsDropdown = ({
filename,
connectorType,
}: KnowledgeActionsDropdownProps) => {
+ const { refreshTasks } = useTask();
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
const deleteDocumentMutation = useDeleteDocument();
const syncConnectorMutation = useSyncConnector();
@@ -49,7 +51,10 @@ export const KnowledgeActionsDropdown = ({
const handleDelete = async () => {
try {
await deleteDocumentMutation.mutateAsync({ filename });
- toast.success(`Successfully deleted "${filename}"`);
+ await refreshTasks();
+ toast.success("Successfully deleted document", {
+ description: formatFilesToDelete([{ filename }], 1),
+ });
setShowDeleteDialog(false);
} catch (error) {
toast.error(
@@ -158,7 +163,7 @@ export const KnowledgeActionsDropdown = ({
onConfirm={handleDelete}
isLoading={deleteDocumentMutation.isPending}
>
- <p className="my-2">This will remove all chunks and data associated with this document. This action cannot be undone.</p>
+ <p className="my-2 overflow-hidden text-ellipsis max-w-[300px]">This will remove all chunks and data associated with this document. This action cannot be undone.</p>
<p className="my-2">Document to be deleted:</p>
{formatFilesToDelete([{ filename }])}
</DeleteConfirmationDialog>
diff --git a/frontend/lib/format-files-to-delete.tsx b/frontend/lib/format-files-to-delete.tsx
index d8ce474c8..0fbfdd35b 100644
--- a/frontend/lib/format-files-to-delete.tsx
+++ b/frontend/lib/format-files-to-delete.tsx
@@ -7,8 +7,18 @@ export function formatFilesToDelete(
const visibleFiles = files.slice(0, maxVisible);
const remainingCount = files.length - maxVisible;
return (
- <ul className="list-disc list-inside max-w-[29rem] sm:max-w-[calc(425px-3rem)]">
- {visibleFiles.map((file) => <li key={file.filename} className="my-2 truncate">{file.filename}</li>)}
+ <ul className="list-disc pl-5">
+ {visibleFiles.map((file) => (
+ <li
+ key={file.filename}
+ className="my-2"
+ title={file.filename}
+ >
+ <p className="overflow-hidden text-ellipsis whitespace-nowrap max-w-[200px]">
+ {file.filename}
+ </p>
+ </li>
+ ))}
{remainingCount > 0 ? <li>&hellip; and {remainingCount} more document{
remainingCount > 1 ? "s" : ""
}</li> : "" }