import Dashboard from "@/components/Dashboard";
import type { Msg } from "@/components/useChat";
import { db } from "@/db";
import { bookmarks, chatMessages, notes, tasks } from "@/db/schema";
import { engineStatus, type AiCard } from "@/lib/ai";
import { ensureSeed } from "@/lib/seed";
import { asc, desc } from "drizzle-orm";
export const dynamic = "force-dynamic";
export default async function Home() {
await ensureSeed();
const [bm, nt, tk, chat] = await Promise.all([
db.select().from(bookmarks).orderBy(desc(bookmarks.pinned), desc(bookmarks.clicks), desc(bookmarks.id)),
db.select().from(notes).orderBy(desc(notes.updatedAt)),
db.select().from(tasks).orderBy(asc(tasks.done), asc(tasks.id)),
db.select().from(chatMessages).orderBy(asc(chatMessages.id)).limit(60),
]);
const engine = engineStatus();
const messages: Msg[] = chat.map((m) => ({
id: m.id,
role: m.role === "user" ? "user" : "assistant",
content: m.content,
cards: (m.meta?.cards as AiCard[] | undefined) ?? [],
engine: m.meta?.engine as string | undefined,
}));
return (
);
}