import React from "react"; import { AssistantShell } from "./PageArchetypes"; import { ButtonSoft, Card } from "./ui"; type AssistantWorkspaceProps = { title: string; description: string; setupTitle?: string; setupSummary: string; hasConversation: boolean; setupContent: React.ReactNode; toolsContent?: React.ReactNode; conversationContent: React.ReactNode; secondaryRail?: React.ReactNode; supplementalContent?: React.ReactNode; modalContent?: React.ReactNode; }; type AssistantSetupPanelProps = { title?: string; summary: string; hasConversation: boolean; children: React.ReactNode; }; export function AssistantSetupPanel(props: AssistantSetupPanelProps) { const { title = "Assistant setup", summary, hasConversation, children, } = props; const [setupOpen, setSetupOpen] = React.useState(!hasConversation); const conversationSeenRef = React.useRef(hasConversation); React.useEffect(() => { if (hasConversation && !conversationSeenRef.current) { setSetupOpen(false); } if (!hasConversation && conversationSeenRef.current) { setSetupOpen(true); } conversationSeenRef.current = hasConversation; }, [hasConversation]); return (
{title}
{setupOpen ?
{summary}
: null}
setSetupOpen((value) => !value)}>{setupOpen ? "Hide setup" : "Show setup"}
{setupOpen ?
{children}
: null}
); } export default function AssistantWorkspace(props: AssistantWorkspaceProps) { const { title, description, setupTitle = "Assistant setup", setupSummary, hasConversation, setupContent, toolsContent, conversationContent, secondaryRail, supplementalContent, modalContent, } = props; return (
{setupContent}
{toolsContent ?
{toolsContent}
: null}
{conversationContent} {secondaryRail ? secondaryRail : null}
{supplementalContent} {modalContent}
); }