diff --git a/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsFilters.tsx b/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsFilters.tsx index e31cb508b..ff9e1f246 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsFilters.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsFilters.tsx @@ -3,12 +3,12 @@ import { useSetAtom } from "jotai"; import { CircleAlert, - FilePlus2, FileType, ListFilter, Search, SlidersHorizontal, Trash, + Upload, X, } from "lucide-react"; import { motion } from "motion/react"; @@ -96,7 +96,7 @@ export function DocumentsFilters({ size="sm" className="h-9 gap-2 bg-white text-gray-700 border-white hover:bg-gray-50 dark:bg-white dark:text-gray-800 dark:hover:bg-gray-100" > - + Upload documents - + + {!thread.archived && ( handleToggleArchive(thread.id, thread.archived)} - disabled={isArchiving} + onClick={() => handleStartRename(thread.id, thread.title || "New Chat")} > + + {t("rename") || "Rename"} + + )} + handleToggleArchive(thread.id, thread.archived)} + disabled={isArchiving} + > {thread.archived ? ( <> @@ -412,6 +462,51 @@ export function AllPrivateChatsSidebar({ )} + + + + + {t("rename_chat") || "Rename Chat"} + + + {t("rename_chat_description") || "Enter a new name for this conversation."} + + + setNewTitle(e.target.value)} + placeholder={t("chat_title_placeholder") || "Chat title"} + onKeyDown={(e) => { + if (e.key === "Enter" && !isRenaming && newTitle.trim()) { + handleConfirmRename(); + } + }} + /> + + + + + + ); } diff --git a/surfsense_web/components/layout/ui/sidebar/AllSharedChatsSidebar.tsx b/surfsense_web/components/layout/ui/sidebar/AllSharedChatsSidebar.tsx index fae9fb05e..67a5c5804 100644 --- a/surfsense_web/components/layout/ui/sidebar/AllSharedChatsSidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/AllSharedChatsSidebar.tsx @@ -6,6 +6,7 @@ import { ArchiveIcon, MessageCircleMore, MoreHorizontal, + PenLine, RotateCcwIcon, Search, Trash2, @@ -17,6 +18,14 @@ import { useTranslations } from "next-intl"; import { useCallback, useEffect, useMemo, useState } from "react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; import { DropdownMenu, DropdownMenuContent, @@ -69,6 +78,10 @@ export function AllSharedChatsSidebar({ const [searchQuery, setSearchQuery] = useState(""); const [showArchived, setShowArchived] = useState(false); const [openDropdownId, setOpenDropdownId] = useState(null); + const [showRenameDialog, setShowRenameDialog] = useState(false); + const [renamingThread, setRenamingThread] = useState<{ id: number; title: string } | null>(null); + const [newTitle, setNewTitle] = useState(""); + const [isRenaming, setIsRenaming] = useState(false); const debouncedSearchQuery = useDebouncedValue(searchQuery, 300); const isSearchMode = !!debouncedSearchQuery.trim(); @@ -187,6 +200,35 @@ export function AllSharedChatsSidebar({ [queryClient, searchSpaceId, t] ); + const handleStartRename = useCallback((threadId: number, title: string) => { + setRenamingThread({ id: threadId, title }); + setNewTitle(title); + setShowRenameDialog(true); + }, []); + + const handleConfirmRename = useCallback(async () => { + if (!renamingThread || !newTitle.trim()) return; + setIsRenaming(true); + try { + await updateThread(renamingThread.id, { title: newTitle.trim() }); + toast.success(t("chat_renamed") || "Chat renamed"); + queryClient.invalidateQueries({ queryKey: ["all-threads", searchSpaceId] }); + queryClient.invalidateQueries({ queryKey: ["search-threads", searchSpaceId] }); + queryClient.invalidateQueries({ queryKey: ["threads", searchSpaceId] }); + queryClient.invalidateQueries({ + queryKey: ["threads", searchSpaceId, "detail", String(renamingThread.id)], + }); + } catch (error) { + console.error("Error renaming thread:", error); + toast.error(t("error_renaming_chat") || "Failed to rename chat"); + } finally { + setIsRenaming(false); + setShowRenameDialog(false); + setRenamingThread(null); + setNewTitle(""); + } + }, [renamingThread, newTitle, queryClient, searchSpaceId, t]); + const handleClearSearch = useCallback(() => { setSearchQuery(""); }, []); @@ -355,12 +397,20 @@ export function AllSharedChatsSidebar({ {t("more_options") || "More options"} - + + {!thread.archived && ( handleToggleArchive(thread.id, thread.archived)} - disabled={isArchiving} + onClick={() => handleStartRename(thread.id, thread.title || "New Chat")} > - {thread.archived ? ( + + {t("rename") || "Rename"} + + )} + handleToggleArchive(thread.id, thread.archived)} + disabled={isArchiving} + > + {thread.archived ? ( <> {t("unarchive") || "Restore"} @@ -412,6 +462,51 @@ export function AllSharedChatsSidebar({ )} + + + + + {t("rename_chat") || "Rename Chat"} + + + {t("rename_chat_description") || "Enter a new name for this conversation."} + + + setNewTitle(e.target.value)} + placeholder={t("chat_title_placeholder") || "Chat title"} + onKeyDown={(e) => { + if (e.key === "Enter" && !isRenaming && newTitle.trim()) { + handleConfirmRename(); + } + }} + /> + + + + + + ); } diff --git a/surfsense_web/components/layout/ui/sidebar/SidebarSlideOutPanel.tsx b/surfsense_web/components/layout/ui/sidebar/SidebarSlideOutPanel.tsx index beb1c81c0..805911f88 100644 --- a/surfsense_web/components/layout/ui/sidebar/SidebarSlideOutPanel.tsx +++ b/surfsense_web/components/layout/ui/sidebar/SidebarSlideOutPanel.tsx @@ -65,7 +65,7 @@ export function SidebarSlideOutPanel({ exit={{ x: "-100%" }} transition={{ type: "tween", duration: 0.2, ease: [0.4, 0, 0.2, 1] }} className={cn( - "h-full w-full bg-background flex flex-col pointer-events-auto", + "h-full w-full bg-background flex flex-col pointer-events-auto select-none", "sm:border-r sm:shadow-xl" )} role="dialog" diff --git a/surfsense_web/components/sources/DocumentUploadTab.tsx b/surfsense_web/components/sources/DocumentUploadTab.tsx index 1018cbdf6..94ba187d6 100644 --- a/surfsense_web/components/sources/DocumentUploadTab.tsx +++ b/surfsense_web/components/sources/DocumentUploadTab.tsx @@ -1,7 +1,7 @@ "use client"; import { useAtom } from "jotai"; -import { CheckCircle2, FileType, Info, Tag, Upload, X } from "lucide-react"; +import { CheckCircle2, FileType, Info, Upload, X } from "lucide-react"; import { AnimatePresence, motion } from "motion/react"; import { useTranslations } from "next-intl"; import { useCallback, useMemo, useRef, useState } from "react"; @@ -452,7 +452,6 @@ export function DocumentUploadTab({
-
{t("supported_file_types")} diff --git a/surfsense_web/messages/en.json b/surfsense_web/messages/en.json index 319595f8e..d7b062ce1 100644 --- a/surfsense_web/messages/en.json +++ b/surfsense_web/messages/en.json @@ -682,7 +682,7 @@ "rename_chat": "Rename Chat", "rename_chat_description": "Enter a new name for this conversation.", "chat_title_placeholder": "Chat title", - "renaming": "Renaming...", + "renaming": "Renaming", "no_archived_chats": "No archived chats", "error_archiving_chat": "Failed to archive chat", "new_chat": "New chat", @@ -720,7 +720,8 @@ "unread": "Unread", "connectors": "Connectors", "all_connectors": "All connectors", - "close": "Close" + "close": "Close", + "cancel": "Cancel" }, "errors": { "something_went_wrong": "Something went wrong", diff --git a/surfsense_web/messages/es.json b/surfsense_web/messages/es.json index acf0a184b..d21b635b5 100644 --- a/surfsense_web/messages/es.json +++ b/surfsense_web/messages/es.json @@ -720,7 +720,8 @@ "unread": "No leído", "connectors": "Conectores", "all_connectors": "Todos los conectores", - "close": "Cerrar" + "close": "Cerrar", + "cancel": "Cancelar" }, "errors": { "something_went_wrong": "Algo salió mal", diff --git a/surfsense_web/messages/hi.json b/surfsense_web/messages/hi.json index 1c95ce203..6a3cb7ffb 100644 --- a/surfsense_web/messages/hi.json +++ b/surfsense_web/messages/hi.json @@ -720,7 +720,8 @@ "unread": "अपठित", "connectors": "कनेक्टर", "all_connectors": "सभी कनेक्टर", - "close": "बंद करें" + "close": "बंद करें", + "cancel": "रद्द करें" }, "errors": { "something_went_wrong": "कुछ गलत हो गया", diff --git a/surfsense_web/messages/pt.json b/surfsense_web/messages/pt.json index aaf3b36f7..ddaa7c0d3 100644 --- a/surfsense_web/messages/pt.json +++ b/surfsense_web/messages/pt.json @@ -720,7 +720,8 @@ "unread": "Não lido", "connectors": "Conectores", "all_connectors": "Todos os conectores", - "close": "Fechar" + "close": "Fechar", + "cancel": "Cancelar" }, "errors": { "something_went_wrong": "Algo deu errado", diff --git a/surfsense_web/messages/zh.json b/surfsense_web/messages/zh.json index 0096b68aa..db29eb198 100644 --- a/surfsense_web/messages/zh.json +++ b/surfsense_web/messages/zh.json @@ -704,7 +704,8 @@ "unread": "未读", "connectors": "连接器", "all_connectors": "所有连接器", - "close": "关闭" + "close": "关闭", + "cancel": "取消" }, "errors": { "something_went_wrong": "出错了",