"use client"; import { useState, useRef, useEffect } from "react"; import { useParams } from "next/navigation"; import { Loader2, Send, Sparkles, Bot, User } from "lucide-react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; type Message = { id: string; role: "user" | "assistant"; content: string; }; export default function AIPage() { const params = useParams(); const workspaceSlug = params.workspaceSlug as string; const [messages, setMessages] = useState([]); const [input, setInput] = useState(""); const [isLoading, setIsLoading] = useState(false); const scrollRef = useRef(null); const inputRef = useRef(null); // Auto-scroll on new messages useEffect(() => { if (scrollRef.current) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight; } }, [messages]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); const trimmed = input.trim(); if (!trimmed || isLoading) return; const userMsg: Message = { id: crypto.randomUUID(), role: "user", content: trimmed }; setMessages((prev) => [...prev, userMsg]); setInput(""); setIsLoading(true); // Placeholder AI response setTimeout(() => { const assistantMsg: Message = { id: crypto.randomUUID(), role: "assistant", content: "I'm your AI assistant. Full AI integration is coming soon! I'll be able to help you create tasks, documents, and manage your workspace.", }; setMessages((prev) => [...prev, assistantMsg]); setIsLoading(false); }, 1000); }; return (
{/* Header */}

AI Assistant

Ask me anything about your workspace

{/* Messages */}
{messages.length === 0 ? (

How can I help you today?

Ask me to create tasks, summarize documents, or manage your workspace.

{["Create a new project", "Summarize my tasks", "Help me plan a sprint"].map( (suggestion) => ( ), )}
) : (
{messages.map((msg) => (
{msg.role === "user" ? : }
{msg.content}
))} {isLoading && (
)}
)}
{/* Input */}