mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
feat: Add task dependencies and spawn sub-task functionality
- Add edge dragging to create dependencies in graph view - Add spawn sub-task action available in graph view and kanban board - Implement ancestor context selection when spawning tasks - Add dependency validation (circular, self, duplicate prevention) - Include ancestor context in spawned task descriptions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
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 } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { AncestorContext } from '@/components/views/graph-view/utils';
|
||||
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<string>;
|
||||
onSelectionChange: (ids: Set<string>) => void;
|
||||
}
|
||||
|
||||
export function AncestorContextSection({
|
||||
parentFeature,
|
||||
ancestors,
|
||||
selectedAncestorIds,
|
||||
onSelectionChange,
|
||||
}: AncestorContextSectionProps) {
|
||||
const [expandedIds, setExpandedIds] = useState<Set<string>>(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 (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<Users className="w-4 h-4 text-muted-foreground" />
|
||||
<Label className="text-sm font-medium">Ancestor Context</Label>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
({selectedAncestorIds.size}/{totalCount} selected)
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={selectAll}
|
||||
className="h-6 px-2 text-xs"
|
||||
>
|
||||
All
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={selectNone}
|
||||
className="h-6 px-2 text-xs"
|
||||
>
|
||||
None
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Select ancestors to include their context in the new task's prompt.
|
||||
</p>
|
||||
|
||||
<div className="space-y-1 max-h-[200px] overflow-y-auto border rounded-lg p-2 bg-muted/20">
|
||||
{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 (
|
||||
<Collapsible key={item.id} open={isExpanded}>
|
||||
<div
|
||||
className={cn(
|
||||
'flex items-start gap-2 p-2 rounded-md transition-colors',
|
||||
isSelected ? 'bg-primary/10' : 'hover:bg-muted/50'
|
||||
)}
|
||||
style={{ marginLeft: item.isParent ? 0 : `${item.depth * 12}px` }}
|
||||
>
|
||||
<Checkbox
|
||||
id={`ancestor-${item.id}`}
|
||||
checked={isSelected}
|
||||
onCheckedChange={() => toggleSelected(item.id)}
|
||||
className="mt-0.5"
|
||||
/>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-1">
|
||||
{hasContent && (
|
||||
<CollapsibleTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-5 w-5 p-0"
|
||||
onClick={() => toggleExpanded(item.id)}
|
||||
>
|
||||
{isExpanded ? (
|
||||
<ChevronDown className="w-3 h-3" />
|
||||
) : (
|
||||
<ChevronRight className="w-3 h-3" />
|
||||
)}
|
||||
</Button>
|
||||
</CollapsibleTrigger>
|
||||
)}
|
||||
<label
|
||||
htmlFor={`ancestor-${item.id}`}
|
||||
className="text-sm font-medium cursor-pointer truncate flex-1"
|
||||
>
|
||||
{displayTitle}
|
||||
{item.isParent && (
|
||||
<span className="ml-2 text-xs text-primary font-normal">(Parent)</span>
|
||||
)}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<CollapsibleContent>
|
||||
<div className="mt-2 space-y-2 text-xs text-muted-foreground pl-5">
|
||||
{item.description && (
|
||||
<div>
|
||||
<span className="font-medium text-foreground">Description:</span>
|
||||
<p className="mt-0.5 line-clamp-3">{item.description}</p>
|
||||
</div>
|
||||
)}
|
||||
{'spec' in item && item.spec && (
|
||||
<div>
|
||||
<span className="font-medium text-foreground">Specification:</span>
|
||||
<p className="mt-0.5 line-clamp-3">{item.spec}</p>
|
||||
</div>
|
||||
)}
|
||||
{'summary' in item && item.summary && (
|
||||
<div>
|
||||
<span className="font-medium text-foreground">Summary:</span>
|
||||
<p className="mt-0.5 line-clamp-3">{item.summary}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</div>
|
||||
</div>
|
||||
</Collapsible>
|
||||
);
|
||||
})}
|
||||
|
||||
{ancestors.length === 0 && (
|
||||
<p className="text-xs text-muted-foreground text-center py-2">
|
||||
Parent task has no additional ancestors
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -6,3 +6,4 @@ export * from './testing-tab-content';
|
||||
export * from './priority-selector';
|
||||
export * from './branch-selector';
|
||||
export * from './planning-mode-selector';
|
||||
export * from './ancestor-context-section';
|
||||
|
||||
Reference in New Issue
Block a user