import { useState, type ReactNode } from "react"; import { ArrowUpRight, ChevronDown, LoaderCircle, Plus, RefreshCw, } from "lucide-react"; import "./jobs.css"; import SubtaskViews from "./SubtaskViews"; export type Job = { id: string; name?: string; stage: string; created_at: string; owner: string; output?: string; }; export type Progress = { model?: string; captioner?: string; status: string; expected: number; completed: number; exported?: number; export_pending?: number; failed: number; failed_recordings?: { source_episode_index: number; recording: string; hand: string; stage: string; error: string; }[]; stopped?: number; pending?: number; usage: { measured_inference_usd?: number; successful_calls?: number; input_tokens?: number; output_tokens?: number; rate_limited_requests?: number; media_usd?: number; completed_media_requests?: number; }; cost?: { inference_usd: number | null; cpu_usd: number | null; total_usd: number | null; uncertain_inference_usd: number; running_seconds: number | null; basis: string; billing_url: string; }; annotation_url?: string | null; hand_visualizer_url?: string | null; output_mode?: string; subtask_views?: "primary" | "per-camera" | "per-hand"; subtask_cameras?: string[]; human_videos?: Record | null; }; type HumanVideo = { episode_index?: number | null; source_episode_index: number; segment_index?: number; subtask?: string; caption?: string | null; status: string; robot_frame?: string; first_frame?: string; video?: string; }; function HumanVideos({ jobId }: { jobId: string }) { const [videos, setVideos] = useState(null); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); async function load() { setLoading(true); setError(""); try { const response = await fetch(`/api/jobs/${jobId}/human-videos`, { credentials: "same-origin", }); if (!response.ok) throw new Error("No human demo videos saved yet."); setVideos(await response.json()); } catch (e) { setError((e as Error).message); } finally { setLoading(false); } } if (!videos) return (
{error &&

{error}

}
); const ready = videos.filter((v) => v.status === "completed" && v.video); return (
{ready.length === 0 &&

No completed videos yet.

}
{ready.map((v) => (
{v.robot_frame && ( Robot view )}
Episode {v.episode_index ?? v.source_episode_index} {" "} · {v.subtask}
))}
); } const terminal = new Set(["COMPLETED", "ERROR", "CANCELED", "DELETED"]); const usd = (value: number | null | undefined) => value == null ? "—" : new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", minimumFractionDigits: value > 0 && value < 1 ? 4 : 2, maximumFractionDigits: 4, }).format(value); function status(job: Job, progress?: Progress) { if (job.stage === "ERROR") return "Failed"; if (job.stage === "COMPLETED") return progress?.status === "partial" ? "Partial" : "Completed"; if (job.stage === "CANCELED") return "Canceled"; if (["PENDING", "QUEUED"].includes(job.stage)) return "Queued"; if ( progress?.expected && progress.completed === progress.expected && progress.export_pending ) return "Exporting"; return job.stage[0] + job.stage.slice(1).toLowerCase(); } export default function JobsView({ jobs, progress, models, signedIn, loading, signIn, onRefresh, onNew, onCancel, }: { jobs: Job[]; progress: Record; models: { route: string; name: string; provider_name: string }[]; signedIn: boolean; loading: boolean; signIn: ReactNode; onRefresh: () => void; onNew: () => void; onCancel: (id: string) => void; }) { return (

Jobs

{!signedIn ? (

Sign in to see your jobs.

{signIn}
) : jobs.length === 0 ? (
{loading ? ( <>

Loading jobs…

) : ( <>

No jobs yet.

)}
) : (
{jobs.map((job) => { const p = progress[job.id]; const ended = terminal.has(job.stage); const state = status(job, p); const profile = models.find((m) => m.route === p?.model); const model = p?.captioner === "flora" ? "Flora · TempSeg + Captioner" : profile?.name || p?.model?.split(":")[0].split("/").pop(); const provider = p?.captioner === "flora" ? "H200 GPU" : profile?.provider_name || p?.model?.split(":")[1]; const name = job.output?.split("/")[1] || job.name || "Annotation job"; const logs = `https://huggingface.co/jobs/${job.owner}/${job.id}`; const results = job.output && p?.completed ? `https://huggingface.co/datasets/${job.output}` : null; const annotations = p?.annotation_url; const hands = p?.hand_visualizer_url; const action = hands ? "View 3D hands" : annotations ? "Show annotations" : results ? "Results" : "Logs"; const knownCost = p?.cost?.total_usd ?? p?.cost?.cpu_usd; const incompleteCost = p?.cost && (p.cost.total_usd == null || p.cost.uncertain_inference_usd > 0.000001); return (
{name} {model && ( <> · {model} )} {state} {p?.expected ? `${p.completed.toLocaleString()} / ${p.expected.toLocaleString()} labeled` : "—"} {p?.exported != null && ( {p.exported.toLocaleString()} ready to view )} {!ended && !!p?.expected && ( )} Cost {usd(knownCost)} {incompleteCost && knownCost != null && *} e.stopPropagation()} > {action}
Model
{model ? `${model}${provider ? ` · ${provider}` : ""}` : "—"}
Episodes
{p ? `${p.completed} labeled · ${p.exported ?? 0} ready to view${p.failed ? ` · ${p.failed} failed` : ""}${p.pending ? ` · ${p.pending} pending` : ""}` : "—"}
Inference
{usd(p?.cost?.inference_usd)}
Compute
{usd(p?.cost?.cpu_usd)}
Model calls
{p?.usage.successful_calls?.toLocaleString() ?? "—"}
{p?.human_videos && (
Human videos
{(p.human_videos.completed || 0).toLocaleString()} {p.human_videos.failed ? ` · ${p.human_videos.failed} failed` : ""} {p.usage.media_usd ? ` · ${usd(p.usage.media_usd)}` : ""}
)}
{p?.subtask_views === "per-camera" && !!p.completed && ( )} {p?.subtask_views === "per-hand" && !!p.completed && ( )} {!!p?.human_videos?.completed && ( )} {p && (p.failed > 0 || (p.stopped || 0) > 0 || (p.pending || 0) > 0) && (

{[ p.failed ? `${p.failed} failed` : "", p.stopped ? `${p.stopped} stopped` : "", p.pending ? `${p.pending} not processed` : "", ] .filter(Boolean) .join(" · ")}

)} {!!p?.failed_recordings?.length && (
Failed recordings ({p.failed_recordings.length})
    {p.failed_recordings.map((r) => (
  • {r.recording}/{r.hand} {" "} · source episode {r.source_episode_index} ·{" "} {r.stage.replace(/_/g, " ")}

    {r.error.split(": {")[0]}

  • ))}
{job.output && ( Full failure report )}
)} {incompleteCost && (

{p.cost!.uncertain_inference_usd > 0.000001 ? `Unconfirmed inference: up to ${usd(p.cost!.uncertain_inference_usd)} extra.` : "Some usage has not been reported yet."}

)}
{hands && annotations && ( Language annotations )} Logs {results && ( Output files )} {p?.cost && ( Billing )} {!ended && ( )}

Usage estimates; final billing may differ.

); })}
)}
); }