// Wire status comes from Python's Status enum: lowercase strings // ("archived", "pending", "merged", "superseded"). CURRENT rows are omitted from JSON entirely // (response_model_exclude_none) and arrive as `null`/undefined. // Normalize to the uppercase label the dashboard renders. export type StatusLabel = | "CURRENT" | "ARCHIVED" | "PENDING" | "MERGED" | "SUPERSEDED"; export type AgentPlaybookStatusLabel = "PENDING" | "APPROVED" | "REJECTED"; export function statusLabel(p: { status?: string | null }): StatusLabel { if (!p.status) return "CURRENT"; const s = String(p.status).toLowerCase(); if (s === "archived") return "ARCHIVED"; if (s === "pending") return "PENDING"; if (s === "merged") return "MERGED"; if (s === "superseded") return "SUPERSEDED"; return "CURRENT"; } export function agentPlaybookStatusLabel(p: { playbook_status?: string | null; }): AgentPlaybookStatusLabel { const s = String(p.playbook_status ?? "pending").toLowerCase(); if (s === "approved") return "APPROVED"; if (s === "rejected") return "REJECTED"; return "PENDING"; }