"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import type { ChatSummary } from "@/src/store/chats"; export function Home({ chats }: { chats: ChatSummary[] }) { const router = useRouter(); const [topic, setTopic] = useState(""); const [busy, setBusy] = useState(false); const start = async () => { const t = topic.trim(); if (!t || busy) return; setBusy(true); try { const res = await fetch("/api/chats", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ title: t }), }); const { id } = (await res.json()) as { id: string }; router.push(`/chat/${id}?prompt=${encodeURIComponent(t)}`); } catch { setBusy(false); } }; return (

Learning Harness

A teacher with a memory. Start a session on anything you want to understand.

{ e.preventDefault(); void start(); }} > setTopic(e.target.value)} placeholder="What do you want to learn?" autoFocus />

Sessions

{chats.length === 0 ? (

No sessions yet.

) : (
{chats.map((c) => ( ))}
)}
); }