import { Link } from "@tanstack/react-router" import { useState } from "react" import type { ModelSelection } from "@/lib/agents/useModelOptions" import { AgentPromptBar } from "@/components/agents/AgentPromptBar" import { AgentRunCard } from "@/components/agents/AgentRunCard" import { SlackConnectDialog } from "@/components/agents/SlackConnectDialog" import { Logo } from "@/components/agents/ported/Logo" import { useAgentThreads, useCreateAgentThread } from "@/lib/agents/queries" import { useModelOptions } from "@/lib/agents/useModelOptions" import { useProfile, useRepos } from "@/lib/profile" 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) const activeSelection = selection ?? defaultSelection const reposQuery = useRepos() const profileQuery = useProfile() // undefined = untouched (fall back to the profile default); null = explicitly "no repo". const [repoOverride, setRepoOverride] = useState( undefined ) const repo = repoOverride === undefined ? (profileQuery.data?.default_repo ?? null) : repoOverride return (
createThread.mutate({ prompt, repo, model_id: activeSelection?.modelId ?? null, effort: activeSelection?.effort ?? null, }) } disabled={createThread.isPending} models={models} selection={activeSelection} onSelectionChange={setSelection} repos={reposQuery.data?.repositories} selectedRepo={repo} onRepoChange={setRepoOverride} />
{threadsQuery.isLoading ? (

Loading agents…

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

No agents yet.

Start your first agent
) }