"use client"; import { useEffect, useState } from "react"; import { Badge } from "@/components/ui/badge"; import { ScrollArea } from "@/components/ui/scroll-area"; import { CopilotChat, useCopilotChatSuggestions } from "@copilotkit/react-ui"; import "@copilotkit/react-ui/styles.css"; import { TextMessage, Role } from "@copilotkit/runtime-client-gql"; import { Search, Sparkles, FileText, Twitter, TrendingUp, Send, User, ExternalLink, Globe, Brain, Zap, Star, ChevronDown, Check, } from "lucide-react"; import { useCoAgent, useCoAgentStateRender, useCopilotAction, useCopilotChat, } from "@copilotkit/react-core"; import { ToolLogs } from "@/components/ui/tool-logs"; import { XPost, XPostPreview, XPostCompact } from "@/components/ui/x-post"; import { LinkedInPost, LinkedInPostPreview, LinkedInPostCompact, } from "@/components/ui/linkedin-post"; import { Button } from "@/components/ui/button"; import { initialPrompt1, suggestionPrompt1 } from "../prompts/prompts"; import { Textarea } from "@/components/ui/textarea"; import { cn } from "@/lib/utils"; import { useParams, useRouter, usePathname, useSearchParams, } from "next/navigation"; import { StackAnalysisCards } from "@/components/ui/stack-analysis-cards"; import { useLayout } from "../contexts/LayoutContext"; const agents = [ { id: "post_generation_agent", name: "Post Generator", description: "Generate posts for Linkedin and X with Gemini and Google web search", icon: Search, gradient: "from-blue-500 to-purple-600", active: true, }, { id: "stack_analysis_agent", name: "Stack Analyst", description: "Analyze the stack of a Project and generate insights from it", icon: FileText, gradient: "from-green-500 to-teal-600", active: false, }, ]; const quickActions = [ { label: "Staple", icon: FileText, color: "text-blue-600", prompt: "Analyze https://github.com/bertinetto/staple Github Repository", }, { label: "Vim-airline", icon: FileText, color: "text-green-600", prompt: "Analyze https://github.com/vim-airline/vim-airline Github Repository", }, { label: "Llama Index x AG-UI", icon: FileText, color: "text-purple-600", prompt: "Analyze https://github.com/copilotkit-support/open-ag-ui-demo-llamaindex Github Repository", }, { label: "Mastra x AG-UI", icon: FileText, color: "text-orange-600", prompt: "Analyze https://github.com/copilotkit-support/open-ag-ui-demo-mastra Github Repository", }, ]; interface PostInterface { tweet: { title: string; content: string; }; linkedIn: { title: string; content: string; }; } export default function StackAnalyzer() { const router = useRouter(); const [selectedAgent, setSelectedAgent] = useState(agents[1]); const [isAgentActive, setIsAgentActive] = useState(false); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const { updateLayout } = useLayout(); const { setState, running, state } = useCoAgent({ name: "stack_analysis_agent", initialState: { tool_logs: [], show_cards: false, analysis: "", }, }); const { appendMessage, setMessages } = useCopilotChat(); // useEffect(() => { // console.log(state.show_cards, "running") // }, [state, visibleMessages]) // Handle clicking outside dropdown to close it useEffect(() => { const handleClickOutside = (event: MouseEvent) => { const target = event.target as Element; if (!target.closest(".dropdown-container")) { setIsDropdownOpen(false); } }; if (isDropdownOpen) { document.addEventListener("mousedown", handleClickOutside); } return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, [isDropdownOpen]); useCoAgentStateRender({ name: "stack_analysis_agent", render: (state) => { return ; }, }); useCopilotChatSuggestions({ available: "enabled", instructions: suggestionPrompt1, }); return (
{/* Sidebar */}
{/* Header */}

Open Gemini Canvas

Advanced AI Canvas

{/* Enhanced Agent Selector */}
{/* Dropdown Menu */}
{agents.map((agent) => ( ))}
{/* Chat Input at Bottom */} { useEffect(() => { if (inProgress) { setIsAgentActive(true); } else { setIsAgentActive(false); } }, [inProgress]); const [input, setInput] = useState(""); return ( <>