import { sew } from "@/actions" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Skeleton } from "@/components/ui/skeleton" import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" import { env } from "@sourcebot/shared" import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants" import { ServiceErrorException } from "@/lib/serviceError" import { cn, getCodeHostInfoForRepo, isServiceError } from "@/lib/utils" import { withOptionalAuthV2 } from "@/withAuthV2" import { getConfigSettings, repoMetadataSchema } from "@sourcebot/shared" import { ExternalLink, Info } from "lucide-react" import Image from "next/image" import Link from "next/link" import { notFound } from "next/navigation" import { Suspense } from "react" import { BackButton } from "../../components/backButton" import { DisplayDate } from "../../components/DisplayDate" import { RepoBranchesTable } from "../components/repoBranchesTable" import { RepoJobsTable } from "../components/repoJobsTable" export default async function RepoDetailPage({ params }: { params: Promise<{ id: string }> }) { const { id } = await params const repo = await getRepoWithJobs(Number.parseInt(id)) if (isServiceError(repo)) { throw new ServiceErrorException(repo); } const codeHostInfo = getCodeHostInfoForRepo({ codeHostType: repo.external_codeHostType, name: repo.name, displayName: repo.displayName ?? undefined, webUrl: repo.webUrl ?? undefined, }); const configSettings = await getConfigSettings(env.CONFIG_PATH); const nextIndexAttempt = (() => { const latestJob = repo.jobs.length > 0 ? repo.jobs[0] : null; if (!latestJob) { return undefined; } if (latestJob.completedAt) { return new Date(latestJob.completedAt.getTime() + configSettings.reindexIntervalMs); } return undefined; })(); const repoMetadata = repoMetadataSchema.parse(repo.metadata); return ( <>

{repo.displayName || repo.name}

{repo.name}

{codeHostInfo.repoLink && ( )}
{repo.isArchived && Archived} {repo.isPublic && Public}
Created

When this repository was first added to Sourcebot

Last indexed

The last time this repository was successfully indexed

{repo.indexedAt ? : "Never"}
Scheduled

When the next indexing job is scheduled to run

{nextIndexAttempt ? : "-"}
{repoMetadata.indexedRevisions && (
Indexed Branches
Branches that have been indexed for this repository. Docs
}>
)} Indexing History History of all indexing and cleanup jobs for this repository. }> ) } const getRepoWithJobs = async (repoId: number) => sew(() => withOptionalAuthV2(async ({ prisma, org }) => { const repo = await prisma.repo.findUnique({ where: { id: repoId, orgId: org.id, }, include: { jobs: { orderBy: { createdAt: 'desc' }, } }, }); if (!repo) { return notFound(); } return repo; }) );