import { AgentAvatar, Ago, Badge, cn, Empty, LayerCard, LineBadge, LinkButton } from "@refs/design-system"; import { ChatCircleIcon, CheckSquareIcon, GitBranchIcon, GitPullRequestIcon, KeyIcon, RobotIcon } from "@refs/design-system/icons"; import { Link } from "react-router"; import type { Route } from "./+types/dashboard"; import { AppShell, PageHeader } from "../components/shell"; import { pullLink, taskLink, type OnlineAgent, type PullSummary, type RepoSummary, type TaskSummary } from "@refs/backend/contract"; import { data } from "react-router"; import { formText, found, refs as handle, signedIn, nowSeconds } from "../lib/session"; import { decidePermission } from "../lib/permissions"; import { Opener, openerOf } from "../components/timeline"; import { PermissionRequests } from "../components/permission-requests"; import { Landing } from "../components/landing"; export const meta: Route.MetaFunction = ({ loaderData }) => loaderData && "landing" in loaderData ? [{ title: "refs: the Git host for coding agents" }, { name: "description", content: "Stop reading diffs. Start reading decisions. refs shows you the few choices your agents made that matter, so you can steer, branch or merge in minutes." }] : [{ title: "Overview ยท refs" }]; export async function loader({ params, context }: Route.LoaderArgs) { if (!params.ns && !handle(context).viewer.person) return { landing: true as const }; const refs = signedIn(context); if (!refs.viewer.namespace) throw data(null, { status: 404 }); const useTasks = refs.viewer.can.useTasks; const [repos, assigned] = await Promise.all([refs.repos(), useTasks ? refs.tasks({ status: "open", assignee: "me", page: { limit: 8 } }) : null]); // ponytail: three queries per repository; add a namespace-wide query when namespaces hold many repositories const activity = await Promise.all( repos.map(async (summary) => { const repo = await refs.repo(summary.name); const [permissions, agents, pulls] = await Promise.all([repo.permissions(), repo.agents(), useTasks ? repo.pulls({ status: "open" }) : null]); return { repo: summary.name, permissions, agents, pulls: pulls?.items ?? [] }; }), ); return { repos, tasks: assigned?.page.items ?? [], waiting: activity.flatMap(({ repo, permissions }) => permissions.filter((request) => request.canDecide).map((request) => ({ ...request, repo }))), agents: activity.flatMap(({ repo, agents }) => agents.map((agent) => ({ ...agent, repo }))), pulls: activity.flatMap(({ pulls }) => pulls).sort((a, b) => b.createdAt - a.createdAt).slice(0, 10), now: nowSeconds(), }; } export async function action({ request, context }: Route.ActionArgs) { const form = await request.formData(); const repo = await found(signedIn(context).repo(formText(form, "repo"))); const outcome = await decidePermission(repo, form); return outcome.ok ? { error: null } : { error: outcome.problem.message }; } const ROW = "flex items-start gap-3 px-4 py-2.5 shadow-[inset_0_-1px_0_var(--hairline)] last:shadow-none"; function Section({ icon, title, count, children }: { icon: React.ReactNode; title: string; count?: number; children: React.ReactNode }) { return ( {icon} {title} {count !== undefined && {count}} {children} ); } function Quiet({ children }: { children: React.ReactNode }) { return

{children}

; } function OpenPulls({ pulls, now }: { pulls: PullSummary[]; now: number }) { return (
} title="Open pull requests" count={pulls.length}> {pulls.length === 0 ? ( No open pull requests. When an agent opens one, it shows here for review. ) : ( )}
); } function Agents({ agents }: { agents: (OnlineAgent & { repo: string })[] }) { return (
} title="Agents online" count={agents.length}> {agents.length === 0 ? ( No agents are connected. They appear here when a Claude Code, OpenCode or Codex session connects to one of these repositories. ) : ( )}
); } function RepositoryList({ repos, now }: { repos: RepoSummary[]; now: number }) { if (repos.length === 0) { return ( } title="No repositories yet" description="Create a repository, then push to it with any Git client." contents={ New repository } /> ); } return (
} title="Repositories" count={repos.length}>
); } function AssignedTasks({ tasks }: { tasks: TaskSummary[] }) { return (
} title="Assigned to you" count={tasks.length}> {tasks.length === 0 ? ( No open tasks are assigned to you. ) : ( )}
); } function GitAccess() { return (
} title="Clone and push">

Git asks for a password the first time you clone or push. Use an access token, with any username.

Manage access tokens
); } export default function Dashboard({ loaderData }: Route.ComponentProps) { if ("landing" in loaderData) return ; const { repos, tasks, waiting, agents, pulls, now } = loaderData; return (
{waiting.length > 0 && (

Waiting for you

)} {repos.length > 0 && }
); }