mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Add run history tab to GlobalSchedules page
Extract RunDetailPanel, create RunHistoryCards component, add runs tab with filtering
This commit is contained in:
1 parent
20838f0b88
commit
cc1256d6ec
7 files changed
+887
-511
No files matched your search
@@ -13,6 +13,21 @@ export interface ScheduleJobWithRepo extends ScheduleJob {
|
||||
repoUrl: string
|
||||
}
|
||||
|
||||
export interface ScheduleRunWithContext extends ScheduleRun {
|
||||
jobName: string
|
||||
repoName: string
|
||||
repoPath: string
|
||||
}
|
||||
|
||||
export interface ListAllRunsParams {
|
||||
limit?: number
|
||||
offset?: number
|
||||
status?: string
|
||||
repoId?: number
|
||||
jobId?: number
|
||||
triggerSource?: string
|
||||
}
|
||||
|
||||
export interface ScheduleCount {
|
||||
total: number
|
||||
enabled: number
|
||||
@@ -22,6 +37,18 @@ export async function listAllSchedules(): Promise<{ jobs: ScheduleJobWithRepo[]
|
||||
return fetchWrapper(`${API_BASE_URL}/api/schedules/all`)
|
||||
}
|
||||
|
||||
export async function listAllScheduleRuns(params: ListAllRunsParams = {}): Promise<{ runs: ScheduleRunWithContext[] }> {
|
||||
const searchParams = new URLSearchParams()
|
||||
if (params.limit !== undefined) searchParams.set('limit', String(params.limit))
|
||||
if (params.offset !== undefined) searchParams.set('offset', String(params.offset))
|
||||
if (params.status) searchParams.set('status', params.status)
|
||||
if (params.repoId !== undefined) searchParams.set('repoId', String(params.repoId))
|
||||
if (params.jobId !== undefined) searchParams.set('jobId', String(params.jobId))
|
||||
if (params.triggerSource) searchParams.set('triggerSource', params.triggerSource)
|
||||
const qs = searchParams.toString()
|
||||
return fetchWrapper(`${API_BASE_URL}/api/schedules/all/runs${qs ? `?${qs}` : ''}`)
|
||||
}
|
||||
|
||||
export async function listRepoSchedules(repoId: number): Promise<{ jobs: ScheduleJob[] }> {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/repos/${repoId}/schedules`)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||
import { ScheduleRunMarkdown } from '@/components/schedules/ScheduleRunMarkdown'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import type { ScheduleRun } from '@opencode-manager/shared/types'
|
||||
|
||||
interface RunDetailPanelProps {
|
||||
repoId: number
|
||||
activeRun: ScheduleRun | null
|
||||
selectedRunLoading: boolean
|
||||
onCancelRun: () => void
|
||||
cancelRunPending: boolean
|
||||
}
|
||||
|
||||
export function RunDetailPanel({ repoId, activeRun, selectedRunLoading, onCancelRun, cancelRunPending }: RunDetailPanelProps) {
|
||||
const navigate = useNavigate()
|
||||
|
||||
if (selectedRunLoading && !activeRun) {
|
||||
return (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!activeRun) {
|
||||
return <div className="flex h-full items-center justify-center text-sm text-muted-foreground">Select a run to inspect logs and output.</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<Tabs key={`${activeRun.id}-${String(activeRun.responseText ? 'response' : activeRun.errorText ? 'error' : 'log')}`} defaultValue={activeRun.responseText ? 'response' : activeRun.errorText ? 'error' : 'log'} className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||
<div className="flex items-center justify-center gap-2 px-2 py-1.5">
|
||||
<TabsList className="h-auto gap-0 rounded-none border-0 bg-transparent p-0">
|
||||
<TabsTrigger value="log" className="rounded-none border-b-2 border-transparent px-3 py-1.5 text-xs data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none">Log</TabsTrigger>
|
||||
<TabsTrigger value="response" disabled={!activeRun.responseText} className="rounded-none border-b-2 border-transparent px-3 py-1.5 text-xs data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none">Assistant Output</TabsTrigger>
|
||||
<TabsTrigger value="error" disabled={!activeRun.errorText} className="rounded-none border-b-2 border-transparent px-3 py-1.5 text-xs data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none">{activeRun.status === 'cancelled' ? 'Details' : 'Error'}</TabsTrigger>
|
||||
</TabsList>
|
||||
</div>
|
||||
{(activeRun.status === 'running' || activeRun.sessionId || activeRun.responseText) && (
|
||||
<div className="flex items-center justify-between gap-2 px-3 py-2">
|
||||
<div className="flex items-center gap-2">
|
||||
{activeRun.sessionId && (
|
||||
<Button variant="outline" size="sm" onClick={() => navigate(`/repos/${repoId}/sessions/${activeRun.sessionId}`)}>
|
||||
Open session
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<Button variant="outline" size="sm" onClick={onCancelRun} disabled={cancelRunPending || activeRun.status !== 'running'}>
|
||||
{cancelRunPending ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
|
||||
Cancel run
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<TabsContent value="log" className="mt-0 min-h-0 flex-1 overflow-y-auto px-0 py-3 [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
|
||||
{selectedRunLoading && !activeRun ? (
|
||||
<div className="flex items-center justify-center p-4"><Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /></div>
|
||||
) : (
|
||||
<pre className="whitespace-pre-wrap break-words text-sm font-mono leading-6">{activeRun.logText ?? 'No log text captured.'}</pre>
|
||||
)}
|
||||
</TabsContent>
|
||||
<TabsContent value="response" className="mt-0 min-h-0 flex-1 flex flex-col overflow-hidden">
|
||||
{selectedRunLoading && !activeRun ? (
|
||||
<div className="flex items-center justify-center p-4"><Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /></div>
|
||||
) : activeRun.responseText ? (
|
||||
<div className="min-h-0 flex-1 overflow-y-auto px-0 py-2 [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
|
||||
<ScheduleRunMarkdown content={activeRun.responseText} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="p-3"><pre className="whitespace-pre-wrap break-words text-sm font-mono leading-6">No assistant output captured.</pre></div>
|
||||
)}
|
||||
</TabsContent>
|
||||
<TabsContent value="error" className="mt-0 min-h-0 flex-1 overflow-y-auto px-0 py-3 [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
|
||||
{selectedRunLoading && !activeRun ? (
|
||||
<div className="flex items-center justify-center p-4"><Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /></div>
|
||||
) : (
|
||||
<pre className={`whitespace-pre-wrap break-words text-sm font-mono leading-6 ${activeRun.status === 'cancelled' ? 'text-muted-foreground' : 'text-red-300'}`}>{activeRun.errorText ?? 'No error recorded.'}</pre>
|
||||
)}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import { useState } from 'react'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { History, Loader2, XCircle, CheckCircle2, Ban, ChevronDown } from 'lucide-react'
|
||||
import type { ScheduleRun } from '@opencode-manager/shared/types'
|
||||
import type { ScheduleRunWithContext } from '@/api/schedules'
|
||||
import { getRunTone } from '@/components/schedules/schedule-utils'
|
||||
import { RunDetailPanel } from '@/components/schedules/RunDetailPanel'
|
||||
import { useRepoScheduleRun } from '@/hooks/useSchedules'
|
||||
|
||||
interface RunHistoryCardsProps {
|
||||
runs: ScheduleRunWithContext[] | undefined
|
||||
runsLoading: boolean
|
||||
onSelectRun: (id: number) => void
|
||||
onCancelRun: () => void
|
||||
cancelRunPending: boolean
|
||||
}
|
||||
|
||||
export function RunHistoryCards({
|
||||
runs,
|
||||
runsLoading,
|
||||
onSelectRun,
|
||||
onCancelRun,
|
||||
cancelRunPending,
|
||||
}: RunHistoryCardsProps) {
|
||||
const [expandedRunId, setExpandedRunId] = useState<number | null>(null)
|
||||
const [expandedRunRepoId, setExpandedRunRepoId] = useState<number | null>(null)
|
||||
const [expandedRunJobId, setExpandedRunJobId] = useState<number | null>(null)
|
||||
|
||||
const { data: runDetail, isLoading } = useRepoScheduleRun(
|
||||
expandedRunRepoId ?? undefined,
|
||||
expandedRunJobId,
|
||||
expandedRunId
|
||||
)
|
||||
|
||||
function getRunStatusIcon(status: ScheduleRun['status']) {
|
||||
if (status === 'completed') return <CheckCircle2 className="h-3.5 w-3.5 text-green-400" />
|
||||
if (status === 'failed') return <XCircle className="h-3.5 w-3.5 text-red-400" />
|
||||
if (status === 'running') return <Loader2 className="h-3.5 w-3.5 animate-spin text-blue-400" />
|
||||
return <Ban className="h-3.5 w-3.5 text-muted-foreground" />
|
||||
}
|
||||
|
||||
function handleCardClick(runId: number, repoId: number, jobId: number) {
|
||||
if (expandedRunId === runId) {
|
||||
setExpandedRunId(null)
|
||||
setExpandedRunRepoId(null)
|
||||
setExpandedRunJobId(null)
|
||||
} else {
|
||||
setExpandedRunId(runId)
|
||||
setExpandedRunRepoId(repoId)
|
||||
setExpandedRunJobId(jobId)
|
||||
onSelectRun(runId)
|
||||
}
|
||||
}
|
||||
|
||||
if (runsLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center p-6">
|
||||
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!runs?.length) {
|
||||
return (
|
||||
<div className="flex items-center justify-center p-6">
|
||||
<div className="text-center">
|
||||
<History className="h-10 w-10 text-muted-foreground mx-auto mb-4" />
|
||||
<p className="text-sm font-medium">No runs yet</p>
|
||||
<p className="text-xs text-muted-foreground mt-1">Use Run now to generate the first execution record and log bundle.</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col min-h-0 flex-1 h-full">
|
||||
<div className="min-h-0 flex-1 overflow-y-auto pt-4 pb-6 px-2 [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
|
||||
{runs.map((run, index) => {
|
||||
const isExpanded = expandedRunId === run.id
|
||||
const displayRun = isExpanded && runDetail ? runDetail : run
|
||||
|
||||
return (
|
||||
<div
|
||||
key={run.id}
|
||||
className={`rounded-xl border overflow-hidden transition-all bg-card ${
|
||||
isExpanded ? 'border-border/70' : 'border-border/70'
|
||||
} ${index === 0 ? 'mt-0' : 'mt-2'}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleCardClick(run.id, run.repoId, run.jobId)}
|
||||
className="w-full px-3 py-2 text-left flex items-center justify-between gap-2"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-1.5">
|
||||
{getRunStatusIcon(run.status)}
|
||||
<Badge className={getRunTone(run)}>{run.status}</Badge>
|
||||
</div>
|
||||
<span className="text-xs text-muted-foreground">{run.triggerSource}</span>
|
||||
</div>
|
||||
<p className="mt-2 truncate text-sm font-medium leading-tight">
|
||||
{run.sessionTitle ?? 'No session recorded'}
|
||||
</p>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">{new Date(run.startedAt).toLocaleString()}</p>
|
||||
{run.errorText && (
|
||||
<p className="mt-0.5 truncate text-xs text-red-400/80">{run.errorText}</p>
|
||||
)}
|
||||
</div>
|
||||
<ChevronDown className={`h-6 w-6 flex-shrink-0 text-muted-foreground transition-transform duration-200 self-start ${isExpanded ? 'rotate-180' : ''}`} />
|
||||
</button>
|
||||
{isExpanded && (
|
||||
<div className="border-t border-border/60 flex flex-col" style={{ maxHeight: 'calc(100vh - 200px)' }}>
|
||||
<div className="flex flex-col min-h-0 flex-1 overflow-hidden">
|
||||
<RunDetailPanel
|
||||
repoId={run.repoId}
|
||||
activeRun={displayRun}
|
||||
selectedRunLoading={isExpanded && isLoading}
|
||||
onCancelRun={onCancelRun}
|
||||
cancelRunPending={cancelRunPending}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,135 +1,31 @@
|
||||
import type { ScheduleJob, ScheduleRun } from '@opencode-manager/shared/types'
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
|
||||
import { ScheduleRunMarkdown } from '@/components/schedules/ScheduleRunMarkdown'
|
||||
import { getRunTone } from '@/components/schedules/schedule-utils'
|
||||
import { Ban, CheckCircle2, ChevronDown, History, Loader2, XCircle } from 'lucide-react'
|
||||
import { History, Loader2 } from 'lucide-react'
|
||||
import { RunHistoryCards, RunDetailPanel } from '@/components/schedules'
|
||||
|
||||
interface RunHistoryTabProps {
|
||||
repoId: number
|
||||
selectedJob: ScheduleJob | undefined
|
||||
runs: ScheduleRun[] | undefined
|
||||
runsLoading: boolean
|
||||
selectedRunId: number | null
|
||||
activeRun: ScheduleRun | null
|
||||
selectedRunLoading: boolean
|
||||
onSelectRun: (id: number) => void
|
||||
activeRun: ScheduleRun | null
|
||||
selectedRunLoading: boolean
|
||||
onCancelRun: () => void
|
||||
cancelRunPending: boolean
|
||||
}
|
||||
|
||||
interface RunDetailPanelProps {
|
||||
repoId: number
|
||||
activeRun: ScheduleRun | null
|
||||
selectedRunLoading: boolean
|
||||
onCancelRun: () => void
|
||||
cancelRunPending: boolean
|
||||
}
|
||||
|
||||
function RunDetailPanel({ repoId, activeRun, selectedRunLoading, onCancelRun, cancelRunPending }: RunDetailPanelProps) {
|
||||
const navigate = useNavigate()
|
||||
|
||||
if (selectedRunLoading && !activeRun) {
|
||||
return (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!activeRun) {
|
||||
return <div className="flex h-full items-center justify-center text-sm text-muted-foreground">Select a run to inspect logs and output.</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<Tabs key={`${activeRun.id}-${String(activeRun.responseText ? 'response' : activeRun.errorText ? 'error' : 'log')}`} defaultValue={activeRun.responseText ? 'response' : activeRun.errorText ? 'error' : 'log'} className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||
<div className="flex items-center justify-center gap-2 px-2 py-1.5">
|
||||
<TabsList className="h-auto gap-0 rounded-none border-0 bg-transparent p-0">
|
||||
<TabsTrigger value="log" className="rounded-none border-b-2 border-transparent px-3 py-1.5 text-xs data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none">Log</TabsTrigger>
|
||||
<TabsTrigger value="response" disabled={!activeRun.responseText} className="rounded-none border-b-2 border-transparent px-3 py-1.5 text-xs data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none">Assistant Output</TabsTrigger>
|
||||
<TabsTrigger value="error" disabled={!activeRun.errorText} className="rounded-none border-b-2 border-transparent px-3 py-1.5 text-xs data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none">{activeRun.status === 'cancelled' ? 'Details' : 'Error'}</TabsTrigger>
|
||||
</TabsList>
|
||||
</div>
|
||||
{(activeRun.status === 'running' || activeRun.sessionId || activeRun.responseText) && (
|
||||
<div className="flex items-center justify-between gap-2 px-3 py-2">
|
||||
<div className="flex items-center gap-2">
|
||||
{activeRun.sessionId && (
|
||||
<Button variant="outline" size="sm" onClick={() => navigate(`/repos/${repoId}/sessions/${activeRun.sessionId}`)}>
|
||||
Open session
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<Button variant="outline" size="sm" onClick={onCancelRun} disabled={cancelRunPending || activeRun.status !== 'running'}>
|
||||
{cancelRunPending ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
|
||||
Cancel run
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<TabsContent value="log" className="mt-0 min-h-0 flex-1 overflow-y-auto px-0 py-3 [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
|
||||
{selectedRunLoading && !activeRun ? (
|
||||
<div className="flex items-center justify-center p-4"><Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /></div>
|
||||
) : (
|
||||
<pre className="whitespace-pre-wrap break-words text-sm font-mono leading-6">{activeRun.logText ?? 'No log text captured.'}</pre>
|
||||
)}
|
||||
</TabsContent>
|
||||
<TabsContent value="response" className="mt-0 min-h-0 flex-1 flex flex-col overflow-hidden">
|
||||
{selectedRunLoading && !activeRun ? (
|
||||
<div className="flex items-center justify-center p-4"><Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /></div>
|
||||
) : activeRun.responseText ? (
|
||||
<div className="min-h-0 flex-1 overflow-y-auto px-0 py-2 [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
|
||||
<ScheduleRunMarkdown content={activeRun.responseText} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="p-3"><pre className="whitespace-pre-wrap break-words text-sm font-mono leading-6">No assistant output captured.</pre></div>
|
||||
)}
|
||||
</TabsContent>
|
||||
<TabsContent value="error" className="mt-0 min-h-0 flex-1 overflow-y-auto px-0 py-3 [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
|
||||
{selectedRunLoading && !activeRun ? (
|
||||
<div className="flex items-center justify-center p-4"><Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /></div>
|
||||
) : (
|
||||
<pre className={`whitespace-pre-wrap break-words text-sm font-mono leading-6 ${activeRun.status === 'cancelled' ? 'text-muted-foreground' : 'text-red-300'}`}>{activeRun.errorText ?? 'No error recorded.'}</pre>
|
||||
)}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
)
|
||||
}
|
||||
|
||||
export function RunHistoryTab({
|
||||
repoId,
|
||||
selectedJob,
|
||||
runs,
|
||||
runsLoading,
|
||||
selectedRunId,
|
||||
onSelectRun,
|
||||
activeRun,
|
||||
selectedRunLoading,
|
||||
onCancelRun,
|
||||
cancelRunPending,
|
||||
}: RunHistoryTabProps) {
|
||||
const [expandedRunId, setExpandedRunId] = useState<number | null>(null)
|
||||
|
||||
|
||||
function getRunStatusIcon(status: ScheduleRun['status']) {
|
||||
if (status === 'completed') return <CheckCircle2 className="h-3.5 w-3.5 text-green-400" />
|
||||
if (status === 'failed') return <XCircle className="h-3.5 w-3.5 text-red-400" />
|
||||
if (status === 'running') return <Loader2 className="h-3.5 w-3.5 animate-spin text-blue-400" />
|
||||
return <Ban className="h-3.5 w-3.5 text-muted-foreground" />
|
||||
}
|
||||
|
||||
function handleCardClick(runId: number) {
|
||||
if (expandedRunId === runId) {
|
||||
setExpandedRunId(null)
|
||||
} else {
|
||||
setExpandedRunId(runId)
|
||||
onSelectRun(runId)
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectedJob) {
|
||||
if (selectedRunLoading) {
|
||||
return (
|
||||
@@ -154,108 +50,14 @@ export function RunHistoryTab({
|
||||
return (
|
||||
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||
<div className="min-h-0 flex-1 overflow-hidden pt-2 xl:gap-4 xl:grid xl:grid-cols-[320px_minmax(0,1fr)] xl:grid-rows-1">
|
||||
<RunHistoryCards
|
||||
runs={runs}
|
||||
runsLoading={runsLoading}
|
||||
onSelectRun={onSelectRun}
|
||||
onCancelRun={onCancelRun}
|
||||
cancelRunPending={cancelRunPending}
|
||||
/>
|
||||
|
||||
{/* Mobile: collapsible list (hidden on xl+) */}
|
||||
<div className="xl:hidden flex flex-col min-h-0 flex-1 h-full">
|
||||
<div className="min-h-0 flex-1 overflow-y-auto pt-4 pb-6 px-2 [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
|
||||
{runsLoading ? (
|
||||
<div className="flex items-center justify-center p-6"><Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /></div>
|
||||
) : runs?.length ? runs.map((run, index) => (
|
||||
<div
|
||||
key={run.id}
|
||||
className={`rounded-xl border overflow-hidden transition-all bg-card ${
|
||||
expandedRunId === run.id
|
||||
? 'border-border/70'
|
||||
: 'border-border/70'
|
||||
} ${index === 0 ? 'mt-0' : 'mt-2'}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleCardClick(run.id)}
|
||||
className="w-full px-3 py-2 text-left flex items-center justify-between gap-2"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-1.5">
|
||||
{getRunStatusIcon(run.status)}
|
||||
<Badge className={getRunTone(run)}>{run.status}</Badge>
|
||||
</div>
|
||||
<span className="text-xs text-muted-foreground">{run.triggerSource}</span>
|
||||
</div>
|
||||
<p className="mt-2 truncate text-sm font-medium leading-tight">
|
||||
{run.sessionTitle ?? 'No session recorded'}
|
||||
</p>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">{new Date(run.startedAt).toLocaleString()}</p>
|
||||
{run.errorText && (
|
||||
<p className="mt-0.5 truncate text-xs text-red-400/80">{run.errorText}</p>
|
||||
)}
|
||||
</div>
|
||||
<ChevronDown className={`h-6 w-6 flex-shrink-0 text-muted-foreground transition-transform duration-200 self-start ${expandedRunId === run.id ? 'rotate-180' : ''}`} />
|
||||
</button>
|
||||
{expandedRunId === run.id && (
|
||||
<div className="border-t border-border/60 flex flex-col" style={{ maxHeight: 'calc(100vh - 200px)' }}>
|
||||
<div className="flex flex-col min-h-0 flex-1 overflow-hidden">
|
||||
<RunDetailPanel
|
||||
repoId={repoId}
|
||||
activeRun={activeRun}
|
||||
selectedRunLoading={selectedRunLoading}
|
||||
onCancelRun={onCancelRun}
|
||||
cancelRunPending={cancelRunPending}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)) : (
|
||||
<Alert>
|
||||
<History className="h-4 w-4" />
|
||||
<AlertTitle>No runs yet</AlertTitle>
|
||||
<AlertDescription>Use Run now to generate the first execution record and log bundle.</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Desktop: original two-column layout (hidden below xl) */}
|
||||
<div className="hidden xl:block min-h-0 space-y-2 overflow-y-auto pr-1">
|
||||
{runsLoading ? (
|
||||
<div className="flex items-center justify-center p-6"><Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /></div>
|
||||
) : runs?.length ? runs.map((run) => (
|
||||
<button
|
||||
key={run.id}
|
||||
type="button"
|
||||
onClick={() => onSelectRun(run.id)}
|
||||
className={`w-full rounded-xl border px-4 py-3 text-left transition-all ${
|
||||
selectedRunId === run.id
|
||||
? 'border-primary bg-primary/10 ring-2 ring-primary/30'
|
||||
: 'border-border/70 bg-background/60 hover:bg-accent/40'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-1.5">
|
||||
{getRunStatusIcon(run.status)}
|
||||
<Badge className={getRunTone(run)}>{run.status}</Badge>
|
||||
</div>
|
||||
<span className="text-xs text-muted-foreground">{run.triggerSource}</span>
|
||||
</div>
|
||||
<p className="mt-2 truncate text-sm font-medium leading-tight">
|
||||
{run.sessionTitle ?? 'No session recorded'}
|
||||
</p>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">{new Date(run.startedAt).toLocaleString()}</p>
|
||||
{run.errorText && (
|
||||
<p className="mt-0.5 truncate text-xs text-red-400/80">{run.errorText}</p>
|
||||
)}
|
||||
</button>
|
||||
)) : (
|
||||
<Alert>
|
||||
<History className="h-4 w-4" />
|
||||
<AlertTitle>No runs yet</AlertTitle>
|
||||
<AlertDescription>Use Run now to generate the first execution record and log bundle.</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Desktop: detail panel (hidden below xl) */}
|
||||
<div className="hidden xl:flex min-h-0 flex-col overflow-hidden rounded-xl border border-border/60 bg-background/60 p-4">
|
||||
<RunDetailPanel
|
||||
repoId={repoId}
|
||||
@@ -265,7 +67,6 @@ export function RunHistoryTab({
|
||||
cancelRunPending={cancelRunPending}
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export { JobsTab } from './JobsTab'
|
||||
export { JobDetailTab } from './JobDetailTab'
|
||||
export { RunHistoryTab } from './RunHistoryTab'
|
||||
export { RunHistoryCards } from './RunHistoryCards'
|
||||
export { RunDetailPanel } from './RunDetailPanel'
|
||||
export { ScheduleJobDialog } from './ScheduleJobDialog'
|
||||
export { ScheduleRunMarkdown } from './ScheduleRunMarkdown'
|
||||
export { ScheduleTabMenu } from './ScheduleTabMenu'
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
deleteRepoSchedule,
|
||||
getRepoSchedule,
|
||||
getRepoScheduleRun,
|
||||
listAllScheduleRuns,
|
||||
listAllSchedules,
|
||||
listRepoScheduleRuns,
|
||||
listRepoSchedules,
|
||||
@@ -13,7 +14,7 @@ import {
|
||||
updateRepoSchedule,
|
||||
} from '@/api/schedules'
|
||||
import { showToast } from '@/lib/toast'
|
||||
import type { ScheduleJobWithRepo } from '@/api/schedules'
|
||||
import type { ListAllRunsParams, ScheduleJobWithRepo, ScheduleRunWithContext } from '@/api/schedules'
|
||||
|
||||
export function useAllSchedules() {
|
||||
return useQuery({
|
||||
@@ -25,6 +26,18 @@ export function useAllSchedules() {
|
||||
})
|
||||
}
|
||||
|
||||
export function useAllScheduleRuns(params: ListAllRunsParams, enabled: boolean = true) {
|
||||
return useQuery({
|
||||
queryKey: ['all-schedule-runs', params],
|
||||
queryFn: async () => {
|
||||
const response = await listAllScheduleRuns(params)
|
||||
return response.runs as ScheduleRunWithContext[]
|
||||
},
|
||||
enabled,
|
||||
refetchInterval: 5000,
|
||||
})
|
||||
}
|
||||
|
||||
export function useRepoSchedules(repoId: number | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['repo-schedules', repoId],
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState, useMemo } from 'react'
|
||||
import { useState, useMemo, useEffect, useRef } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useAllSchedules } from '@/hooks/useSchedules'
|
||||
import { useAllSchedules, useAllScheduleRuns, useCancelRepoScheduleRun } from '@/hooks/useSchedules'
|
||||
import { useDeleteRepoSchedule, useRunRepoSchedule, useUpdateRepoSchedule, useCreateRepoSchedule } from '@/hooks/useSchedules'
|
||||
import { ScheduleJobDialog } from '@/components/schedules'
|
||||
import { ScheduleJobDialog, RunHistoryCards } from '@/components/schedules'
|
||||
import type { CreateScheduleJobRequest } from '@opencode-manager/shared/types'
|
||||
import { toUpdateScheduleRequest, formatScheduleShortLabel, getJobStatusTone, formatTimestamp } from '@/components/schedules/schedule-utils'
|
||||
import { Header } from '@/components/ui/header'
|
||||
@@ -11,9 +11,10 @@ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuChe
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { DeleteDialog } from '@/components/ui/delete-dialog'
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||
import { CalendarClock, Loader2, Plus, ArrowLeft, Play, Pencil, Trash2, Pause, PlayCircle, Clock3, History, SlidersHorizontal } from 'lucide-react'
|
||||
|
||||
import type { ScheduleJobWithRepo } from '@/api/schedules'
|
||||
import type { ScheduleJobWithRepo, ScheduleRunWithContext } from '@/api/schedules'
|
||||
import { Combobox } from '@/components/ui/combobox'
|
||||
|
||||
type StatusFilter = 'all' | 'enabled' | 'disabled'
|
||||
@@ -30,14 +31,80 @@ export function GlobalSchedules() {
|
||||
const [scheduleModeFilter, setScheduleModeFilter] = useState<ScheduleModeFilter>('all')
|
||||
const [repoFilter, setRepoFilter] = useState<string>('all')
|
||||
const [sortOption, setSortOption] = useState<SortOption>('nextRun')
|
||||
const [activeTab, setActiveTab] = useState<'jobs' | 'runs'>('jobs')
|
||||
const [runStatusFilter, setRunStatusFilter] = useState<string>('all')
|
||||
const [runRepoFilter, setRunRepoFilter] = useState<string>('all')
|
||||
const [runTriggerFilter, setRunTriggerFilter] = useState<string>('all')
|
||||
const [runSortOption, setRunSortOption] = useState<'startedAt' | 'jobName' | 'duration'>('startedAt')
|
||||
const [runOffset, setRunOffset] = useState(0)
|
||||
const [allRuns, setAllRuns] = useState<ScheduleRunWithContext[]>([])
|
||||
const [selectedRunId, setSelectedRunId] = useState<number | null>(null)
|
||||
const runOffsetRef = useRef(runOffset)
|
||||
|
||||
const cancelRunMutation = useCancelRepoScheduleRun()
|
||||
const cancelRunPending = cancelRunMutation.isPending
|
||||
|
||||
useEffect(() => {
|
||||
runOffsetRef.current = runOffset
|
||||
}, [runOffset])
|
||||
|
||||
const { data: jobs = [], isLoading, error } = useAllSchedules()
|
||||
|
||||
const runsParams = useMemo(() => ({
|
||||
limit: 50,
|
||||
offset: runOffset,
|
||||
status: runStatusFilter !== 'all' ? runStatusFilter : undefined,
|
||||
repoId: runRepoFilter !== 'all' ? Number(runRepoFilter.split('|')[0]) : undefined,
|
||||
triggerSource: runTriggerFilter !== 'all' ? runTriggerFilter : undefined,
|
||||
}), [runStatusFilter, runRepoFilter, runTriggerFilter, runOffset])
|
||||
|
||||
const { data: runsPage = [], isLoading: runsLoading } = useAllScheduleRuns(runsParams, activeTab === 'runs')
|
||||
|
||||
const createMutation = useCreateRepoSchedule()
|
||||
const deleteMutation = useDeleteRepoSchedule()
|
||||
const runMutation = useRunRepoSchedule()
|
||||
const updateMutation = useUpdateRepoSchedule()
|
||||
|
||||
useEffect(() => {
|
||||
setRunOffset(0)
|
||||
setAllRuns([])
|
||||
}, [runStatusFilter, runRepoFilter, runTriggerFilter])
|
||||
|
||||
useEffect(() => {
|
||||
if (runsPage.length > 0) {
|
||||
if (runOffsetRef.current === 0) {
|
||||
setAllRuns(runsPage)
|
||||
} else {
|
||||
setAllRuns((prev) => {
|
||||
const existingIds = new Set(prev.map((r) => r.id))
|
||||
const newRuns = runsPage.filter((r) => !existingIds.has(r.id))
|
||||
return newRuns.length > 0 ? [...prev, ...newRuns] : prev
|
||||
})
|
||||
}
|
||||
} else if (runOffsetRef.current === 0) {
|
||||
setAllRuns((prev) => prev.length > 0 ? [] : prev)
|
||||
}
|
||||
}, [runsPage])
|
||||
|
||||
const sortedRuns = useMemo(() => {
|
||||
const sorted = [...allRuns]
|
||||
sorted.sort((a, b) => {
|
||||
switch (runSortOption) {
|
||||
case 'jobName':
|
||||
return a.jobName.localeCompare(b.jobName)
|
||||
case 'duration': {
|
||||
const aDuration = a.finishedAt ? a.finishedAt - a.startedAt : 0
|
||||
const bDuration = b.finishedAt ? b.finishedAt - b.startedAt : 0
|
||||
return bDuration - aDuration
|
||||
}
|
||||
case 'startedAt':
|
||||
default:
|
||||
return new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
|
||||
}
|
||||
})
|
||||
return sorted
|
||||
}, [allRuns, runSortOption])
|
||||
|
||||
const uniqueRepos = useMemo(() => {
|
||||
const repoMap = new Map<string, { name: string; url: string }>()
|
||||
jobs.forEach((job) => {
|
||||
@@ -125,6 +192,35 @@ export function GlobalSchedules() {
|
||||
{ value: 'repo', label: 'Repository' },
|
||||
], [])
|
||||
|
||||
const runStatusOptions = useMemo(() => [
|
||||
{ value: 'all', label: 'All Status' },
|
||||
{ value: 'running', label: 'Running' },
|
||||
{ value: 'completed', label: 'Completed' },
|
||||
{ value: 'failed', label: 'Failed' },
|
||||
{ value: 'cancelled', label: 'Cancelled' },
|
||||
], [])
|
||||
|
||||
const runTriggerOptions = useMemo(() => [
|
||||
{ value: 'all', label: 'All Triggers' },
|
||||
{ value: 'manual', label: 'Manual' },
|
||||
{ value: 'schedule', label: 'Scheduled' },
|
||||
], [])
|
||||
|
||||
const runSortOptions = useMemo(() => [
|
||||
{ value: 'startedAt', label: 'Date' },
|
||||
{ value: 'jobName', label: 'Job Name' },
|
||||
{ value: 'duration', label: 'Duration' },
|
||||
], [])
|
||||
|
||||
const runRepoOptions = useMemo(() => [
|
||||
{ value: 'all', label: 'All Repos', description: '' },
|
||||
...uniqueRepos.map((repo) => ({
|
||||
value: `${jobs.find((j) => j.repoPath === repo.path)?.repoId ?? 0}|${repo.path}`,
|
||||
label: repo.name,
|
||||
description: repo.path,
|
||||
})),
|
||||
], [uniqueRepos, jobs])
|
||||
|
||||
const handleDelete = () => {
|
||||
if (!deletingJob) {
|
||||
return
|
||||
@@ -136,6 +232,10 @@ export function GlobalSchedules() {
|
||||
)
|
||||
}
|
||||
|
||||
const handleCancelRun = (repoId: number, jobId: number, runId: number) => {
|
||||
cancelRunMutation.mutate({ repoId, jobId, runId })
|
||||
}
|
||||
|
||||
const handleToggleEnabled = (job: ScheduleJobWithRepo) => {
|
||||
updateMutation.mutate({
|
||||
repoId: job.repoId,
|
||||
@@ -248,314 +348,534 @@ export function GlobalSchedules() {
|
||||
</div>
|
||||
</Header>
|
||||
|
||||
<div className="border-b border-border px-4 py-3 space-y-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap hidden sm:inline">Filter by repo:</span>
|
||||
<Combobox
|
||||
value={repoFilter}
|
||||
onChange={setRepoFilter}
|
||||
options={repoOptions}
|
||||
placeholder="All Repos"
|
||||
className="flex-1 sm:flex-none sm:min-w-[150px]"
|
||||
/>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="icon" className="sm:hidden h-8 w-8 shrink-0 relative">
|
||||
<SlidersHorizontal className="h-3.5 w-3.5" />
|
||||
{(statusFilter !== 'all' || scheduleModeFilter !== 'all') && (
|
||||
<span className="absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" />
|
||||
)}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
setStatusFilter('all')
|
||||
setScheduleModeFilter('all')
|
||||
setRepoFilter('all')
|
||||
setSortOption('nextRun')
|
||||
}}
|
||||
className="text-xs text-muted-foreground"
|
||||
>
|
||||
Clear all filters
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Status</DropdownMenuLabel>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={statusFilter === 'all'}
|
||||
onCheckedChange={() => setStatusFilter('all')}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
All Status
|
||||
</DropdownMenuCheckboxItem>
|
||||
{statusOptions.filter((opt) => opt.value !== 'all').map((opt) => (
|
||||
<DropdownMenuCheckboxItem
|
||||
key={opt.value}
|
||||
checked={statusFilter === opt.value}
|
||||
onCheckedChange={(checked) => {
|
||||
if (checked) {
|
||||
setStatusFilter(opt.value as StatusFilter)
|
||||
} else {
|
||||
<Tabs value={activeTab} onValueChange={(v) => setActiveTab(v as 'jobs' | 'runs')} className="flex-1 min-h-0 flex flex-col overflow-hidden">
|
||||
<div className="border-b border-border px-4">
|
||||
<TabsList className="h-auto gap-0 rounded-none border-0 bg-transparent p-0">
|
||||
<TabsTrigger value="jobs" className="rounded-none border-b-2 border-transparent px-4 py-2.5 text-sm data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none">
|
||||
Jobs
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="runs" className="rounded-none border-b-2 border-transparent px-4 py-2.5 text-sm data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none">
|
||||
Run History
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</div>
|
||||
|
||||
<TabsContent value="jobs" className="mt-0 flex-1 min-h-0 flex flex-col overflow-hidden">
|
||||
<div className="border-b border-border px-4 py-3 space-y-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap hidden sm:inline">Filter by repo:</span>
|
||||
<Combobox
|
||||
value={repoFilter}
|
||||
onChange={setRepoFilter}
|
||||
options={repoOptions}
|
||||
placeholder="All Repos"
|
||||
className="flex-1 sm:flex-none sm:min-w-[150px]"
|
||||
/>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="icon" className="sm:hidden h-8 w-8 shrink-0 relative">
|
||||
<SlidersHorizontal className="h-3.5 w-3.5" />
|
||||
{(statusFilter !== 'all' || scheduleModeFilter !== 'all') && (
|
||||
<span className="absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" />
|
||||
)}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
setStatusFilter('all')
|
||||
}
|
||||
}}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{opt.label}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Mode</DropdownMenuLabel>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={scheduleModeFilter === 'all'}
|
||||
onCheckedChange={() => setScheduleModeFilter('all')}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
All Modes
|
||||
</DropdownMenuCheckboxItem>
|
||||
{modeOptions.filter((opt) => opt.value !== 'all').map((opt) => (
|
||||
<DropdownMenuCheckboxItem
|
||||
key={opt.value}
|
||||
checked={scheduleModeFilter === opt.value}
|
||||
onCheckedChange={(checked) => {
|
||||
if (checked) {
|
||||
setScheduleModeFilter(opt.value as ScheduleModeFilter)
|
||||
} else {
|
||||
setScheduleModeFilter('all')
|
||||
}
|
||||
}}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{opt.label}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Sort</DropdownMenuLabel>
|
||||
<DropdownMenuRadioGroup value={sortOption} onValueChange={(v) => setSortOption(v as SortOption)}>
|
||||
{sortOptions.map((opt) => (
|
||||
<DropdownMenuRadioItem
|
||||
key={opt.value}
|
||||
value={opt.value}
|
||||
setRepoFilter('all')
|
||||
setSortOption('nextRun')
|
||||
}}
|
||||
className="text-xs text-muted-foreground"
|
||||
>
|
||||
Clear all filters
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Status</DropdownMenuLabel>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={statusFilter === 'all'}
|
||||
onCheckedChange={() => setStatusFilter('all')}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{opt.label}
|
||||
</DropdownMenuRadioItem>
|
||||
))}
|
||||
</DropdownMenuRadioGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
<div className="hidden sm:flex flex-wrap gap-x-4 gap-y-2">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Status:</span>
|
||||
<div className="flex gap-1">
|
||||
{statusOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={statusFilter === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setStatusFilter(opt.value as StatusFilter)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Mode:</span>
|
||||
<div className="flex gap-1">
|
||||
{modeOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={scheduleModeFilter === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setScheduleModeFilter(opt.value as ScheduleModeFilter)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Sort:</span>
|
||||
<div className="flex gap-1">
|
||||
{sortOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={sortOption === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setSortOption(opt.value as SortOption)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-h-0 overflow-y-auto p-4">
|
||||
{!hasJobs ? (
|
||||
<div className="flex min-h-full items-center justify-center">
|
||||
<Card className="max-w-md border-dashed border-border/70">
|
||||
<CardContent className="flex flex-col items-center gap-4 p-8 text-center">
|
||||
<div className="rounded-full border border-border bg-muted/40 p-4">
|
||||
<CalendarClock className="h-8 w-8 text-muted-foreground" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<p className="text-lg font-semibold">No schedules yet</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Create schedules for your repositories to automate recurring agent work.
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={() => navigate('/')}>
|
||||
<Plus className="w-4 h-4 mr-2" />
|
||||
Go to Repositories
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
) : filteredAndSortedJobs.length === 0 ? (
|
||||
<div className="flex min-h-full items-center justify-center">
|
||||
<Card className="max-w-md border-dashed border-border/70">
|
||||
<CardContent className="flex flex-col items-center gap-4 p-8 text-center">
|
||||
<div className="rounded-full border border-border bg-muted/40 p-4">
|
||||
<CalendarClock className="h-8 w-8 text-muted-foreground" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<p className="text-lg font-semibold">No matching schedules</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Try adjusting your filters to see more results.
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setStatusFilter('all')
|
||||
setScheduleModeFilter('all')
|
||||
setRepoFilter('all')
|
||||
}}
|
||||
>
|
||||
Clear Filters
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-3 md:grid-cols-2 lg:grid-cols-3">
|
||||
{filteredAndSortedJobs.map((job) => (
|
||||
<Card
|
||||
key={job.id}
|
||||
className="group cursor-pointer transition-all hover:shadow-md border-border/70 bg-card/60"
|
||||
onClick={() => navigate(`/repos/${job.repoId}/schedules`)}
|
||||
>
|
||||
<CardContent className="p-4 space-y-3">
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<div className="min-w-0 flex-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleNavigateToRepo(job.repoPath)
|
||||
}}
|
||||
className="text-xs text-muted-foreground hover:text-foreground hover:underline truncate block mb-1"
|
||||
All Status
|
||||
</DropdownMenuCheckboxItem>
|
||||
{statusOptions.filter((opt) => opt.value !== 'all').map((opt) => (
|
||||
<DropdownMenuCheckboxItem
|
||||
key={opt.value}
|
||||
checked={statusFilter === opt.value}
|
||||
onCheckedChange={(checked) => {
|
||||
if (checked) {
|
||||
setStatusFilter(opt.value as StatusFilter)
|
||||
} else {
|
||||
setStatusFilter('all')
|
||||
}
|
||||
}}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{opt.label}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Mode</DropdownMenuLabel>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={scheduleModeFilter === 'all'}
|
||||
onCheckedChange={() => setScheduleModeFilter('all')}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
All Modes
|
||||
</DropdownMenuCheckboxItem>
|
||||
{modeOptions.filter((opt) => opt.value !== 'all').map((opt) => (
|
||||
<DropdownMenuCheckboxItem
|
||||
key={opt.value}
|
||||
checked={scheduleModeFilter === opt.value}
|
||||
onCheckedChange={(checked) => {
|
||||
if (checked) {
|
||||
setScheduleModeFilter(opt.value as ScheduleModeFilter)
|
||||
} else {
|
||||
setScheduleModeFilter('all')
|
||||
}
|
||||
}}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{opt.label}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Sort</DropdownMenuLabel>
|
||||
<DropdownMenuRadioGroup value={sortOption} onValueChange={(v) => setSortOption(v as SortOption)}>
|
||||
{sortOptions.map((opt) => (
|
||||
<DropdownMenuRadioItem
|
||||
key={opt.value}
|
||||
value={opt.value}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{job.repoName}
|
||||
</button>
|
||||
<h3 className="font-medium truncate">{job.name}</h3>
|
||||
<p className="mt-1 text-xs text-muted-foreground line-clamp-2">
|
||||
{job.description || 'No description'}
|
||||
{opt.label}
|
||||
</DropdownMenuRadioItem>
|
||||
))}
|
||||
</DropdownMenuRadioGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
<div className="hidden sm:flex flex-wrap gap-x-4 gap-y-2">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Status:</span>
|
||||
<div className="flex gap-1">
|
||||
{statusOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={statusFilter === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setStatusFilter(opt.value as StatusFilter)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Mode:</span>
|
||||
<div className="flex gap-1">
|
||||
{modeOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={scheduleModeFilter === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setScheduleModeFilter(opt.value as ScheduleModeFilter)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Sort:</span>
|
||||
<div className="flex gap-1">
|
||||
{sortOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={sortOption === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setSortOption(opt.value as SortOption)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-h-0 overflow-y-auto p-4">
|
||||
{!hasJobs ? (
|
||||
<div className="flex min-h-full items-center justify-center">
|
||||
<Card className="max-w-md border-dashed border-border/70">
|
||||
<CardContent className="flex flex-col items-center gap-4 p-8 text-center">
|
||||
<div className="rounded-full border border-border bg-muted/40 p-4">
|
||||
<CalendarClock className="h-8 w-8 text-muted-foreground" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<p className="text-lg font-semibold">No schedules yet</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Create schedules for your repositories to automate recurring agent work.
|
||||
</p>
|
||||
</div>
|
||||
<Badge className={getJobStatusTone(job)}>
|
||||
{job.enabled ? 'Enabled' : 'Paused'}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 text-xs text-muted-foreground">
|
||||
<div className="flex items-center gap-2">
|
||||
<CalendarClock className="h-3.5 w-3.5" />
|
||||
<span className="truncate">
|
||||
{formatScheduleShortLabel(job)}
|
||||
</span>
|
||||
<Button onClick={() => navigate('/')}>
|
||||
<Plus className="w-4 h-4 mr-2" />
|
||||
Go to Repositories
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
) : filteredAndSortedJobs.length === 0 ? (
|
||||
<div className="flex min-h-full items-center justify-center">
|
||||
<Card className="max-w-md border-dashed border-border/70">
|
||||
<CardContent className="flex flex-col items-center gap-4 p-8 text-center">
|
||||
<div className="rounded-full border border-border bg-muted/40 p-4">
|
||||
<CalendarClock className="h-8 w-8 text-muted-foreground" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Clock3 className="h-3.5 w-3.5" />
|
||||
<span>
|
||||
Next: {job.nextRunAt ? new Date(job.nextRunAt).toLocaleString() : 'Never'}
|
||||
</span>
|
||||
<div className="space-y-2">
|
||||
<p className="text-lg font-semibold">No matching schedules</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Try adjusting your filters to see more results.
|
||||
</p>
|
||||
</div>
|
||||
{job.lastRunAt && (
|
||||
<div className="flex items-center gap-2">
|
||||
<History className="h-3.5 w-3.5" />
|
||||
<span>
|
||||
Last: {formatTimestamp(job.lastRunAt)}
|
||||
</span>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setStatusFilter('all')
|
||||
setScheduleModeFilter('all')
|
||||
setRepoFilter('all')
|
||||
}}
|
||||
>
|
||||
Clear Filters
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-3 md:grid-cols-2 lg:grid-cols-3">
|
||||
{filteredAndSortedJobs.map((job) => (
|
||||
<Card
|
||||
key={job.id}
|
||||
className="group cursor-pointer transition-all hover:shadow-md border-border/70 bg-card/60"
|
||||
onClick={() => navigate(`/repos/${job.repoId}/schedules`)}
|
||||
>
|
||||
<CardContent className="p-4 space-y-3">
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<div className="min-w-0 flex-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleNavigateToRepo(job.repoPath)
|
||||
}}
|
||||
className="text-xs text-muted-foreground hover:text-foreground hover:underline truncate block mb-1"
|
||||
>
|
||||
{job.repoName}
|
||||
</button>
|
||||
<h3 className="font-medium truncate">{job.name}</h3>
|
||||
<p className="mt-1 text-xs text-muted-foreground line-clamp-2">
|
||||
{job.description || 'No description'}
|
||||
</p>
|
||||
</div>
|
||||
<Badge className={getJobStatusTone(job)}>
|
||||
{job.enabled ? 'Enabled' : 'Paused'}
|
||||
</Badge>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 pt-2 border-t border-border/50">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleRunNow(job)
|
||||
}}
|
||||
disabled={runMutation.isPending}
|
||||
>
|
||||
<PlayCircle className="h-3.5 w-3.5 mr-1" />
|
||||
Run
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleToggleEnabled(job)
|
||||
}}
|
||||
>
|
||||
{job.enabled ? (
|
||||
<Pause className="h-3.5 w-3.5" />
|
||||
) : (
|
||||
<Play className="h-3.5 w-3.5" />
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleEdit(job)
|
||||
}}
|
||||
>
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8 w-8 p-0 text-destructive hover:text-destructive"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setDeletingJob(job)
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
<div className="space-y-2 text-xs text-muted-foreground">
|
||||
<div className="flex items-center gap-2">
|
||||
<CalendarClock className="h-3.5 w-3.5" />
|
||||
<span className="truncate">
|
||||
{formatScheduleShortLabel(job)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Clock3 className="h-3.5 w-3.5" />
|
||||
<span>
|
||||
Next: {job.nextRunAt ? new Date(job.nextRunAt).toLocaleString() : 'Never'}
|
||||
</span>
|
||||
</div>
|
||||
{job.lastRunAt && (
|
||||
<div className="flex items-center gap-2">
|
||||
<History className="h-3.5 w-3.5" />
|
||||
<span>
|
||||
Last: {formatTimestamp(job.lastRunAt)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 pt-2 border-t border-border/50">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleRunNow(job)
|
||||
}}
|
||||
disabled={runMutation.isPending}
|
||||
>
|
||||
<PlayCircle className="h-3.5 w-3.5 mr-1" />
|
||||
Run
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleToggleEnabled(job)
|
||||
}}
|
||||
>
|
||||
{job.enabled ? (
|
||||
<Pause className="h-3.5 w-3.5" />
|
||||
) : (
|
||||
<Play className="h-3.5 w-3.5" />
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleEdit(job)
|
||||
}}
|
||||
>
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8 w-8 p-0 text-destructive hover:text-destructive"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setDeletingJob(job)
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="runs" className="mt-0 flex-1 min-h-0 flex flex-col overflow-hidden">
|
||||
<div className="border-b border-border px-4 py-3 space-y-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap hidden sm:inline">Filter by repo:</span>
|
||||
<Combobox
|
||||
value={runRepoFilter}
|
||||
onChange={setRunRepoFilter}
|
||||
options={runRepoOptions}
|
||||
placeholder="All Repos"
|
||||
className="flex-1 sm:flex-none sm:min-w-[150px]"
|
||||
/>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="icon" className="sm:hidden h-8 w-8 shrink-0 relative">
|
||||
<SlidersHorizontal className="h-3.5 w-3.5" />
|
||||
{(runStatusFilter !== 'all' || runTriggerFilter !== 'all' || runSortOption !== 'startedAt') && (
|
||||
<span className="absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" />
|
||||
)}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
setRunStatusFilter('all')
|
||||
setRunTriggerFilter('all')
|
||||
setRunRepoFilter('all')
|
||||
setRunSortOption('startedAt')
|
||||
}}
|
||||
className="text-xs text-muted-foreground"
|
||||
>
|
||||
Clear all filters
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Status</DropdownMenuLabel>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={runStatusFilter === 'all'}
|
||||
onCheckedChange={() => setRunStatusFilter('all')}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
All Status
|
||||
</DropdownMenuCheckboxItem>
|
||||
{runStatusOptions.filter((opt) => opt.value !== 'all').map((opt) => (
|
||||
<DropdownMenuCheckboxItem
|
||||
key={opt.value}
|
||||
checked={runStatusFilter === opt.value}
|
||||
onCheckedChange={(checked) => {
|
||||
if (checked) {
|
||||
setRunStatusFilter(opt.value)
|
||||
} else {
|
||||
setRunStatusFilter('all')
|
||||
}
|
||||
}}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{opt.label}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Trigger</DropdownMenuLabel>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={runTriggerFilter === 'all'}
|
||||
onCheckedChange={() => setRunTriggerFilter('all')}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
All Triggers
|
||||
</DropdownMenuCheckboxItem>
|
||||
{runTriggerOptions.filter((opt) => opt.value !== 'all').map((opt) => (
|
||||
<DropdownMenuCheckboxItem
|
||||
key={opt.value}
|
||||
checked={runTriggerFilter === opt.value}
|
||||
onCheckedChange={(checked) => {
|
||||
if (checked) {
|
||||
setRunTriggerFilter(opt.value)
|
||||
} else {
|
||||
setRunTriggerFilter('all')
|
||||
}
|
||||
}}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{opt.label}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Sort</DropdownMenuLabel>
|
||||
<DropdownMenuRadioGroup value={runSortOption} onValueChange={(v) => setRunSortOption(v as 'startedAt' | 'jobName' | 'duration')}>
|
||||
{runSortOptions.map((opt) => (
|
||||
<DropdownMenuRadioItem
|
||||
key={opt.value}
|
||||
value={opt.value}
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
>
|
||||
{opt.label}
|
||||
</DropdownMenuRadioItem>
|
||||
))}
|
||||
</DropdownMenuRadioGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
<div className="hidden sm:flex flex-wrap gap-x-4 gap-y-2">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Status:</span>
|
||||
<div className="flex gap-1">
|
||||
{runStatusOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={runStatusFilter === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setRunStatusFilter(opt.value)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Trigger:</span>
|
||||
<div className="flex gap-1">
|
||||
{runTriggerOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={runTriggerFilter === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setRunTriggerFilter(opt.value)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground whitespace-nowrap">Sort:</span>
|
||||
<div className="flex gap-1">
|
||||
{runSortOptions.map((opt) => (
|
||||
<Button
|
||||
key={opt.value}
|
||||
variant={runSortOption === opt.value ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={() => setRunSortOption(opt.value as 'startedAt' | 'jobName' | 'duration')}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{opt.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-h-0 overflow-y-auto p-4">
|
||||
{runsLoading && allRuns.length === 0 ? (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
) : allRuns.length === 0 ? (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<Card className="max-w-md border-dashed border-border/70">
|
||||
<CardContent className="flex flex-col items-center gap-4 p-8 text-center">
|
||||
<div className="rounded-full border border-border bg-muted/40 p-4">
|
||||
<History className="h-8 w-8 text-muted-foreground" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<p className="text-lg font-semibold">No runs found</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{runStatusFilter !== 'all' || runRepoFilter !== 'all' || runTriggerFilter !== 'all'
|
||||
? 'Try adjusting your filters to see more results.'
|
||||
: 'Schedule runs will appear here once jobs start executing.'}
|
||||
</p>
|
||||
</div>
|
||||
{(runStatusFilter !== 'all' || runRepoFilter !== 'all' || runTriggerFilter !== 'all' || runSortOption !== 'startedAt') && (
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setRunStatusFilter('all')
|
||||
setRunRepoFilter('all')
|
||||
setRunTriggerFilter('all')
|
||||
setRunSortOption('startedAt')
|
||||
}}
|
||||
>
|
||||
Clear Filters
|
||||
</Button>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
) : (
|
||||
<RunHistoryCards
|
||||
runs={sortedRuns}
|
||||
runsLoading={runsLoading}
|
||||
onSelectRun={setSelectedRunId}
|
||||
onCancelRun={() => {
|
||||
if (selectedRunId) {
|
||||
const run = sortedRuns.find((r) => r.id === selectedRunId)
|
||||
if (run) {
|
||||
handleCancelRun(run.repoId, run.jobId, run.id)
|
||||
}
|
||||
}
|
||||
}}
|
||||
cancelRunPending={cancelRunPending}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
<ScheduleJobDialog
|
||||
open={dialogOpen}
|
||||
|
||||
Reference in new issue
Block a user