import React, { useEffect, useState } from 'react'; import { api, type JobResponse } from '../api.js'; interface JobsProps { token: string; teamSlug: string; } const TABLE_STYLE: React.CSSProperties = { width: '100%', borderCollapse: 'collapse', marginTop: 16, background: '#12141a', border: '1px solid #2a2d36', borderRadius: 8, overflow: 'hidden', boxShadow: '0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3)', }; const TH_STYLE: React.CSSProperties = { textAlign: 'left', padding: '12px 16px', borderBottom: '1px solid #2a2d36', fontSize: 13, color: '#9ca3af', textTransform: 'uppercase', letterSpacing: 0.5, }; const TD_STYLE: React.CSSProperties = { padding: '10px 16px', fontSize: 14, color: '#cbd5e1', }; const STATUS_COLORS: Record = { queued: '#6b7280', running: '#3b82f6', completed: '#10b981', failed: '#ef4444', }; export function Jobs({ token, teamSlug }: JobsProps) { const [jobs, setJobs] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { if (!token || !teamSlug) return; let cancelled = false; (async () => { try { setLoading(true); setError(null); const data = await api.listJobs(token, teamSlug); if (!cancelled) setJobs(Array.isArray(data) ? data : []); } catch { if (!cancelled) { setError('Job queue not available. The team server may not support job listing, or is not running.'); setJobs([]); } } finally { if (!cancelled) setLoading(false); } })(); return () => { cancelled = true; }; }, [token, teamSlug]); return (

Agent Jobs

{error && (
{error}
)} {loading ? (

Loading jobs...

) : jobs.length === 0 && !error ? (

No jobs found

Jobs appear here when agents execute tasks in the team workspace.

) : jobs.length > 0 ? (
{jobs.map((job) => ( ))}
ID Type Status Created Completed
{job.id.slice(0, 8)} {job.jobType} {job.status} {new Date(job.createdAt).toLocaleString()} {job.completedAt ? new Date(job.completedAt).toLocaleString() : '—'}
) : null}
); }