Live Worker & Job Queue Panel
Background job monitor modeled on Template Factory's build workers: live UI SDK Progress bars, Running / Queued / Paused / Done / Failed badges with icons, per-job pause, resume, retry and a Cancel run that confirms in an AlertDialog, a Collapsible log per job, and a queue-wide pause.
Install UI SDK & packages
npm install @ui-sdk/react @ui-sdk/core lucide-react
Give your agent the UI SDK skill
npx skills add vercel-labs/ui --skill ui-sdk
"use client"; import * as React from "react"; import { Ban, ChevronDown, CircleCheck, CircleX, Clock, Inbox, LoaderCircle, Pause, Play, Plus, RotateCcw, TriangleAlert, X, } from "lucide-react"; import type { LucideIcon } from "lucide-react"; import { AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogTitle, } from "@ui-sdk/react/alert-dialog"; import { Button } from "@ui-sdk/react/button"; import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "@ui-sdk/react/collapsible"; import { Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue } from "@ui-sdk/react/progress"; const card = "rounded-2xl border border-[#d8e0ea] bg-white shadow-[0_18px_44px_rgba(15,23,42,0.12)] dark:border-slate-400/20 dark:bg-[#111827] dark:shadow-[0_24px_60px_rgba(0,0,0,0.5)]"; const btnBase = "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-[10px] font-bold transition hover:-translate-y-px active:translate-y-px disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-500"; const btnMd = "h-11 px-4 text-sm"; const btnRow = "h-9 px-3 text-[13px] max-sm:h-11 max-sm:flex-1"; const btnGhost = `${btnBase} border border-slate-300 bg-linear-to-b from-white to-slate-100 text-slate-900 shadow-[inset_0_1px_0_rgba(255,255,255,0.95),inset_0_-1.5px_0_rgba(15,23,42,0.08),0_1px_2px_rgba(15,23,42,0.06)] hover:border-slate-400 dark:border-slate-400/35 dark:from-[#243047] dark:to-[#182234] dark:text-slate-50 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.09),inset_0_-1.5px_0_rgba(0,0,0,0.35)] dark:hover:border-slate-400/55`; const btnDanger = `${btnBase} border border-red-200/45 bg-linear-to-b from-red-500 via-red-600 to-red-700 text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.3),inset_0_-2px_0_rgba(127,29,29,0.55),0_8px_20px_rgba(220,38,38,0.32)] hover:brightness-110 focus-visible:outline-red-400`; const btnDangerSoft = `${btnBase} border-[1.5px] border-red-300 bg-red-50 text-red-800 hover:border-red-700 hover:bg-red-600 hover:text-white dark:border-red-400/65 dark:bg-linear-to-b dark:from-red-600/30 dark:to-red-800/40 dark:text-rose-50 dark:hover:border-red-400 dark:hover:from-red-600 dark:hover:to-red-600 dark:hover:text-white focus-visible:outline-red-400`; const hairline = "border-[#d8e0ea] dark:border-slate-400/20"; const mutedText = "text-slate-600 dark:text-slate-400"; export type JobStatus = "running" | "queued" | "paused" | "done" | "failed"; export interface QueueJob { id: string; /** File or task name. Shown in monospace because it's an identifier. */ name: string; /** Which worker picked it up, like "Claude". */ worker: string; status: JobStatus; /** 0 to 100. */ progress: number; /** Short plain-language note, like "Started 2 min ago". */ detail?: string; /** Why it failed, in words a non-technical person understands. */ error?: string; log: string[]; } const STATUS_META: Record<JobStatus, { label: string; icon: LucideIcon; spin?: boolean; badge: string; bar: string }> = { running: { label: "Running", icon: LoaderCircle, spin: true, badge: "border-sky-600/35 bg-sky-50 text-sky-800 dark:border-sky-400/40 dark:bg-sky-400/15 dark:text-sky-300", bar: "bg-sky-600 dark:bg-sky-400", }, queued: { label: "Queued", icon: Clock, badge: "border-slate-300 bg-slate-50 text-slate-700 dark:border-slate-400/35 dark:bg-[#162033] dark:text-slate-200", bar: "bg-slate-400", }, paused: { label: "Paused", icon: Pause, badge: "border-amber-600/35 bg-amber-50 text-amber-800 dark:border-amber-400/45 dark:bg-amber-400/15 dark:text-amber-300", bar: "bg-amber-500 dark:bg-amber-400", }, done: { label: "Done", icon: CircleCheck, badge: "border-emerald-600/30 bg-emerald-50 text-emerald-800 dark:border-emerald-400/40 dark:bg-emerald-400/15 dark:text-emerald-300", bar: "bg-emerald-600 dark:bg-emerald-400", }, failed: { label: "Failed", icon: CircleX, badge: "border-red-600/30 bg-red-50 text-red-800 dark:border-red-400/45 dark:bg-red-400/15 dark:text-red-300", bar: "bg-red-600 dark:bg-red-400", }, }; const SAMPLE_JOBS: QueueJob[] = [ { id: "job-1", name: "saas-pricing-dark.png", worker: "Claude", status: "running", progress: 64, detail: "Started 2 min ago", log: ["09:41:02 Started on Claude", "09:41:09 Read the screenshot", "09:41:31 Drafted the page layout"] }, { id: "job-2", name: "analytics-overview.png", worker: "Codex", status: "running", progress: 21, detail: "Started just now", log: ["09:42:48 Started on Codex"] }, { id: "job-3", name: "settings-subtabs.png", worker: "Claude", status: "queued", progress: 0, detail: "Next in line", log: ["09:40:15 Added to the queue"] }, { id: "job-4", name: "broken-export.png", worker: "Claude", status: "failed", progress: 38, error: "The screenshot is too small to read (640 × 360).", log: ["09:36:20 Started on Claude", "09:36:41 Stopped: the screenshot is too small to read"] }, { id: "job-5", name: "kanban-board.png", worker: "Antigravity", status: "done", progress: 100, detail: "4 components saved", log: ["09:30:04 Started on Antigravity", "09:33:52 Finished — 4 components saved"] }, ]; const ORDER: JobStatus[] = ["running", "queued", "paused", "failed", "done"]; export function LiveWorkerQueue({ title = "Template builds", jobs = SAMPLE_JOBS, defaultQueuePaused = false, onToggleQueue, onAddJob, onPauseJob, onResumeJob, onRetryJob, onCancelJob, }: { title?: string; /** Controlled list. Update it from your polling, websocket, or server events and the bars follow. */ jobs?: QueueJob[]; defaultQueuePaused?: boolean; onToggleQueue?: (paused: boolean) => void; /** Shows an "Add build" button when provided. */ onAddJob?: () => void; onPauseJob?: (id: string) => unknown; onResumeJob?: (id: string) => unknown; onRetryJob?: (id: string) => unknown; onCancelJob?: (id: string) => unknown; }) { const [queuePaused, setQueuePaused] = React.useState(defaultQueuePaused); const [cancelOpen, setCancelOpen] = React.useState(false); const [cancelJob, setCancelJob] = React.useState<QueueJob | null>(null); const summary = ORDER.map((status) => { const count = jobs.filter((job) => job.status === status).length; return count > 0 ? `${count} ${STATUS_META[status].label.toLowerCase()}` : null; }) .filter(Boolean) .join(" · "); return ( <section aria-label={title} className={`${card} overflow-hidden`}> <div className={`flex flex-wrap items-center justify-between gap-x-4 gap-y-3 border-b px-4 py-4 sm:px-5 ${hairline}`}> <div className="min-w-0"> <h2 className="text-[17px] font-bold tracking-tight text-slate-900 dark:text-slate-50">{title}</h2> <p aria-live="polite" className={`mt-0.5 text-[12.5px] tabular-nums ${mutedText}`}> {queuePaused ? "Queue paused — running builds finish, nothing new starts. " : ""} {summary || "Nothing in the queue"} </p> </div> <div className="flex flex-wrap items-center gap-2 max-sm:w-full"> {onAddJob && ( <Button onClick={() => onAddJob()} className={`${btnGhost} ${btnRow}`}> <Plus className="size-3.5" aria-hidden="true" /> <span>Add build</span> </Button> )} <Button onClick={() => { setQueuePaused(!queuePaused); onToggleQueue?.(!queuePaused); }} className={`${btnGhost} ${btnRow}`} > {queuePaused ? <Play className="size-3.5" aria-hidden="true" /> : <Pause className="size-3.5" aria-hidden="true" />} <span>{queuePaused ? "Resume queue" : "Pause queue"}</span> </Button> </div> </div> {jobs.length === 0 ? ( <div className="flex flex-col items-center gap-2 px-5 py-10 text-center"> <Inbox className={`size-6 ${mutedText}`} aria-hidden="true" /> <p className="text-[15px] font-bold text-slate-900 dark:text-slate-50">The queue is empty</p> <p className={`text-[13px] ${mutedText}`}>New builds show up here the moment they start.</p> </div> ) : ( <ul className="m-0 list-none p-0"> {jobs.map((job) => { const meta = STATUS_META[job.status]; const StatusIcon = meta.icon; const canCancel = job.status === "running" || job.status === "queued" || job.status === "paused"; return ( <li key={job.id} className={`border-t first:border-t-0 ${hairline}`}> <Collapsible className="grid grid-cols-1 items-center gap-x-5 gap-y-2.5 px-4 py-3.5 sm:px-5 md:grid-cols-[minmax(0,1fr)_auto] lg:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_18.5rem]"> <div className="min-w-0"> <div className="flex flex-wrap items-center gap-x-2.5 gap-y-1.5"> <span className="min-w-0 truncate font-mono text-[13px] font-semibold text-slate-900 dark:text-slate-50"> {job.name} </span> <span className={`inline-flex h-[22px] items-center gap-1.5 whitespace-nowrap rounded-full border px-2 text-[11.5px] font-bold ${meta.badge}`} > <StatusIcon className={`size-3 ${meta.spin ? "animate-spin motion-reduce:animate-none" : ""}`} aria-hidden="true" /> {meta.label} </span> </div> {job.error ? ( <p className="mt-1 flex items-start gap-1.5 text-[12.5px] font-semibold text-red-800 dark:text-red-300"> <TriangleAlert className="mt-0.5 size-3.5 shrink-0" aria-hidden="true" /> <span>{job.error}</span> </p> ) : ( <p className={`mt-1 text-[12.5px] ${mutedText}`}> {job.worker} {job.detail ? ` · ${job.detail}` : ""} </p> )} </div> <Progress value={job.progress} className="flex items-center gap-3 md:max-lg:col-span-2 md:max-lg:row-start-2" > <ProgressLabel className="sr-only">{job.name} progress</ProgressLabel> <ProgressTrack className="h-2 min-w-0 flex-1 overflow-hidden rounded-full border border-[#d8e0ea] bg-slate-100 dark:border-slate-400/20 dark:bg-[#162033]"> <ProgressIndicator className={`h-full rounded-full transition-[width] duration-500 ${meta.bar}`} style={{ width: `${Math.max(0, Math.min(100, job.progress))}%` }} /> </ProgressTrack> <ProgressValue className="w-10 text-right text-[12.5px] font-semibold text-slate-900 tabular-nums dark:text-slate-50" /> </Progress> <div className="flex flex-wrap items-center gap-2 md:max-lg:col-start-2 md:max-lg:row-start-1 md:justify-end"> {job.status === "running" && ( <Button aria-label={`Pause ${job.name}`} onClick={() => onPauseJob?.(job.id)} className={`${btnGhost} ${btnRow}`}> <Pause className="size-3.5" aria-hidden="true" /> <span>Pause</span> </Button> )} {job.status === "paused" && ( <Button aria-label={`Resume ${job.name}`} onClick={() => onResumeJob?.(job.id)} className={`${btnGhost} ${btnRow}`}> <Play className="size-3.5" aria-hidden="true" /> <span>Resume</span> </Button> )} {job.status === "failed" && ( <Button aria-label={`Retry ${job.name}`} onClick={() => onRetryJob?.(job.id)} className={`${btnGhost} ${btnRow}`}> <RotateCcw className="size-3.5" aria-hidden="true" /> <span>Retry</span> </Button> )} {canCancel && ( <Button aria-label={`Cancel ${job.name}`} onClick={() => { setCancelJob(job); setCancelOpen(true); }} className={`${btnDangerSoft} ${btnRow}`} > <X className="size-3.5" aria-hidden="true" /> <span>Cancel run</span> </Button> )} <CollapsibleTrigger aria-label={`Show log for ${job.name}`} className={`${btnGhost} ${btnRow} group`}> <span>Log</span> <ChevronDown className="size-3.5 transition-transform group-data-open:rotate-180" aria-hidden="true" /> </CollapsibleTrigger> </div> <CollapsiblePanel className="col-span-full min-w-0"> <pre className="m-0 max-h-40 overflow-auto rounded-[10px] border border-[#d8e0ea] bg-slate-50 p-3 font-mono text-xs leading-relaxed text-slate-800 dark:border-slate-400/20 dark:bg-[#0b1220] dark:text-slate-200"> {job.log.join("\n")} </pre> </CollapsiblePanel> </Collapsible> </li> ); })} </ul> )} <AlertDialog open={cancelOpen} onOpenChange={setCancelOpen}> <AlertDialogBackdrop className="fixed inset-0 bg-slate-900/40 backdrop-blur-xs dark:bg-black/65" /> <AlertDialogContent className="fixed inset-0 m-auto h-fit w-[calc(100%-1.75rem)] max-w-md overflow-hidden rounded-2xl border border-slate-300 bg-white p-0 shadow-[0_24px_60px_rgba(15,23,42,0.2)] dark:border-slate-400/35 dark:bg-[#111827] dark:shadow-[0_28px_70px_rgba(0,0,0,0.62)]"> <div className="flex gap-3.5 p-5"> <span className="grid size-10 shrink-0 place-items-center rounded-xl border border-red-300 bg-red-50 text-red-700 dark:border-red-400/45 dark:bg-red-400/15 dark:text-red-300"> <TriangleAlert className="size-5" aria-hidden="true" /> </span> <div className="min-w-0"> <AlertDialogTitle className="text-[17px] font-bold tracking-tight text-slate-900 dark:text-slate-50"> Cancel this build? </AlertDialogTitle> <AlertDialogDescription className={`mt-1.5 text-[13.5px] leading-relaxed ${mutedText}`}> <span className="font-mono font-semibold text-slate-900 dark:text-slate-50">{cancelJob?.name}</span> stops at{" "} {Math.round(cancelJob?.progress ?? 0)}% and its partial files are discarded. </AlertDialogDescription> </div> </div> <div className={`flex flex-col-reverse gap-2.5 border-t bg-slate-50 px-5 py-3.5 sm:flex-row sm:justify-end dark:bg-[#162033] ${hairline}`}> <AlertDialogClose className={`${btnGhost} ${btnMd}`}>Keep running</AlertDialogClose> <AlertDialogClose value="confirm" data-agent-confirm="Stops this build and discards its partial files" onClick={() => { if (cancelJob) onCancelJob?.(cancelJob.id); }} className={`${btnDanger} ${btnMd}`} > <Ban className="size-4" aria-hidden="true" /> <span>Cancel run</span> </AlertDialogClose> </div> </AlertDialogContent> </AlertDialog> </section> ); } export default LiveWorkerQueue;
More in Dashboard & Data
Agent Approval Inbox & Slide-Over Reading Pane
MSAI one-line scannable agent inbox paired with a slide-over reading pane. Quick Approve/Skip actions live on hover in the list and stay pinned in a fixed decision footer inside the reading pane with Undo and arrow-key navigation.
KPI & Timeframe Telemetry Strip
One framed four-up metric bar (2x2 on tablet, stacked on mobile) with a UI SDK SegmentedControl timeframe switch that updates every number, icon + sign delta pills, tabular numbers, and inline sparklines.
Key-Value Detail Inspector Drawer
Slide-over UI SDK Drawer inspector: semantic <dl> metadata grid, editable status Select and notes Textarea, and a sticky footer with a tactile Copy ID button and a high-contrast Archive record button that confirms in an AlertDialog, then shows the archived state with Restore.