import { createChat, isTurnRunning, listChats, titleFromPrompt } from "@/src/server"; import type { ChatListItem } from "@/src/core"; /** The session picker's list: record-derived summaries (phase, pending * question) + live liveness — a running turn marks the session busy * (contracts.ts ChatListItem; the store can't see liveness, the route is * the merge point). Owner, minimal-color round: background jobs NO LONGER * count — the sidebar's Background agents section is their channel now * (a running spinner per row would double-signal them), so busy means * exactly "a teach turn is in flight". */ export async function GET() { const chats: ChatListItem[] = listChats().map((c) => ({ ...c, busy: isTurnRunning(c.id), })); return Response.json({ chats }); } export async function POST(req: Request) { const body = (await req.json().catch(() => ({}))) as { title?: unknown }; const title = typeof body.title === "string" ? body.title : ""; const chat = createChat(titleFromPrompt(title || "Untitled session")); return Response.json({ id: chat.id, title: chat.title }); }