import type { IssueRelatedWorkItem, IssueRelatedWorkSummary } from "@paperclipai/shared"; import { IssueReferencePill } from "./IssueReferencePill"; type GroupedSource = { label: string; count: number; sampleMatchedText: string | null; }; function groupSourcesByLabel(sources: IssueRelatedWorkItem["sources"]): GroupedSource[] { const groups = new Map(); for (const source of sources) { const existing = groups.get(source.label); if (existing) { existing.count += 1; } else { groups.set(source.label, { label: source.label, count: 1, sampleMatchedText: source.matchedText ?? null, }); } } return Array.from(groups.values()); } function Section({ title, description, items, emptyLabel, }: { title: string; description: string; items: IssueRelatedWorkItem[]; emptyLabel: string; }) { return (

{title}

{description}

{items.length === 0 ? (

{emptyLabel}

) : ( )}
); } export function IssueRelatedWorkPanel({ relatedWork, }: { relatedWork?: IssueRelatedWorkSummary | null; }) { const outbound = relatedWork?.outbound ?? []; const inbound = relatedWork?.inbound ?? []; return (
); }