1- import { Suspense } from "react"
2- import { notFound } from "next/navigation"
3- import Link from "next/link"
4- import { ChevronLeft , ExternalLink } from "lucide-react"
5- import { Button } from "@/components/ui/button"
1+ import { sew } from "@/actions"
62import { Badge } from "@/components/ui/badge"
3+ import { Button } from "@/components/ui/button"
74import { Card , CardContent , CardDescription , CardHeader , CardTitle } from "@/components/ui/card"
85import { Skeleton } from "@/components/ui/skeleton"
9- import { RepoJobsTable } from ".. /components/repoJobsTable "
6+ import { Tooltip , TooltipContent , TooltipTrigger } from "@ /components/ui/tooltip "
107import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants"
11- import { sew } from "@/actions"
12- import { withOptionalAuthV2 } from "@/withAuthV2"
138import { ServiceErrorException } from "@/lib/serviceError"
149import { cn , getCodeHostInfoForRepo , isServiceError } from "@/lib/utils"
10+ import { withOptionalAuthV2 } from "@/withAuthV2"
11+ import { ChevronLeft , ExternalLink , Info } from "lucide-react"
1512import Image from "next/image"
13+ import Link from "next/link"
14+ import { notFound } from "next/navigation"
15+ import { Suspense } from "react"
16+ import { RepoJobsTable } from "../components/repoJobsTable"
17+ import { getConfigSettings } from "@sourcebot/shared"
18+ import { env } from "@/env.mjs"
1619
1720function formatDate ( date : Date | null ) {
1821 if ( ! date ) return "Never"
@@ -39,6 +42,21 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
3942 webUrl : repo . webUrl ?? undefined ,
4043 } ) ;
4144
45+ const configSettings = await getConfigSettings ( env . CONFIG_PATH ) ;
46+
47+ const nextIndexAttempt = ( ( ) => {
48+ const latestJob = repo . jobs . length > 0 ? repo . jobs [ 0 ] : null ;
49+ if ( ! latestJob ) {
50+ return undefined ;
51+ }
52+
53+ if ( latestJob . completedAt ) {
54+ return new Date ( latestJob . completedAt . getTime ( ) + configSettings . reindexIntervalMs ) ;
55+ }
56+
57+ return undefined ;
58+ } ) ( ) ;
59+
4260 return (
4361 < div className = "container mx-auto" >
4462 < div className = "mb-6" >
@@ -78,28 +96,58 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
7896 < div className = "grid gap-4 md:grid-cols-3 mb-8" >
7997 < Card >
8098 < CardHeader className = "pb-3" >
81- < CardTitle className = "text-sm font-medium" > Last Indexed</ CardTitle >
99+ < CardTitle className = "text-sm font-medium flex items-center gap-1.5" >
100+ Created
101+ < Tooltip >
102+ < TooltipTrigger asChild >
103+ < Info className = "h-3.5 w-3.5 text-muted-foreground cursor-help" />
104+ </ TooltipTrigger >
105+ < TooltipContent >
106+ < p > When this repository was first added to Sourcebot</ p >
107+ </ TooltipContent >
108+ </ Tooltip >
109+ </ CardTitle >
82110 </ CardHeader >
83111 < CardContent >
84- < div className = "text-2xl font-semibold" > { repo . indexedAt ? formatDate ( repo . indexedAt ) : "Never" } </ div >
112+ < div className = "text-2xl font-semibold" > { formatDate ( repo . createdAt ) } </ div >
85113 </ CardContent >
86114 </ Card >
87115
88116 < Card >
89117 < CardHeader className = "pb-3" >
90- < CardTitle className = "text-sm font-medium" > Created</ CardTitle >
118+ < CardTitle className = "text-sm font-medium flex items-center gap-1.5" >
119+ Last indexed
120+ < Tooltip >
121+ < TooltipTrigger asChild >
122+ < Info className = "h-3.5 w-3.5 text-muted-foreground cursor-help" />
123+ </ TooltipTrigger >
124+ < TooltipContent >
125+ < p > The last time this repository was successfully indexed</ p >
126+ </ TooltipContent >
127+ </ Tooltip >
128+ </ CardTitle >
91129 </ CardHeader >
92130 < CardContent >
93- < div className = "text-2xl font-semibold" > { formatDate ( repo . createdAt ) } </ div >
131+ < div className = "text-2xl font-semibold" > { repo . indexedAt ? formatDate ( repo . indexedAt ) : "Never" } </ div >
94132 </ CardContent >
95133 </ Card >
96134
97135 < Card >
98136 < CardHeader className = "pb-3" >
99- < CardTitle className = "text-sm font-medium" > Last Updated</ CardTitle >
137+ < CardTitle className = "text-sm font-medium flex items-center gap-1.5" >
138+ Scheduled
139+ < Tooltip >
140+ < TooltipTrigger asChild >
141+ < Info className = "h-3.5 w-3.5 text-muted-foreground cursor-help" />
142+ </ TooltipTrigger >
143+ < TooltipContent >
144+ < p > When the next indexing job is scheduled to run</ p >
145+ </ TooltipContent >
146+ </ Tooltip >
147+ </ CardTitle >
100148 </ CardHeader >
101149 < CardContent >
102- < div className = "text-2xl font-semibold" > { formatDate ( repo . updatedAt ) } </ div >
150+ < div className = "text-2xl font-semibold" > { nextIndexAttempt ? formatDate ( nextIndexAttempt ) : "-" } </ div >
103151 </ CardContent >
104152 </ Card >
105153 </ div >
@@ -127,8 +175,12 @@ const getRepoWithJobs = async (repoId: number) => sew(() =>
127175 id : repoId ,
128176 } ,
129177 include : {
130- jobs : true ,
131- }
178+ jobs : {
179+ orderBy : {
180+ createdAt : 'desc'
181+ } ,
182+ }
183+ } ,
132184 } ) ;
133185
134186 if ( ! repo ) {
0 commit comments