diff --git a/surfsense_web/components/chat/ChatInterface.tsx b/surfsense_web/components/chat/ChatInterface.tsx index 4aaeb2847..f94c2b3ee 100644 --- a/surfsense_web/components/chat/ChatInterface.tsx +++ b/surfsense_web/components/chat/ChatInterface.tsx @@ -2,7 +2,7 @@ import { type ChatHandler, ChatSection as LlamaIndexChatSection } from "@llamaindex/chat-ui"; import { PanelRight } from "lucide-react"; -import { useState } from "react"; +import { createContext, useState } from "react"; import type { ResearchMode } from "@/components/chat"; import { ChatInputUI } from "@/components/chat/ChatInputGroup"; import { ChatMessagesUI } from "@/components/chat/ChatMessages"; @@ -20,6 +20,13 @@ interface ChatInterfaceProps { onSearchModeChange?: (mode: "DOCUMENTS" | "CHUNKS") => void; } +interface ChatInterfaceContext { + isChatPannelOpen: boolean; + setIsChatPannelOpen: (value: boolean) => void; +} + +export const chatInterfaceContext = createContext(null); + export default function ChatInterface({ handler, onDocumentSelectionChange, @@ -30,49 +37,56 @@ export default function ChatInterface({ onSearchModeChange, }: ChatInterfaceProps) { const [isChatPannelOpen, setIsChatPannelOpen] = useState(false); + const contextValue = { + isChatPannelOpen, + setIsChatPannelOpen, + }; return ( - -
-
- -
- + + +
+
+ +
+ +
-
-
- -
+ +
-
- +
+ +
-
- + + ); } diff --git a/surfsense_web/components/chat/ChatPannel/ChatPanelView.tsx b/surfsense_web/components/chat/ChatPannel/ChatPanelView.tsx index 5f4eb0405..995c4d3a7 100644 --- a/surfsense_web/components/chat/ChatPannel/ChatPanelView.tsx +++ b/surfsense_web/components/chat/ChatPannel/ChatPanelView.tsx @@ -1,21 +1,49 @@ +"use client"; + import { Pencil, Podcast } from "lucide-react"; +import { useContext } from "react"; +import { cn } from "@/lib/utils"; +import { chatInterfaceContext } from "../ChatInterface"; export default function ChatPanelView() { + const context = useContext(chatInterfaceContext); + if (!context) { + throw new Error("chatInterfaceContext must be used within a ChatProvider"); + } + + const { isChatPannelOpen, setIsChatPannelOpen } = context; + return (
-
-
-
- - +
+ {isChatPannelOpen ? ( +
+
+ + +
+

Generate Podcast

-

Generate Podcast

-
+ ) : ( + + )}
);