'use client'; import { useEffect, useState } from 'react'; import Link from "next/link"; import Image from "next/image"; import logo from '@/public/logo.png'; import logoOnly from '@/public/logo-only.png'; import { usePathname } from "next/navigation"; import { Tooltip, Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, useDisclosure } from "@heroui/react"; import { UserButton } from "@/app/lib/components/user_button"; import { SettingsIcon, WorkflowIcon, PlayIcon, ChevronLeftIcon, ChevronRightIcon, Moon, Sun, HelpCircle, MessageSquareIcon, LogsIcon, Clock, ZapIcon } from "lucide-react"; import { fetchProject } from "@/app/actions/project.actions"; import { createProjectWithOptions } from "../../lib/project-creation-utils"; import { useTheme } from "@/app/providers/theme-provider"; import { USE_PRODUCT_TOUR } from '@/app/lib/feature_flags'; import { SHOW_DARK_MODE_TOGGLE } from '@/app/lib/feature_flags'; import { useHelpModal } from "@/app/providers/help-modal-provider"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { TextareaWithSend } from "@/app/components/ui/textarea-with-send"; interface SidebarProps { projectId?: string; useAuth: boolean; collapsed?: boolean; onToggleCollapse?: () => void; useBilling?: boolean; } const EXPANDED_ICON_SIZE = 20; const COLLAPSED_ICON_SIZE = 20; // DO NOT CHANGE THIS export default function Sidebar({ projectId, useAuth, collapsed = false, onToggleCollapse, useBilling }: SidebarProps) { const pathname = usePathname(); const router = useRouter(); const [projectName, setProjectName] = useState("Select Project"); const [assistantName, setAssistantName] = useState(""); const [assistantPrompt, setAssistantPrompt] = useState(""); const [isCreatingAssistant, setIsCreatingAssistant] = useState(false); const isProjectsRoute = pathname === '/projects'; const { theme, toggleTheme } = useTheme(); const { showHelpModal } = useHelpModal(); const { isOpen: isCreateModalOpen, onOpen: onCreateModalOpen, onClose: onCreateModalClose } = useDisclosure(); useEffect(() => { async function fetchProjectName() { if (!isProjectsRoute && projectId) { try { const project = await fetchProject(projectId); setProjectName(project.name); } catch (error) { console.error('Failed to fetch project name:', error); setProjectName("Select Project"); } } } fetchProjectName(); }, [projectId, isProjectsRoute]); const handleCreateAssistant = async () => { if (!assistantPrompt.trim()) return; setIsCreatingAssistant(true); try { await createProjectWithOptions({ prompt: assistantPrompt, router, onSuccess: () => { onCreateModalClose(); }, onError: (error) => { console.error('Error creating assistant:', error); } }); } finally { setIsCreatingAssistant(false); } }; const handleCreateModalClose = () => { setAssistantName(""); setAssistantPrompt(""); onCreateModalClose(); }; const navItems = [ { href: 'workflow', label: 'Build', icon: WorkflowIcon, }, { href: 'manage-triggers', label: 'Triggers', icon: ZapIcon, }, { href: 'conversations', label: 'Conversations', icon: MessageSquareIcon, }, { href: 'jobs', label: 'Jobs', icon: LogsIcon, }, { href: 'config', label: 'Settings', icon: SettingsIcon, } ]; const projectsNavItems: Array<{ href: string; label: string; icon: any; requiresProject: boolean; }> = []; const handleStartTour = () => { localStorage.removeItem('user_product_tour_completed'); window.location.reload(); }; return ( <> {/* Create Assistant Modal */} Create New Assistant
{/* Assistant Name Input */}
setAssistantName(e.target.value)} className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" placeholder="Assistant 1" />
{/* Assistant Description/Prompt */}
In the next step, our AI copilot will create agents for you, complete with mock-tools.
); }