mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
refactor: streamline feature implementation handling in BoardView and KanbanCard
- Introduced a helper function, handleStartImplementation, to manage concurrency checks and feature status updates when moving features from backlog to in_progress. - Simplified the onImplement callback in KanbanCard to utilize the new helper function, enhancing code readability and maintainability. - Removed redundant concurrency checks from multiple locations, centralizing the logic for better consistency and reducing code duplication.
This commit is contained in:
@@ -849,34 +849,12 @@ export function BoardView() {
|
|||||||
// Same column, nothing to do
|
// Same column, nothing to do
|
||||||
if (targetStatus === draggedFeature.status) return;
|
if (targetStatus === draggedFeature.status) return;
|
||||||
|
|
||||||
// Check concurrency limit before moving to in_progress (only for backlog -> in_progress and if running agent)
|
|
||||||
if (
|
|
||||||
targetStatus === "in_progress" &&
|
|
||||||
draggedFeature.status === "backlog" &&
|
|
||||||
!autoMode.canStartNewTask
|
|
||||||
) {
|
|
||||||
console.log("[Board] Cannot start new task - at max concurrency limit");
|
|
||||||
toast.error("Concurrency limit reached", {
|
|
||||||
description: `You can only have ${autoMode.maxConcurrency} task${
|
|
||||||
autoMode.maxConcurrency > 1 ? "s" : ""
|
|
||||||
} running at a time. Wait for a task to complete or increase the limit.`,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle different drag scenarios
|
// Handle different drag scenarios
|
||||||
if (draggedFeature.status === "backlog") {
|
if (draggedFeature.status === "backlog") {
|
||||||
// From backlog
|
// From backlog
|
||||||
if (targetStatus === "in_progress") {
|
if (targetStatus === "in_progress") {
|
||||||
// Update with startedAt timestamp
|
// Use helper function to handle concurrency check and start implementation
|
||||||
const updates = {
|
await handleStartImplementation(draggedFeature);
|
||||||
status: targetStatus,
|
|
||||||
startedAt: new Date().toISOString(),
|
|
||||||
};
|
|
||||||
updateFeature(featureId, updates);
|
|
||||||
persistFeatureUpdate(featureId, updates);
|
|
||||||
console.log("[Board] Feature moved to in_progress, starting agent...");
|
|
||||||
await handleRunFeature(draggedFeature);
|
|
||||||
} else {
|
} else {
|
||||||
moveFeature(featureId, targetStatus);
|
moveFeature(featureId, targetStatus);
|
||||||
persistFeatureUpdate(featureId, { status: targetStatus });
|
persistFeatureUpdate(featureId, { status: targetStatus });
|
||||||
@@ -1149,6 +1127,28 @@ export function BoardView() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper function to start implementing a feature (from backlog to in_progress)
|
||||||
|
const handleStartImplementation = async (feature: Feature) => {
|
||||||
|
if (!autoMode.canStartNewTask) {
|
||||||
|
toast.error("Concurrency limit reached", {
|
||||||
|
description: `You can only have ${autoMode.maxConcurrency} task${
|
||||||
|
autoMode.maxConcurrency > 1 ? "s" : ""
|
||||||
|
} running at a time. Wait for a task to complete or increase the limit.`,
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const updates = {
|
||||||
|
status: "in_progress" as const,
|
||||||
|
startedAt: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
updateFeature(feature.id, updates);
|
||||||
|
persistFeatureUpdate(feature.id, updates);
|
||||||
|
console.log("[Board] Feature moved to in_progress, starting agent...");
|
||||||
|
await handleRunFeature(feature);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
const handleVerifyFeature = async (feature: Feature) => {
|
const handleVerifyFeature = async (feature: Feature) => {
|
||||||
if (!currentProject) return;
|
if (!currentProject) return;
|
||||||
|
|
||||||
@@ -2187,30 +2187,9 @@ export function BoardView() {
|
|||||||
onComplete={() =>
|
onComplete={() =>
|
||||||
handleCompleteFeature(feature)
|
handleCompleteFeature(feature)
|
||||||
}
|
}
|
||||||
onImplement={async () => {
|
onImplement={() =>
|
||||||
// Check concurrency limit
|
handleStartImplementation(feature)
|
||||||
if (!autoMode.canStartNewTask) {
|
}
|
||||||
toast.error("Concurrency limit reached", {
|
|
||||||
description: `You can only have ${
|
|
||||||
autoMode.maxConcurrency
|
|
||||||
} task${
|
|
||||||
autoMode.maxConcurrency > 1 ? "s" : ""
|
|
||||||
} running at a time. Wait for a task to complete or increase the limit.`,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Update with startedAt timestamp
|
|
||||||
const updates = {
|
|
||||||
status: "in_progress" as const,
|
|
||||||
startedAt: new Date().toISOString(),
|
|
||||||
};
|
|
||||||
updateFeature(feature.id, updates);
|
|
||||||
persistFeatureUpdate(feature.id, updates);
|
|
||||||
console.log(
|
|
||||||
"[Board] Feature moved to in_progress via Implement button, starting agent..."
|
|
||||||
);
|
|
||||||
await handleRunFeature(feature);
|
|
||||||
}}
|
|
||||||
hasContext={featuresWithContext.has(feature.id)}
|
hasContext={featuresWithContext.has(feature.id)}
|
||||||
isCurrentAutoTask={runningAutoTasks.includes(
|
isCurrentAutoTask={runningAutoTasks.includes(
|
||||||
feature.id
|
feature.id
|
||||||
@@ -2376,9 +2355,9 @@ export function BoardView() {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
onClick={() => {
|
onClick={async () => {
|
||||||
if (deleteCompletedFeature) {
|
if (deleteCompletedFeature) {
|
||||||
handleDeleteFeature(deleteCompletedFeature.id);
|
await handleDeleteFeature(deleteCompletedFeature.id);
|
||||||
setDeleteCompletedFeature(null);
|
setDeleteCompletedFeature(null);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -549,102 +549,64 @@ export const KanbanCard = memo(function KanbanCard({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!isCurrentAutoTask && feature.status === "waiting_approval" && (
|
{!isCurrentAutoTask &&
|
||||||
<div className="absolute top-2 right-2 flex items-center gap-1">
|
(feature.status === "waiting_approval" ||
|
||||||
<Button
|
feature.status === "verified") && (
|
||||||
variant="ghost"
|
<div className="absolute top-2 right-2 flex items-center gap-1">
|
||||||
size="sm"
|
|
||||||
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-foreground"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onEdit();
|
|
||||||
}}
|
|
||||||
onPointerDown={(e) => e.stopPropagation()}
|
|
||||||
data-testid={`edit-waiting-${feature.id}`}
|
|
||||||
title="Edit"
|
|
||||||
>
|
|
||||||
<Edit className="w-4 h-4" />
|
|
||||||
</Button>
|
|
||||||
{onViewOutput && (
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-foreground"
|
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-foreground"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onViewOutput();
|
onEdit();
|
||||||
}}
|
}}
|
||||||
onPointerDown={(e) => e.stopPropagation()}
|
onPointerDown={(e) => e.stopPropagation()}
|
||||||
data-testid={`logs-waiting-${feature.id}`}
|
data-testid={`edit-${
|
||||||
title="Logs"
|
feature.status === "waiting_approval" ? "waiting" : "verified"
|
||||||
|
}-${feature.id}`}
|
||||||
|
title="Edit"
|
||||||
>
|
>
|
||||||
<FileText className="w-4 h-4" />
|
<Edit className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
{onViewOutput && (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-destructive"
|
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-foreground"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
handleDeleteClick(e);
|
onViewOutput();
|
||||||
}}
|
}}
|
||||||
onPointerDown={(e) => e.stopPropagation()}
|
onPointerDown={(e) => e.stopPropagation()}
|
||||||
data-testid={`delete-waiting-${feature.id}`}
|
data-testid={`logs-${
|
||||||
title="Delete"
|
feature.status === "waiting_approval"
|
||||||
>
|
? "waiting"
|
||||||
<Trash2 className="w-4 h-4" />
|
: "verified"
|
||||||
</Button>
|
}-${feature.id}`}
|
||||||
</div>
|
title="Logs"
|
||||||
)}
|
>
|
||||||
{!isCurrentAutoTask && feature.status === "verified" && (
|
<FileText className="w-4 h-4" />
|
||||||
<div className="absolute top-2 right-2 flex items-center gap-1">
|
</Button>
|
||||||
<Button
|
)}
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-foreground"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onEdit();
|
|
||||||
}}
|
|
||||||
onPointerDown={(e) => e.stopPropagation()}
|
|
||||||
data-testid={`edit-verified-${feature.id}`}
|
|
||||||
title="Edit"
|
|
||||||
>
|
|
||||||
<Edit className="w-4 h-4" />
|
|
||||||
</Button>
|
|
||||||
{onViewOutput && (
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-foreground"
|
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-destructive"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onViewOutput();
|
handleDeleteClick(e);
|
||||||
}}
|
}}
|
||||||
onPointerDown={(e) => e.stopPropagation()}
|
onPointerDown={(e) => e.stopPropagation()}
|
||||||
data-testid={`logs-verified-${feature.id}`}
|
data-testid={`delete-${
|
||||||
title="Logs"
|
feature.status === "waiting_approval" ? "waiting" : "verified"
|
||||||
|
}-${feature.id}`}
|
||||||
|
title="Delete"
|
||||||
>
|
>
|
||||||
<FileText className="w-4 h-4" />
|
<Trash2 className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
</div>
|
||||||
<Button
|
)}
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="h-6 w-6 p-0 hover:bg-white/10 text-muted-foreground hover:text-destructive"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
handleDeleteClick(e);
|
|
||||||
}}
|
|
||||||
onPointerDown={(e) => e.stopPropagation()}
|
|
||||||
data-testid={`delete-verified-${feature.id}`}
|
|
||||||
title="Delete"
|
|
||||||
>
|
|
||||||
<Trash2 className="w-4 h-4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{!isCurrentAutoTask && feature.status === "in_progress" && (
|
{!isCurrentAutoTask && feature.status === "in_progress" && (
|
||||||
<div className="absolute top-2 right-2">
|
<div className="absolute top-2 right-2">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
|
|||||||
Reference in New Issue
Block a user