diff --git a/surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx b/surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx index 24be65cce..272f34509 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx @@ -2,491 +2,511 @@ import { format } from "date-fns"; import { - Calendar, - ExternalLink, - MessageCircleMore, - MoreHorizontal, - Search, - Tag, - Trash2, + Calendar, + ExternalLink, + MessageCircleMore, + MoreHorizontal, + Search, + Tag, + Trash2, } from "lucide-react"; import { AnimatePresence, motion, type Variants } from "motion/react"; import { useRouter, useSearchParams } from "next/navigation"; import { useEffect, useState } from "react"; -import { toast } from "sonner"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; -import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, + Card, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, } from "@/components/ui/dialog"; import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuSeparator, + DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Input } from "@/components/ui/input"; import { - Pagination, - PaginationContent, - PaginationItem, - PaginationLink, - PaginationNext, - PaginationPrevious, + Pagination, + PaginationContent, + PaginationItem, + PaginationLink, + PaginationNext, + PaginationPrevious, } from "@/components/ui/pagination"; import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectTrigger, - SelectValue, + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectTrigger, + SelectValue, } from "@/components/ui/select"; -import { cn } from "@/lib/utils"; -import { useAtomValue } from "jotai"; -import { activeSearchSpaceChatsAtom } from "@/atoms/chats/queries/active-search-space-chats.atom"; +import { useAtom, useAtomValue } from "jotai"; +import { activeSearchSpaceChatsAtom } from "@/atoms/chats/queries/active-search-space-chats.query.atom"; +import { deleteChatMutationAtom } from "@/atoms/chats/mutations/delete-chat.mutation.atom"; export interface Chat { - created_at: string; - id: number; - type: "DOCUMENT" | "CHAT"; - title: string; - search_space_id: number; - state_version: number; + created_at: string; + id: number; + type: "DOCUMENT" | "CHAT"; + title: string; + search_space_id: number; + state_version: number; } export interface ChatDetails { - type: "DOCUMENT" | "CHAT"; - title: string; - initial_connectors: string[]; - messages: any[]; - created_at: string; - id: number; - search_space_id: number; - state_version: number; + type: "DOCUMENT" | "CHAT"; + title: string; + initial_connectors: string[]; + messages: any[]; + created_at: string; + id: number; + search_space_id: number; + state_version: number; } interface ChatsPageClientProps { - searchSpaceId: string; + searchSpaceId: string; } const pageVariants: Variants = { - initial: { opacity: 0 }, - enter: { opacity: 1, transition: { duration: 0.3, ease: "easeInOut" } }, - exit: { opacity: 0, transition: { duration: 0.3, ease: "easeInOut" } }, + initial: { opacity: 0 }, + enter: { opacity: 1, transition: { duration: 0.3, ease: "easeInOut" } }, + exit: { opacity: 0, transition: { duration: 0.3, ease: "easeInOut" } }, }; const chatCardVariants: Variants = { - initial: { y: 20, opacity: 0 }, - animate: { y: 0, opacity: 1 }, - exit: { y: -20, opacity: 0 }, + initial: { y: 20, opacity: 0 }, + animate: { y: 0, opacity: 1 }, + exit: { y: -20, opacity: 0 }, }; const MotionCard = motion(Card); -export default function ChatsPageClient({ searchSpaceId }: ChatsPageClientProps) { - const router = useRouter(); - const [filteredChats, setFilteredChats] = useState([]); - const [searchQuery, setSearchQuery] = useState(""); - const [currentPage, setCurrentPage] = useState(1); - const [totalPages, setTotalPages] = useState(1); - const [selectedType, setSelectedType] = useState("all"); - const [sortOrder, setSortOrder] = useState("newest"); - const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); - const [chatToDelete, setChatToDelete] = useState<{ id: number; title: string } | null>(null); - const [isDeleting, setIsDeleting] = useState(false); - const {isFetching , data : chats, error} = useAtomValue(activeSearchSpaceChatsAtom); +export default function ChatsPageClient({ + searchSpaceId, +}: ChatsPageClientProps) { + const router = useRouter(); + const [filteredChats, setFilteredChats] = useState([]); + const [searchQuery, setSearchQuery] = useState(""); + const [currentPage, setCurrentPage] = useState(1); + const [totalPages, setTotalPages] = useState(1); + const [selectedType, setSelectedType] = useState("all"); + const [sortOrder, setSortOrder] = useState("newest"); + const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); + const [chatToDelete, setChatToDelete] = useState<{ + id: number; + title: string; + } | null>(null); + const { + isFetching: isFetchingChats, + data: chats, + error: fetchError, + } = useAtomValue(activeSearchSpaceChatsAtom); + const [ + { isPending: isDeletingChat, mutateAsync: deleteChat, error: deleteError } + ] = useAtom(deleteChatMutationAtom); - const chatsPerPage = 9; - const searchParams = useSearchParams(); + const chatsPerPage = 9; + const searchParams = useSearchParams(); - // Get initial page from URL params if it exists - useEffect(() => { - const pageParam = searchParams.get("page"); - if (pageParam) { - const pageNumber = parseInt(pageParam, 10); - if (!Number.isNaN(pageNumber) && pageNumber > 0) { - setCurrentPage(pageNumber); - } - } - }, [searchParams]); + // Get initial page from URL params if it exists + useEffect(() => { + const pageParam = searchParams.get("page"); + if (pageParam) { + const pageNumber = parseInt(pageParam, 10); + if (!Number.isNaN(pageNumber) && pageNumber > 0) { + setCurrentPage(pageNumber); + } + } + }, [searchParams]); + useEffect(() => { + if (fetchError) { + console.error("Error fetching chats:", fetchError); + } + }, [fetchError]); - useEffect(() => { - if (error) { - console.error("Error fetching chats:", error); - } - }, [error]); + useEffect(() => { + if (deleteError) { + console.error("Error deleting chat:", deleteError); + } + }, [deleteError]); - // Filter and sort chats based on search query, type, and sort order - useEffect(() => { - let result = [...(chats || [])]; + // Filter and sort chats based on search query, type, and sort order + useEffect(() => { + let result = [...(chats || [])]; - // Filter by search term - if (searchQuery) { - const query = searchQuery.toLowerCase(); - result = result.filter((chat) => chat.title.toLowerCase().includes(query)); - } + // Filter by search term + if (searchQuery) { + const query = searchQuery.toLowerCase(); + result = result.filter((chat) => + chat.title.toLowerCase().includes(query) + ); + } - // Filter by type - if (selectedType !== "all") { - result = result.filter((chat) => chat.type === selectedType); - } + // Filter by type + if (selectedType !== "all") { + result = result.filter((chat) => chat.type === selectedType); + } - // Sort chats - result.sort((a, b) => { - const dateA = new Date(a.created_at).getTime(); - const dateB = new Date(b.created_at).getTime(); + // Sort chats + result.sort((a, b) => { + const dateA = new Date(a.created_at).getTime(); + const dateB = new Date(b.created_at).getTime(); - return sortOrder === "newest" ? dateB - dateA : dateA - dateB; - }); + return sortOrder === "newest" ? dateB - dateA : dateA - dateB; + }); - setFilteredChats(result); - setTotalPages(Math.max(1, Math.ceil(result.length / chatsPerPage))); + setFilteredChats(result); + setTotalPages(Math.max(1, Math.ceil(result.length / chatsPerPage))); - // Reset to first page when filters change - if (currentPage !== 1 && (searchQuery || selectedType !== "all" || sortOrder !== "newest")) { - setCurrentPage(1); - } - }, [chats, searchQuery, selectedType, sortOrder, currentPage]); + // Reset to first page when filters change + if ( + currentPage !== 1 && + (searchQuery || selectedType !== "all" || sortOrder !== "newest") + ) { + setCurrentPage(1); + } + }, [chats, searchQuery, selectedType, sortOrder, currentPage]); - // Function to handle chat deletion - const handleDeleteChat = async () => { - // if (!chatToDelete) return; + // Function to handle chat deletion + const handleDeleteChat = async () => { + if (!chatToDelete) return; - // setIsDeleting(true); - // try { - // const token = localStorage.getItem("surfsense_bearer_token"); - // if (!token) { - // setIsDeleting(false); - // return; - // } + await deleteChat(chatToDelete.id); - // const response = await fetch( - // `${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/chats/${chatToDelete.id}`, - // { - // method: "DELETE", - // headers: { - // Authorization: `Bearer ${token}`, - // "Content-Type": "application/json", - // }, - // } - // ); + setDeleteDialogOpen(false); + setChatToDelete(null); + }; - // if (!response.ok) { - // throw new Error(`Failed to delete chat: ${response.statusText}`); - // } + // Calculate pagination + const indexOfLastChat = currentPage * chatsPerPage; // Index of last chat in the current page + const indexOfFirstChat = indexOfLastChat - chatsPerPage; // Index of first chat in the current page + const currentChats = filteredChats.slice(indexOfFirstChat, indexOfLastChat); - // // Close dialog and refresh chats - // setDeleteDialogOpen(false); - // setChatToDelete(null); + // Get unique chat types for filter dropdown + const chatTypes = chats + ? ["all", ...Array.from(new Set(chats.map((chat) => chat.type)))] + : []; - // // Update local state by removing the deleted chat - // setChats((prevChats) => prevChats.filter((chat) => chat.id !== chatToDelete.id)); - // } catch (error) { - // console.error("Error deleting chat:", error); - // } finally { - // setIsDeleting(false); - // } - }; + return ( + +
+
+

All Chats

+

+ View, search, and manage all your chats. +

+
- // Calculate pagination - const indexOfLastChat = currentPage * chatsPerPage; // Index of last chat in the current page - const indexOfFirstChat = indexOfLastChat - chatsPerPage; // Index of first chat in the current page - const currentChats = filteredChats.slice(indexOfFirstChat, indexOfLastChat); + {/* Filter and Search Bar */} +
+
+
+ + setSearchQuery(e.target.value)} + /> +
- // Get unique chat types for filter dropdown - const chatTypes = chats ? ["all", ...Array.from(new Set(chats.map((chat) => chat.type)))] : []; + +
- return ( - -
-
-

All Chats

-

View, search, and manage all your chats.

-
+
+ +
+
- {/* Filter and Search Bar */} -
-
-
- - setSearchQuery(e.target.value)} - /> -
+ {/* Status Messages */} + {isFetchingChats && ( +
+
+
+

Loading chats...

+
+
+ )} - -
+ {fetchError && !isFetchingChats && ( +
+

Error loading chats

+

{fetchError.message}

+
+ )} -
- -
-
+ {!isFetchingChats && !fetchError && filteredChats.length === 0 && ( +
+ +

No chats found

+

+ {searchQuery || selectedType !== "all" + ? "Try adjusting your search filters" + : "Start a new chat to get started"} +

+
+ )} - {/* Status Messages */} - {isFetching && ( -
-
-
-

Loading chats...

-
-
- )} + {/* Chat Grid */} + {!isFetchingChats && !fetchError && filteredChats.length > 0 && ( + +
+ {currentChats.map((chat, index) => ( + + +
+
+ + {chat.title || `Chat ${chat.id}`} + + + + + + {format(new Date(chat.created_at), "MMM d, yyyy")} + + + +
+ + + + + + + router.push( + `/dashboard/${chat.search_space_id}/researcher/${chat.id}` + ) + } + > + + View Chat + + + { + e.stopPropagation(); + setChatToDelete({ + id: chat.id, + title: chat.title || `Chat ${chat.id}`, + }); + setDeleteDialogOpen(true); + }} + > + + Delete Chat + + + +
+
- {error && !isFetching && ( -
-

Error loading chats

-

{error.message}

-
- )} + + + + {chat.type || "Unknown"} + + + +
+ ))} +
+
+ )} - {!isFetching && !error && filteredChats.length === 0 && ( -
- -

No chats found

-

- {searchQuery || selectedType !== "all" - ? "Try adjusting your search filters" - : "Start a new chat to get started"} -

-
- )} + {/* Pagination */} + {!isFetchingChats && !fetchError && totalPages > 1 && ( + + + + { + e.preventDefault(); + if (currentPage > 1) setCurrentPage(currentPage - 1); + }} + className={ + currentPage <= 1 ? "pointer-events-none opacity-50" : "" + } + /> + - {/* Chat Grid */} - {!isFetching && !error && filteredChats.length > 0 && ( - -
- {currentChats.map((chat, index) => ( - - -
-
- - {chat.title || `Chat ${chat.id}`} - - - - - {format(new Date(chat.created_at), "MMM d, yyyy")} - - -
- - - - - - - router.push( - `/dashboard/${chat.search_space_id}/researcher/${chat.id}` - ) - } - > - - View Chat - - - { - e.stopPropagation(); - setChatToDelete({ - id: chat.id, - title: chat.title || `Chat ${chat.id}`, - }); - setDeleteDialogOpen(true); - }} - > - - Delete Chat - - - -
-
+ {Array.from({ length: totalPages }).map((_, index) => { + const pageNumber = index + 1; + const isVisible = + pageNumber === 1 || + pageNumber === totalPages || + (pageNumber >= currentPage - 1 && + pageNumber <= currentPage + 1); - - - - {chat.type || "Unknown"} - - - -
- ))} -
-
- )} + if (!isVisible) { + // Show ellipsis at appropriate positions + if (pageNumber === 2 || pageNumber === totalPages - 1) { + return ( + + + ... + + + ); + } + return null; + } - {/* Pagination */} - {!isFetching && !error && totalPages > 1 && ( - - - - { - e.preventDefault(); - if (currentPage > 1) setCurrentPage(currentPage - 1); - }} - className={currentPage <= 1 ? "pointer-events-none opacity-50" : ""} - /> - + return ( + + { + e.preventDefault(); + setCurrentPage(pageNumber); + }} + isActive={pageNumber === currentPage} + > + {pageNumber} + + + ); + })} - {Array.from({ length: totalPages }).map((_, index) => { - const pageNumber = index + 1; - const isVisible = - pageNumber === 1 || - pageNumber === totalPages || - (pageNumber >= currentPage - 1 && pageNumber <= currentPage + 1); + + { + e.preventDefault(); + if (currentPage < totalPages) + setCurrentPage(currentPage + 1); + }} + className={ + currentPage >= totalPages + ? "pointer-events-none opacity-50" + : "" + } + /> + + + + )} +
- if (!isVisible) { - // Show ellipsis at appropriate positions - if (pageNumber === 2 || pageNumber === totalPages - 1) { - return ( - - ... - - ); - } - return null; - } - - return ( - - { - e.preventDefault(); - setCurrentPage(pageNumber); - }} - isActive={pageNumber === currentPage} - > - {pageNumber} - - - ); - })} - - - { - e.preventDefault(); - if (currentPage < totalPages) setCurrentPage(currentPage + 1); - }} - className={currentPage >= totalPages ? "pointer-events-none opacity-50" : ""} - /> - - - - )} -
- - {/* Delete Confirmation Dialog */} - - - - - - Delete Chat - - - Are you sure you want to delete{" "} - {chatToDelete?.title}? This action cannot be - undone. - - - - - - - - -
- ); + {/* Delete Confirmation Dialog */} + + + + + + Delete Chat + + + Are you sure you want to delete{" "} + {chatToDelete?.title}? This + action cannot be undone. + + + + + + + + + + ); } diff --git a/surfsense_web/app/dashboard/[search_space_id]/client-layout.tsx b/surfsense_web/app/dashboard/[search_space_id]/client-layout.tsx index b1526a3ad..ceeb1e7f4 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/client-layout.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/client-layout.tsx @@ -27,8 +27,8 @@ import { } from "@/components/ui/sidebar"; import { useLLMPreferences } from "@/hooks/use-llm-configs"; import { cn } from "@/lib/utils"; -import { activeChatIdAtom } from "@/atoms/chats/queries/active-chat.atom"; -import { chatUIAtom } from "@/atoms/chats/active-chat-ui.atom"; +import { activeChatIdAtom } from "@/atoms/chats/queries/active-chat.query.atom"; +import { chatUIAtom } from "@/atoms/chats/active-chat.atom"; import { activeSearchSpaceIdAtom } from "@/atoms/seach-spaces/active-seach-space.atom"; export function DashboardClientLayout({ diff --git a/surfsense_web/atoms/chats/active-chat-ui.atom.ts b/surfsense_web/atoms/chats/active-chat.atom.ts similarity index 100% rename from surfsense_web/atoms/chats/active-chat-ui.atom.ts rename to surfsense_web/atoms/chats/active-chat.atom.ts diff --git a/surfsense_web/atoms/chats/mutations/delete-chat.mutation.atom.ts b/surfsense_web/atoms/chats/mutations/delete-chat.mutation.atom.ts new file mode 100644 index 000000000..994906c24 --- /dev/null +++ b/surfsense_web/atoms/chats/mutations/delete-chat.mutation.atom.ts @@ -0,0 +1,33 @@ +import { atomWithMutation } from "jotai-tanstack-query"; +import { deleteChat } from "@/lib/apis/chat-apis"; +import { activeSearchSpaceIdAtom } from "../../seach-spaces/active-seach-space.atom"; +import { queryClient } from "@/lib/query-client/client"; +import { cacheKeys } from "@/lib/query-client/cache-keys"; +import { toast } from "sonner"; + +export const deleteChatMutationAtom = atomWithMutation((get) => { + const searchSpaceId = get(activeSearchSpaceIdAtom); + const authToken = localStorage.getItem("surfsense_bearer_token"); + + return { + mutationKey: cacheKeys.activeSearchSpace.chats(searchSpaceId ?? ""), + enabled: !!searchSpaceId && !!authToken, + mutationFn: async (chatId: number) => { + if (!authToken) { + throw new Error("No authentication token found"); + } + if (!searchSpaceId) { + throw new Error("No search space id found"); + } + + return deleteChat(chatId, authToken); + }, + + onSuccess: () => { + toast.success("Chat deleted successfully"); + queryClient.invalidateQueries({ + queryKey: cacheKeys.activeSearchSpace.chats(searchSpaceId!), + }); + }, + }; +}); diff --git a/surfsense_web/atoms/chats/queries/active-chat.atom.ts b/surfsense_web/atoms/chats/queries/active-chat.query.atom.ts similarity index 87% rename from surfsense_web/atoms/chats/queries/active-chat.atom.ts rename to surfsense_web/atoms/chats/queries/active-chat.query.atom.ts index 48f650768..cb4ad9201 100644 --- a/surfsense_web/atoms/chats/queries/active-chat.atom.ts +++ b/surfsense_web/atoms/chats/queries/active-chat.query.atom.ts @@ -18,18 +18,8 @@ export const activeChatAtom = atomWithQuery((get) => { const activeChatId = get(activeChatIdAtom); const authToken = localStorage.getItem("surfsense_bearer_token"); - if (!activeChatId) { - return { - queryKey: [], - enabled: false, - queryFn: async () => { - return { chatId: null, chatDetails: null, podcast: null }; - }, - }; - } - return { - queryKey: cacheKeys.activeSearchSpace.activeChat(activeChatId), + queryKey: cacheKeys.activeSearchSpace.activeChat(activeChatId ?? ""), enabled: !!activeChatId && !!authToken, queryFn: async () => { if (!authToken) { diff --git a/surfsense_web/atoms/chats/queries/active-search-space-chats.atom.ts b/surfsense_web/atoms/chats/queries/active-search-space-chats.query.atom.ts similarity index 84% rename from surfsense_web/atoms/chats/queries/active-search-space-chats.atom.ts rename to surfsense_web/atoms/chats/queries/active-search-space-chats.query.atom.ts index 0b8b30eb0..feafcf434 100644 --- a/surfsense_web/atoms/chats/queries/active-search-space-chats.atom.ts +++ b/surfsense_web/atoms/chats/queries/active-search-space-chats.query.atom.ts @@ -1,13 +1,14 @@ import { atomWithQuery } from "jotai-tanstack-query"; import { fetchChatsBySearchSpace } from "@/lib/apis/chat-apis"; import { activeSearchSpaceIdAtom } from "../../seach-spaces/active-seach-space.atom"; +import { cacheKeys } from "@/lib/query-client/cache-keys"; export const activeSearchSpaceChatsAtom = atomWithQuery((get) => { const searchSpaceId = get(activeSearchSpaceIdAtom); const authToken = localStorage.getItem("surfsense_bearer_token"); return { - queryKey: ["chatsBySearchSpace", searchSpaceId], + queryKey: cacheKeys.activeSearchSpace.chats(searchSpaceId ?? ""), enabled: !!searchSpaceId && !!authToken, queryFn: async () => { if (!authToken) { diff --git a/surfsense_web/components/chat/ChatPanel/ChatPanelContainer.tsx b/surfsense_web/components/chat/ChatPanel/ChatPanelContainer.tsx index a412f99a8..bc443d143 100644 --- a/surfsense_web/components/chat/ChatPanel/ChatPanelContainer.tsx +++ b/surfsense_web/components/chat/ChatPanel/ChatPanelContainer.tsx @@ -4,8 +4,8 @@ import { LoaderIcon, PanelRight, TriangleAlert } from "lucide-react"; import { toast } from "sonner"; import { generatePodcast } from "@/lib/apis/podcast-apis"; import { cn } from "@/lib/utils"; -import { activeChatAtom, activeChatIdAtom } from "@/atoms/chats/queries/active-chat.atom"; -import { chatUIAtom } from "@/atoms/chats/active-chat-ui.atom"; +import { activeChatAtom, activeChatIdAtom } from "@/atoms/chats/queries/active-chat.query.atom"; +import { chatUIAtom } from "@/atoms/chats/active-chat.atom"; import { ChatPanelView } from "./ChatPanelView"; export interface GeneratePodcastRequest { diff --git a/surfsense_web/components/chat/ChatPanel/ChatPanelView.tsx b/surfsense_web/components/chat/ChatPanel/ChatPanelView.tsx index ca220856d..c1672a7ea 100644 --- a/surfsense_web/components/chat/ChatPanel/ChatPanelView.tsx +++ b/surfsense_web/components/chat/ChatPanel/ChatPanelView.tsx @@ -5,8 +5,8 @@ import { AlertCircle, Play, RefreshCw, Sparkles } from "lucide-react"; import { motion } from "motion/react"; import { useCallback } from "react"; import { cn } from "@/lib/utils"; -import { activeChatAtom } from "@/atoms/chats/queries/active-chat.atom"; -import { chatUIAtom } from "@/atoms/chats/active-chat-ui.atom"; +import { activeChatAtom } from "@/atoms/chats/queries/active-chat.query.atom"; +import { chatUIAtom } from "@/atoms/chats/active-chat.atom"; import { getPodcastStalenessMessage, isPodcastStale } from "../PodcastUtils"; import type { GeneratePodcastRequest } from "./ChatPanelContainer"; import { ConfigModal } from "./ConfigModal"; diff --git a/surfsense_web/components/chat/ChatPanel/ConfigModal.tsx b/surfsense_web/components/chat/ChatPanel/ConfigModal.tsx index 175520d39..25b6446c0 100644 --- a/surfsense_web/components/chat/ChatPanel/ConfigModal.tsx +++ b/surfsense_web/components/chat/ChatPanel/ConfigModal.tsx @@ -4,7 +4,7 @@ import { useAtomValue } from "jotai"; import { Pencil } from "lucide-react"; import { useCallback, useContext, useState } from "react"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; -import { activeChatAtom } from "@/atoms/chats/queries/active-chat.atom"; +import { activeChatAtom } from "@/atoms/chats/queries/active-chat.query.atom"; import type { GeneratePodcastRequest } from "./ChatPanelContainer"; interface ConfigModalProps { diff --git a/surfsense_web/lib/apis/chat-apis.ts b/surfsense_web/lib/apis/chat-apis.ts index ff3076744..5a4789be7 100644 --- a/surfsense_web/lib/apis/chat-apis.ts +++ b/surfsense_web/lib/apis/chat-apis.ts @@ -72,9 +72,7 @@ export const deleteChat = async (chatId: number, authToken: string) => { throw new Error(`Failed to delete chat: ${response.statusText}`); } - return true; } catch (err) { console.error("Error deleting chat:", err); - return false; } }; diff --git a/surfsense_web/lib/query-client/cache-keys.ts b/surfsense_web/lib/query-client/cache-keys.ts index 335125bb8..5b74092e1 100644 --- a/surfsense_web/lib/query-client/cache-keys.ts +++ b/surfsense_web/lib/query-client/cache-keys.ts @@ -2,6 +2,5 @@ export const cacheKeys = { activeSearchSpace: { chats : (searchSpaceId: string) => ["active-search-space", "chats", searchSpaceId] as const, activeChat : (chatId: string) => ["active-search-space", "active-chat", chatId] as const, - deleteChat : ( searchSpaceId: string, chatId: string) => ["active-search-space", "chats", searchSpaceId, "delete", chatId] as const, }, };