import { Clock3 } from "lucide-react"; import type { CaseDetail, CaseHandoffView } from "@/api/cases"; import { AgentIdentity } from "@/components/AgentIdentity"; import type { AvatarAgent } from "@/components/AgentAvatar"; import { IssueReferencePill } from "@/components/IssueReferencePill"; import { IssueStatusBadge } from "@/components/StatusBadge"; import { PropertyRow } from "@/components/issue-properties/primitives"; export type CaseAgentMap = ReadonlyMap; export function CaseWorkSummary({ caseData, pendingHandoff, agents }: { caseData: CaseDetail; pendingHandoff?: CaseHandoffView | null; agents?: CaseAgentMap; }) { const task = caseData.workIssue; const pending = pendingHandoff === undefined ? caseData.pendingHandoff : pendingHandoff; const assignee = task?.assigneeAgentId ? agents?.get(task.assigneeAgentId) ?? { id: task.assigneeAgentId, name: task.assigneeAgentName ?? "Agent", } : null; const from = pending?.fromAgentId ? agents?.get(pending.fromAgentId)?.name ?? pending.fromAgentName ?? "the previous agent" : "the previous agent"; const to = pending ? (pending.toAgentId ? agents?.get(pending.toAgentId)?.name : null) ?? pending.toAgentName ?? "the receiving agent" : null; const destination = pending?.toAgentId ? agents?.get(pending.toAgentId) : null; const waiting = pending?.destinationKind === "done" ? "Case will close when the task is complete." : pending?.lastError ?? (pending?.state === "awaiting_release" ? `Waiting for ${from} to finish.` : destination?.status === "paused" ? `${to} is paused.` : `Waiting for ${to} to start.`); return

Work

{caseData.workIssueId ?
{task ?
{caseData.workflow?.name ?? "Case instructions"} {caseData.phase && {caseData.phase}} {assignee ? : Unassigned}
:

The primary task is unavailable.

} {pending && pending.state !== "delivered" && pending.state !== "completed" && pending.state !== "cancelled" &&
{pending.state === "awaiting_release" &&

Next: {pending.workflowTransition?.to.name ?? "Case instructions"} ยท {pending.phase}

}

{waiting}

}
:

No task linked

}
; }