diff --git a/web/public/batch_delete2.png b/web/public/batch_delete2.png new file mode 100644 index 000000000..91d5342cb Binary files /dev/null and b/web/public/batch_delete2.png differ diff --git a/web/public/return2.png b/web/public/return2.png new file mode 100644 index 000000000..4655fb319 Binary files /dev/null and b/web/public/return2.png differ diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 89416aea7..04afa82fc 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -427,7 +427,8 @@ Example: A 1 KB message with 1024-dim embedding uses ~9 KB. The 5 MB default lim paddleocrOptions: 'PaddleOCR Options', paddleocrApiUrl: 'PaddleOCR API URL', paddleocrApiUrlTip: 'The API endpoint URL for PaddleOCR service', - paddleocrApiUrlPlaceholder: 'e.g. https://paddleocr-server.com/layout-parsing', + paddleocrApiUrlPlaceholder: + 'e.g. https://paddleocr-server.com/layout-parsing', paddleocrAccessToken: 'AI Studio Access Token', paddleocrAccessTokenTip: 'Access token for PaddleOCR API (optional)', paddleocrAccessTokenPlaceholder: 'Your AI Studio token (optional)', @@ -866,6 +867,8 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s chatSetting: 'Chat setting', tocEnhance: 'TOC enhance', tocEnhanceTip: ` During the parsing of the document, table of contents information was generated (see the 'Enable Table of Contents Extraction' option in the General method). This allows the large model to return table of contents items relevant to the user's query, thereby using these items to retrieve related chunks and apply weighting to these chunks during the sorting process. This approach is derived from mimicking the behavioral logic of how humans search for knowledge in books.`, + batchDeleteSessions: 'Batch delete', + deleteSelectedConfirm: 'Delete the selected {count} session(s)?', }, setting: { deleteModel: 'Delete model', @@ -1107,14 +1110,15 @@ Example: Virtual Hosted Style`, baseUrlNameMessage: 'Please input your base url!', paddleocr: { apiUrl: 'PaddleOCR API URL', - apiUrlPlaceholder: 'For example: https://paddleocr-server.com/layout-parsing', + apiUrlPlaceholder: + 'For example: https://paddleocr-server.com/layout-parsing', accessToken: 'AI Studio Access Token', accessTokenPlaceholder: 'Your AI Studio token (optional)', algorithm: 'PaddleOCR Algorithm', selectAlgorithm: 'Select Algorithm', modelNamePlaceholder: 'For example: paddleocr-from-env-1', modelNameRequired: 'Model name is required', - apiUrlRequired: 'PaddleOCR API URL is required' + apiUrlRequired: 'PaddleOCR API URL is required', }, vision: 'Does it support Vision?', ollamaLink: 'How to integrate {{name}}', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index a92294361..a4d8e5662 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -826,7 +826,9 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于 avatarHidden: '隐藏头像', locale: '地区', tocEnhance: '目录增强', - tocEnhanceTip: `解析文档时生成了目录信息(见General方法的‘启用目录抽取’),让大模型返回和用户问题相关的目录项,从而利用目录项拿到相关chunk,对这些chunk在排序中进行加权。这种方法来源于模仿人类查询书本中知识的行为逻辑`, + tocEnhanceTip: `解析文档时生成了目录信息(见General方法的'启用目录抽取'),让大模型返回和用户问题相关的目录项,从而利用目录项拿到相关chunk,对这些chunk在排序中进行加权。这种方法来源于模仿人类查询书本中知识的行为逻辑`, + batchDeleteSessions: '批量删除', + deleteSelectedConfirm: '删除选中的 {count} 个会话?', }, setting: { deleteModel: '删除模型', diff --git a/web/src/pages/next-chats/chat/sessions.tsx b/web/src/pages/next-chats/chat/sessions.tsx index 15433b38d..34519b32d 100644 --- a/web/src/pages/next-chats/chat/sessions.tsx +++ b/web/src/pages/next-chats/chat/sessions.tsx @@ -1,16 +1,25 @@ +import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog'; import { MoreButton } from '@/components/more-button'; import { RAGFlowAvatar } from '@/components/ragflow-avatar'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; +import { Checkbox } from '@/components/ui/checkbox'; import { SearchInput } from '@/components/ui/input'; import { useSetModalState } from '@/hooks/common-hooks'; import { useFetchDialog, useGetChatSearchParams, + useRemoveConversation, } from '@/hooks/use-chat-request'; import { cn } from '@/lib/utils'; -import { PanelLeftClose, PanelRightClose, Plus } from 'lucide-react'; -import { useCallback } from 'react'; +import { + Check, + PanelLeftClose, + PanelRightClose, + Plus, + Trash2, +} from 'lucide-react'; +import { useCallback, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useHandleClickConversationCard } from '../hooks/use-click-card'; import { useSelectDerivedConversationList } from '../hooks/use-select-conversation-list'; @@ -35,12 +44,71 @@ export function Sessions({ } = useSelectDerivedConversationList(); const { data } = useFetchDialog(); const { visible, switchVisible } = useSetModalState(true); + const { removeConversation } = useRemoveConversation(); + + // Selection mode state + const [selectionMode, setSelectionMode] = useState(false); + const [selectedIds, setSelectedIds] = useState>(new Set()); + + // Toggle selection mode (click batch delete icon) + const toggleSelectionMode = useCallback(() => { + setSelectionMode(true); + setSelectedIds(new Set()); + }, []); + + // Exit selection mode (click return icon) + const exitSelectionMode = useCallback(() => { + setSelectionMode(false); + setSelectedIds(new Set()); + }, []); + + // Toggle single item selection + const toggleSelection = useCallback((id: string) => { + setSelectedIds((prev) => { + const newSet = new Set(prev); + if (newSet.has(id)) { + newSet.delete(id); + } else { + newSet.add(id); + } + return newSet; + }); + }, []); + + // Toggle select all + const toggleSelectAll = useCallback(() => { + setSelectedIds((prev) => { + if (prev.size === conversationList.length) { + return new Set(); + } + return new Set(conversationList.map((x) => x.id)); + }); + }, [conversationList]); + + // Batch delete + const handleBatchDelete = useCallback(async () => { + if (selectedIds.size > 0) { + await removeConversation(Array.from(selectedIds)); + exitSelectionMode(); + } + }, [selectedIds, removeConversation, exitSelectionMode]); + + const selectedCount = useMemo(() => selectedIds.size, [selectedIds]); + const allSelected = useMemo( + () => + selectedCount === conversationList.length && conversationList.length > 0, + [selectedCount, conversationList.length], + ); const handleCardClick = useCallback( (conversationId: string, isNew: boolean) => () => { - handleConversationCardClick(conversationId, isNew); + if (selectionMode) { + toggleSelection(conversationId); + } else { + handleConversationCardClick(conversationId, isNew); + } }, - [handleConversationCardClick], + [handleConversationCardClick, selectionMode, toggleSelection], ); const { conversationId } = useGetChatSearchParams(); @@ -55,7 +123,7 @@ export function Sessions({ } return ( -
+
- + {selectionMode && selectedCount > 0 ? ( + // Selection mode with items selected: show return and delete +
+ + + + +
+ ) : ( + // Default or selection mode without selection: show plus and batch delete +
+ + +
+ )}
-
{x.name}
- - - +
+ {selectionMode && ( + e.stopPropagation()} + onMouseDown={(e) => e.stopPropagation()} + > + toggleSelection(x.id)} + /> + + )} +
{x.name}
+
+ {!selectionMode && ( + + + + )}
))}