Files
PaperClipAI/ui/src/components/issue-output/IssueOutputSection.tsx
T
DottaandPaperclip 96d266109b Add issue Output UI for artifact playback (PAP-10168)
Surface attachment-backed artifact work products as a first-class
Output section on the issue detail page so cloud users can watch and
download agent-generated videos without host filesystem access.

- ui/src/lib/issue-output.ts: formatBytes/formatDuration/getOutputFileGlyph
  helpers + getIssueOutputs selector that validates the Phase-2 attachment
  artifact metadata contract and tolerates malformed metadata (degraded).
- issue-output components: IssueOutputSection, OutputPrimaryCard (native
  <video>/image/generic), OutputRow, OutputVideoPlayer, OutputFileTile.
- IssueDetail: fetch work products and render the Output section between
  Documents and Attachments; reuse formatBytes in the attachments list.
- DesignGuide: showcase multiple-output, degraded, and empty states.
- Focused tests for video output, empty state, multiple outputs, and
  failed attachment metadata (15 tests).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-30 20:40:35 +00:00

50 lines
1.9 KiB
TypeScript

import { Play } from "lucide-react";
import type { IssueWorkProduct } from "@paperclipai/shared";
import { getIssueOutputs, type IssueOutputItem } from "@/lib/issue-output";
import { OutputPrimaryCard } from "./OutputPrimaryCard";
import { OutputRow } from "./OutputRow";
interface IssueOutputSectionProps {
workProducts: IssueWorkProduct[] | null | undefined;
/** Optional resolver for the artifact creator's display name. */
resolveCreatorName?: (item: IssueOutputItem) => string | null;
}
/**
* Issue Output surface (PAP-10162 Phase 3).
*
* Renders attachment-backed artifact work products as first-class issue
* outputs: a full-width primary card (video player / image / generic file) with
* Open + Download, plus compact rows for any additional outputs. The section is
* omitted entirely when the issue has produced no outputs — we never show a
* permanent empty card.
*/
export function IssueOutputSection({ workProducts, resolveCreatorName }: IssueOutputSectionProps) {
const { primary, rest, count } = getIssueOutputs(workProducts);
if (!primary) return null;
const creatorFor = (item: IssueOutputItem) => resolveCreatorName?.(item) ?? null;
return (
<section className="space-y-3" aria-label="Issue outputs">
<div className="flex items-center gap-2">
<Play className="h-3.5 w-3.5 text-muted-foreground" aria-hidden="true" />
<h3 className="text-sm font-medium text-muted-foreground">Output</h3>
<span className="text-xs text-muted-foreground">{count}</span>
</div>
<OutputPrimaryCard item={primary} creatorName={creatorFor(primary)} />
{rest.length > 0 && (
<div className="space-y-2">
<p className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">Also produced</p>
{rest.map((item) => (
<OutputRow key={item.id} item={item} creatorName={creatorFor(item)} />
))}
</div>
)}
</section>
);
}