diff --git a/web/src/app/(applayout)/playground/page.tsx b/web/src/app/(applayout)/playground/page.tsx index 399886c..cdfe420 100644 --- a/web/src/app/(applayout)/playground/page.tsx +++ b/web/src/app/(applayout)/playground/page.tsx @@ -101,7 +101,7 @@ const ChatPlayground = () => { transition="width 0.1s, visibility 0.1s" > - + diff --git a/web/src/components/Playground/ChatHistoryList.tsx b/web/src/components/Playground/ChatHistoryList.tsx index 4066972..c2789d4 100644 --- a/web/src/components/Playground/ChatHistoryList.tsx +++ b/web/src/components/Playground/ChatHistoryList.tsx @@ -1,21 +1,8 @@ import { Flex, Spinner, - Container, useColorModeValue, IconButton, - Menu, - MenuButton, - MenuList, - MenuItem, - Modal, - ModalOverlay, - ModalContent, - ModalHeader, - ModalFooter, - ModalBody, - ModalCloseButton, - useDisclosure, Icon, Box, Text, @@ -27,20 +14,15 @@ import useCustomToast from "../../hooks/useCustomToast"; import { useRouter } from "next/navigation"; import { useTranslation } from "react-i18next"; import React, { useEffect, useState } from "react"; -import { - EllipsisVerticalIcon, - StarIcon, - Trash, - Trash2Icon, -} from "lucide-react"; +import { StarIcon, Trash2Icon } from "lucide-react"; import useChatMessageStore from "@/store/chatMessageStore"; -import { FaTrashCan } from "react-icons/fa6"; interface ChatHistoryProps { teamId: string; + isPlayground?: boolean; } -const ChatHistoryList = ({ teamId }: ChatHistoryProps) => { +const ChatHistoryList = ({ teamId, isPlayground }: ChatHistoryProps) => { const queryClient = useQueryClient(); const navigate = useRouter(); @@ -86,31 +68,49 @@ const ChatHistoryList = ({ teamId }: ChatHistoryProps) => { const deleteThreadMutation = useMutation(deleteThread, { onError: (err: ApiError) => { const errDetail = err.body?.detail; - showToast("Unable to delete thread.", `${errDetail}`, "error"); + // showToast("Unable to delete thread.", `${errDetail}`, "error"); + console.log("error", errDetail); }, onSettled: () => { queryClient.invalidateQueries(["threads", teamId]); - // queryClient.invalidateQueries(["threads", threadId]); + queryClient.invalidateQueries(["threads", selectedThreadId]); }, }); const [selectedThreadId, setSelectedThreadId] = useState(null); const onClickRowHandler = (threadId: string) => { - navigate.push(`/playground?teamId=${teamId}&threadId=${threadId}`); setSelectedThreadId(threadId); + if (isPlayground) { + navigate.push(`/playground?teamId=${teamId}&threadId=${threadId}`); + } else { + navigate.push(`/teams/${teamId}?threadId=${threadId}`); + } }; const { setMessages } = useChatMessageStore(); + const [shouldNavigate, setShouldNavigate] = useState(false); + const handleDeleteThread = () => { if (selectedThreadId) { deleteThreadMutation.mutate(selectedThreadId); - setMessages([]); - navigate.push(`/playground?teamId=${teamId}`); + setShouldNavigate(true); } }; - if (isError) { - const errDetail = (error as ApiError).body?.detail; + useEffect(() => { + if (shouldNavigate) { + if (isPlayground) { + navigate.push(`/playground?teamId=${teamId}`); + } else { + navigate.push(`/steamsS/${teamId}`); + } + setShouldNavigate(false); + } + }, [shouldNavigate, isPlayground, teamId, navigate]); + + if (isError || membersIsError) { + const errors = error || membersError; + const errDetail = (errors as ApiError).body?.detail; showToast("Something went wrong.", `${errDetail}`, "error"); } @@ -118,7 +118,7 @@ const ChatHistoryList = ({ teamId }: ChatHistoryProps) => { const { t } = useTranslation(); return ( <> - {isLoading ? ( + {isLoading && membersLoading ? ( @@ -175,7 +175,7 @@ const ChatHistoryList = ({ teamId }: ChatHistoryProps) => { {thread.query} - + { - {/* */} )} diff --git a/web/src/components/Teams/DebugPreview/head.tsx b/web/src/components/Teams/DebugPreview/head.tsx index 3976371..3e2ddef 100644 --- a/web/src/components/Teams/DebugPreview/head.tsx +++ b/web/src/components/Teams/DebugPreview/head.tsx @@ -66,7 +66,7 @@ function DebugPreviewHead({ - +