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 cb58acf27..4a9b0777d 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 @@ -56,14 +56,24 @@ import { } from "@/components/ui/select"; import { cn } from "@/lib/utils"; -interface Chat { +export interface Chat { created_at: string; id: number; - type: string; + type: "DOCUMENT" | "CHAT"; title: string; search_space_id: number; } +export interface ChatDetails { + type: "DOCUMENT" | "CHAT"; + title: string; + initial_connectors: string[]; + messages: any[]; + created_at: string; + id: number; + search_space_id: number; +} + interface ChatsPageClientProps { searchSpaceId: string; } diff --git a/surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx b/surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx index 3fa6db3ff..b8d867218 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx @@ -47,7 +47,7 @@ import { } from "@/components/ui/select"; import { Slider } from "@/components/ui/slider"; -interface PodcastItem { +export interface PodcastItem { id: number; title: string; created_at: string; diff --git a/surfsense_web/components/chat/ChatInterface.tsx b/surfsense_web/components/chat/ChatInterface.tsx index b5bbd49d7..0c2d7c5a7 100644 --- a/surfsense_web/components/chat/ChatInterface.tsx +++ b/surfsense_web/components/chat/ChatInterface.tsx @@ -1,17 +1,16 @@ "use client"; import { type ChatHandler, ChatSection as LlamaIndexChatSection } from "@llamaindex/chat-ui"; -import { PanelRight } from "lucide-react"; import { useParams } from "next/navigation"; import { createContext, useCallback, useEffect, useState } from "react"; -import { Chat, type ChatDetails } from "@/app/dashboard/[search_space_id]/chats/chats-client"; +import type { ChatDetails } from "@/app/dashboard/[search_space_id]/chats/chats-client"; import type { PodcastItem } from "@/app/dashboard/[search_space_id]/podcasts/podcasts-client"; import type { ResearchMode } from "@/components/chat"; import { ChatInputUI } from "@/components/chat/ChatInputGroup"; import { ChatMessagesUI } from "@/components/chat/ChatMessages"; import { useChatAPI } from "@/hooks/use-chat"; import type { Document } from "@/hooks/use-documents"; -import { ChatPanelContainer } from "./ChatPannel/ChatPanelContainer"; +import { ChatPanelContainer } from "./ChatPanel/ChatPanelContainer"; interface ChatInterfaceProps { handler: ChatHandler; diff --git a/surfsense_web/components/chat/ChatPanel/ChatPanelContainer.tsx b/surfsense_web/components/chat/ChatPanel/ChatPanelContainer.tsx index 75481dc3a..2f460ee31 100644 --- a/surfsense_web/components/chat/ChatPanel/ChatPanelContainer.tsx +++ b/surfsense_web/components/chat/ChatPanel/ChatPanelContainer.tsx @@ -3,9 +3,15 @@ import { useActionState, useContext, useTransition } from "react"; import { toast } from "sonner"; import { cn } from "@/lib/utils"; import { chatInterfaceContext } from "../ChatInterface"; -import type { GeneratePodcastRequest } from "./actions"; import { ChatPanelView } from "./ChatPanelView"; +export interface GeneratePodcastRequest { + type: "CHAT" | "DOCUMENT"; + ids: number[]; + search_space_id: number; + podcast_title?: string; +} + export function ChatPanelContainer() { const context = useContext(chatInterfaceContext); diff --git a/surfsense_web/components/chat/ChatPannel/ChatPanelContainer.tsx b/surfsense_web/components/chat/ChatPannel/ChatPanelContainer.tsx deleted file mode 100644 index aebdca29e..000000000 --- a/surfsense_web/components/chat/ChatPannel/ChatPanelContainer.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { PanelRight } from "lucide-react"; -import { useActionState, useContext } from "react"; -import { cn } from "@/lib/utils"; -import { chatInterfaceContext } from "../ChatInterface"; -import { generatePodCastAction, getChatPodcastPromise } from "./actions"; -import { ChatPanelView } from "./ChatPanelView"; - -export interface PodCastInterface { - title: string; - podcast_transcript: string; - search_space_id: string; -} - -export type PodcastGenerationState = Partial<{ - title: string; - podcast_transcript: string; - search_space_id: string; - chat_id: string; - prompt: string; - error: unknown; -}>; - -export function ChatPanelContainer() { - const context = useContext(chatInterfaceContext); - - if (!context) { - throw new Error("chatInterfaceContext must be used within a ChatProvider"); - } - - const { isChatPannelOpen, setIsChatPannelOpen, chat_id: chatId } = context; - - const [state, generatePodcastAction, isGeneratingPodcast] = - useActionState(generatePodCastAction, { - chat_id: chatId, - prompt: "Test", - }); - - return chatId && chatId !== "" ? ( -
-
- -
- -
- -
-
- ) : null; -} diff --git a/surfsense_web/components/chat/ChatPannel/ChatPanelView.tsx b/surfsense_web/components/chat/ChatPannel/ChatPanelView.tsx deleted file mode 100644 index 575d2bf65..000000000 --- a/surfsense_web/components/chat/ChatPannel/ChatPanelView.tsx +++ /dev/null @@ -1,49 +0,0 @@ -"use client"; - -import { Pencil, Podcast } from "lucide-react"; -import { useContext } from "react"; -import { cn } from "@/lib/utils"; -import { chatInterfaceContext } from "../ChatInterface"; -import { ConfigModal } from "./ConfigModal"; - -interface ChatPanelViewProps { - chat_id: string; -} - -export function ChatPanelView({ chat_id: chatId }: ChatPanelViewProps) { - const context = useContext(chatInterfaceContext); - if (!context) { - throw new Error("chatInterfaceContext must be used within a ChatProvider"); - } - - const { isChatPannelOpen, setIsChatPannelOpen } = context; - - return ( -
-
- {isChatPannelOpen ? ( -
-
- - -
-

Generate Podcast

-
- ) : ( - - )} -
-
- ); -} diff --git a/surfsense_web/components/chat/ChatPannel/ConfigModal.tsx b/surfsense_web/components/chat/ChatPannel/ConfigModal.tsx deleted file mode 100644 index 4c005e52e..000000000 --- a/surfsense_web/components/chat/ChatPannel/ConfigModal.tsx +++ /dev/null @@ -1,40 +0,0 @@ -"use client"; - -import { Pencil } from "lucide-react"; -import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; - -export function ConfigModal() { - return ( - - - - - -
- - - - - -
-
-
- ); -} diff --git a/surfsense_web/components/chat/ChatPannel/actions.ts b/surfsense_web/components/chat/ChatPannel/actions.ts deleted file mode 100644 index 71bd23a95..000000000 --- a/surfsense_web/components/chat/ChatPannel/actions.ts +++ /dev/null @@ -1,21 +0,0 @@ -"use server"; - -import type { PodCastInterface, PodcastGenerationState } from "./ChatPanelContainer"; - -export const generatePodCastAction = async ( - formData: PodcastGenerationState -): Promise => { - return Promise.resolve({ - title: "Test", - podcast_transcript: "Test", - search_space_id: "Test", - }); -}; - -export const getChatPodcastPromise = async (chatId: string): Promise => { - return Promise.resolve({ - title: "Test", - podcast_transcript: "Test", - search_space_id: "Test", - }); -}; diff --git a/surfsense_web/hooks/use-chat.ts b/surfsense_web/hooks/use-chat.ts index fdd447a10..4e094cb31 100644 --- a/surfsense_web/hooks/use-chat.ts +++ b/surfsense_web/hooks/use-chat.ts @@ -1,6 +1,6 @@ import type { Message } from "@ai-sdk/react"; import { useCallback, useEffect, useState } from "react"; -import { type ChatDetails } from "@/app/dashboard/[search_space_id]/chats/chats-client"; +import type { ChatDetails } from "@/app/dashboard/[search_space_id]/chats/chats-client"; import type { ResearchMode } from "@/components/chat"; import type { Document } from "@/hooks/use-documents";