+ Select your LLM engine, choose the task mode, and send a message. Every conversation is automatically persisted. +
+{starter.desc}
+
+
+ {part.slice(1, -1)}
+
+ );
+ }
+ return part;
+ })}
+ >
+ );
+}
diff --git a/client/app/multiple-ai/components/Sidebar.tsx b/client/app/multiple-ai/components/Sidebar.tsx
new file mode 100644
index 0000000..afb2956
--- /dev/null
+++ b/client/app/multiple-ai/components/Sidebar.tsx
@@ -0,0 +1,179 @@
+"use client";
+
+import React, { useTransition } from "react";
+import { useRouter } from "next/navigation";
+import { MessageSquare, Plus, Trash2, Bot, Code2, Search, Sparkles } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { deleteChat, createChat } from "../actions";
+import { formatDate } from "@/lib/utils";
+import { cn } from "@/lib/utils";
+
+interface ChatItem {
+ id: string;
+ title: string;
+ mode: string;
+ createdAt: Date;
+}
+
+interface SidebarProps {
+ chats: ChatItem[];
+ activeChatId?: string;
+}
+
+export function Sidebar({ chats, activeChatId }: SidebarProps) {
+ const router = useRouter();
+ const [isPending, startTransition] = useTransition();
+
+ const handleNewChat = () => {
+ startTransition(async () => {
+ try {
+ const newChat = await createChat("chat");
+ router.push(`/multiple-ai/${newChat.id}`);
+ } catch (err) {
+ console.error("Failed to create new chat:", err);
+ }
+ });
+ };
+
+ const handleDeleteChat = (e: React.MouseEvent, id: string) => {
+ e.stopPropagation();
+ e.preventDefault();
+ if (confirm("Are you sure you want to delete this chat?")) {
+ startTransition(async () => {
+ try {
+ await deleteChat(id);
+ if (activeChatId === id) {
+ router.push("/multiple-ai");
+ }
+ } catch (err) {
+ console.error("Failed to delete chat:", err);
+ }
+ });
+ }
+ };
+
+ // Group chats by date
+ const getGroupedChats = () => {
+ const today: ChatItem[] = [];
+ const yesterday: ChatItem[] = [];
+ const thisWeek: ChatItem[] = [];
+ const older: ChatItem[] = [];
+
+ const now = new Date();
+ const oneDayMs = 24 * 60 * 60 * 1000;
+
+ chats.forEach((chat) => {
+ const date = new Date(chat.createdAt);
+ const diffMs = now.getTime() - date.getTime();
+ const diffDays = Math.floor(diffMs / oneDayMs);
+
+ if (diffDays === 0 && date.getDate() === now.getDate()) {
+ today.push(chat);
+ } else if (diffDays <= 1) {
+ yesterday.push(chat);
+ } else if (diffDays < 7) {
+ thisWeek.push(chat);
+ } else {
+ older.push(chat);
+ }
+ });
+
+ return { today, yesterday, thisWeek, older };
+ };
+
+ const grouped = getGroupedChats();
+
+ const renderModeIcon = (mode: string) => {
+ switch (mode) {
+ case "build":
+ return + Select your LLM engine, choose the task mode, and send a message. Every conversation is automatically persisted. +
+{starter.desc}
+