// Processing Queue view — live scan progress per step. "use client"; import { useQuery } from "@tanstack/react-query"; import { Card } from "@/components/ui/card"; import { Progress } from "@/components/ui/progress"; import { Badge } from "@/components/ui/badge"; import { Radio, Clock, CheckCircle2, AlertTriangle, ListChecks, History, } from "lucide-react"; import { useAppStore } from "@/lib/store"; import { SourceBadge } from "@/components/shared/badges"; import type { QueueItemView } from "@/lib/types"; const STEP_LABELS: Record = { metadata: "Container Metadata", filename: "Filename Intelligence", stream: "Stream Analysis", alpha: "Alpha Channel", mask: "Mask Track", frame: "Frame Analysis", depth: "Depth Detection", classify: "Classification", }; export function QueueView() { const setView = useAppStore((s) => s.setView); const queueQ = useQuery({ queryKey: ["queue"], queryFn: async () => { const res = await fetch("/api/queue"); if (!res.ok) throw new Error("queue fetch failed"); return res.json() as Promise<{ active: QueueItemView[]; recentlyDone: { id: string; videoId: string; videoName: string; finishedAt: string | null }[]; recentErrors: { id: string; videoId: string; videoName: string; errorMessage: string | null; finishedAt: string | null }[]; totals: { queued: number; running: number }; }>; }, refetchInterval: 1500, }); const q = queueQ.data; return (
{/* Summary cards */}
Running
{q?.totals?.running ?? 0}
Queued
{q?.totals?.queued ?? 0}
Recently Done
{q?.recentlyDone?.length ?? 0}
Errors
{q?.recentErrors?.length ?? 0}
{/* Active queue */}

Active Queue

{q?.active?.length === 0 ? (
Queue is empty. Trigger a scan from the top bar.
) : (
{q?.active?.map((item) => (
Started: {item.startedAt ? new Date(item.startedAt).toLocaleTimeString() : "—"}
{item.status}
{item.steps.map((step) => (
{step.label.split(" ")[0]}
{step.status}
))}
))}
)}
{/* Recent activity */}

Recently Completed

{q?.recentlyDone?.length === 0 ? (
No completed scans yet.
) : (
{q?.recentlyDone?.map((item) => (
{item.finishedAt ? new Date(item.finishedAt).toLocaleTimeString() : "—"}
))}
)}

Recent Errors

{q?.recentErrors?.length === 0 ? (
No errors. All good.
) : (
{q?.recentErrors?.map((item) => (
{item.errorMessage}
))}
)}
); }