import { useState } from 'react'; import { Checkbox } from '@/components/ui/checkbox'; import { Label } from '@/components/ui/label'; import { Button } from '@/components/ui/button'; import { ChevronDown, ChevronRight, Users, CheckCircle2 } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { AncestorContext } from '@automaker/dependency-resolver'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; interface ParentFeatureContext { id: string; title?: string; description: string; spec?: string; summary?: string; } interface AncestorContextSectionProps { parentFeature: ParentFeatureContext; ancestors: AncestorContext[]; selectedAncestorIds: Set; onSelectionChange: (ids: Set) => void; } export function AncestorContextSection({ parentFeature, ancestors, selectedAncestorIds, onSelectionChange, }: AncestorContextSectionProps) { const [expandedIds, setExpandedIds] = useState>(new Set()); const toggleExpanded = (id: string) => { const newExpanded = new Set(expandedIds); if (newExpanded.has(id)) { newExpanded.delete(id); } else { newExpanded.add(id); } setExpandedIds(newExpanded); }; const toggleSelected = (id: string) => { const newSelected = new Set(selectedAncestorIds); if (newSelected.has(id)) { newSelected.delete(id); } else { newSelected.add(id); } onSelectionChange(newSelected); }; const selectAll = () => { const allIds = new Set([parentFeature.id, ...ancestors.map((a) => a.id)]); onSelectionChange(allIds); }; const selectNone = () => { onSelectionChange(new Set()); }; // Combine parent and ancestors into a single list const allAncestorItems: Array< (AncestorContext | ParentFeatureContext) & { isParent: boolean; depth: number } > = [ { ...parentFeature, depth: -1, isParent: true }, ...ancestors.map((a) => ({ ...a, isParent: false })), ]; const totalCount = allAncestorItems.length; return (
({selectedAncestorIds.size}/{totalCount} selected)

The parent task context will be included to help the AI understand the background. Additional ancestors can optionally be included for more context.

{allAncestorItems.map((item) => { const isSelected = selectedAncestorIds.has(item.id); const isExpanded = expandedIds.has(item.id); const hasContent = item.description || ('spec' in item && item.spec) || ('summary' in item && item.summary); const displayTitle = item.title || item.description.slice(0, 50) + (item.description.length > 50 ? '...' : ''); return (
toggleSelected(item.id)} className="mt-0.5" />
{hasContent && ( )} {item.isParent && ( Completed Parent )}
{item.description && (
Description:

{item.description}

)} {'spec' in item && item.spec && (
Specification:

{item.spec}

)} {'summary' in item && item.summary && (
Summary:

{item.summary}

)}
); })} {ancestors.length === 0 && (

Parent task has no additional ancestors

)}
); }