import { Button } from "@code/ui/components/button"; import { ArrowUpRight, Bot, ExternalLink, FileText, GitPullRequest, Layers, Radio, TriangleAlert, } from "lucide-react"; import { formatRelativeTime } from "@/lib/work-os/work-unit-projection"; import type { WorkUnitDetail as WorkUnitDetailData } from "@/lib/work-os/work-unit-projection"; const formatStatus = ( status: WorkUnitDetailData["issue"]["status"] ): string => { if (status === "needs-input") { return "Needs input"; } if (status === "working") { return "In progress"; } return status.charAt(0).toUpperCase() + status.slice(1); }; interface WorkUnitDetailProps { readonly detail: WorkUnitDetailData; readonly onOpenPullRequest: (url: string) => void; readonly onStart: () => void; readonly startPending: boolean; } const Section = ({ children, icon, title, }: { readonly children: React.ReactNode; readonly icon: React.ReactNode; readonly title: string; }) => (
{icon} {title}
{children}
); export const WorkUnitDetail = ({ detail, onOpenPullRequest, onStart, startPending, }: WorkUnitDetailProps) => { const { issue } = detail; const canStart = issue.status === "open" || issue.status === "failed"; return (
{/* Objective */}

Work Unit #{issue.number}

{issue.title}

{formatStatus(issue.status)}

{issue.body}

{canStart ? ( ) : null}
{/* Needs input alert */} {detail.needsInput ? (

This work unit needs your input

Resolve the open question or decision to unblock the agent.

) : null} {/* Latest summary */} {detail.latestSummary ? (
} title="Latest">

{detail.latestSummary}

) : null} {/* Linked Signals — authenticated via signalIssueAttachments */}
} title={`Signals (${detail.signalCount})`} > {detail.linkedSignals.length > 0 ? (
{detail.linkedSignals.map((signal) => (

{signal.title}

{signal.summary}

{signal.sourceCount} source {signal.sourceCount === 1 ? "" : "s"} ·{" "} {formatRelativeTime(signal.createdAt)}

))}
) : (

No Signals linked to this Work Unit.

)}
{/* Activity timeline */}
} title={`Timeline (${detail.stepCount} steps)`} > {detail.activity.length > 0 ? (
{detail.activity.map((item) => (

{item.label}

{item.detail}

{item.time}

))}
) : (

No activity recorded yet.

)}
{/* Artifacts */}
} title={`Artifacts (${detail.artifactCount})`} > {detail.artifactPaths.length > 0 ? (
{detail.artifactPaths.map((path) => ( {path} ))}
) : (

No artifacts produced yet.

)}
{/* Pull request */} {detail.hasPullRequest ? (
} title="Pull request" > {detail.pullRequestUrl ? (

{detail.pullRequestNumber ? `PR #${detail.pullRequestNumber} ready for review` : "Pull request ready"}

) : (

A pull request was opened but the URL is unavailable.

)}
) : null}
); };