import React, { useState } from "react"; import type { SessionSummary } from "../../../src/shared/protocol.ts"; import { GraphPlaceholder } from "../components/GraphPlaceholder.tsx"; interface HomeProps { sessions: SessionSummary[]; onStart: (topic: string) => Promise; onOpen: (file: string) => void; onRefresh: () => void; error: string | null; } function formatDate(iso: string): string { if (!iso) return ""; try { return new Date(iso).toLocaleString(undefined, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", }); } catch { return iso; } } export function Home({ sessions, onStart, onOpen, onRefresh, error }: HomeProps) { const [topic, setTopic] = useState(""); const [busy, setBusy] = useState(false); const submit = async () => { const t = topic.trim(); if (!t || busy) return; setBusy(true); try { await onStart(t); } finally { setBusy(false); setTopic(""); } }; return (
setTopic(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") void submit(); }} />
{error &&
{error}
}
); }