import { Link } from "@tanstack/react-router"; import { useEffect, useState } from "react"; import { AgentPromptBar } from "@/components/agents/AgentPromptBar"; import { AgentRunCard } from "@/components/agents/AgentRunCard"; import { Logo } from "@/components/agents/ported/Logo"; import { useAgentThreads, useCreateAgentThread } from "@/lib/agents/queries"; import { useModelOptions, type ModelSelection } from "@/lib/agents/useModelOptions"; export function AgentsHome() { const threadsQuery = useAgentThreads(); const createThread = useCreateAgentThread(); const recentRuns = (threadsQuery.data ?? []).slice(0, 5); const { models, defaultSelection } = useModelOptions(); const [selection, setSelection] = useState(null); useEffect(() => { if (selection === null && defaultSelection) setSelection(defaultSelection); }, [defaultSelection, selection]); return (
createThread.mutate({ prompt, model_id: selection?.modelId ?? null, effort: selection?.effort ?? null, }) } disabled={createThread.isPending} models={models} selection={selection ?? defaultSelection} onSelectionChange={setSelection} />
{threadsQuery.isLoading ? (

Loading agents…

) : recentRuns.length === 0 ? ( ) : ( recentRuns.map((thread) => ) )}
); } export function AgentsHomeEmptyState() { return (

No agents yet.

Start your first agent
); }