"use client"; import React, { useState, Suspense } from 'react'; import { Skeleton } from "@/components/ui/skeleton"; import { useRouter } from 'next/navigation'; import { ChatInput } from '@/components/chat/chat-input'; import { createProject, addUserMessage, startAgent, createThread } from "@/lib/api"; function DashboardContent() { const [inputValue, setInputValue] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); const router = useRouter(); const handleSubmit = async (message: string) => { if (!message.trim() || isSubmitting) return; setIsSubmitting(true); try { // 1. Create a new project with the message as the name const newAgent = await createProject({ name: message.trim().length > 50 ? message.trim().substring(0, 47) + "..." : message.trim(), description: "", }); // 2. Create a new thread for this project const thread = await createThread(newAgent.id); // 3. Add the user message to the thread await addUserMessage(thread.thread_id, message.trim()); // 4. Start the agent with the thread ID const agentRun = await startAgent(thread.thread_id); // 5. Navigate to the new agent's thread page router.push(`/dashboard/agents/${thread.thread_id}`); } catch (error) { console.error("Error creating agent:", error); setIsSubmitting(false); } }; return (

Hello.

What can I help with?

); } export default function DashboardPage() { return (
}>
); }