2025-06-16 20:23:57 -04:00
|
|
|
import { useState, useEffect } from "react";
|
|
|
|
|
import { Card, CardContent } from "@/components/ui/card";
|
2025-06-16 16:16:42 -04:00
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogHeader,
|
2025-06-16 20:23:57 -04:00
|
|
|
DialogTitle,
|
|
|
|
|
} from "@/components/ui/dialog";
|
|
|
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
|
|
|
import {
|
|
|
|
|
Select,
|
|
|
|
|
SelectContent,
|
|
|
|
|
SelectItem,
|
|
|
|
|
SelectTrigger,
|
|
|
|
|
SelectValue,
|
|
|
|
|
} from "@/components/ui/select";
|
|
|
|
|
import { Separator } from "@/components/ui/separator";
|
2025-06-17 14:17:31 -04:00
|
|
|
import { makeRequest } from "@/lib/api";
|
2025-06-16 20:23:57 -04:00
|
|
|
import type {
|
|
|
|
|
TaskStatus,
|
|
|
|
|
TaskAttempt,
|
|
|
|
|
TaskAttemptActivity,
|
2025-06-19 11:09:32 -04:00
|
|
|
TaskAttemptStatus,
|
2025-06-16 20:23:57 -04:00
|
|
|
} from "shared/types";
|
2025-06-16 16:16:42 -04:00
|
|
|
|
|
|
|
|
interface Task {
|
2025-06-16 20:23:57 -04:00
|
|
|
id: string;
|
|
|
|
|
project_id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
description: string | null;
|
|
|
|
|
status: TaskStatus;
|
|
|
|
|
created_at: string;
|
|
|
|
|
updated_at: string;
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ApiResponse<T> {
|
2025-06-16 20:23:57 -04:00
|
|
|
success: boolean;
|
|
|
|
|
data: T | null;
|
|
|
|
|
message: string | null;
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface TaskDetailsDialogProps {
|
2025-06-16 20:23:57 -04:00
|
|
|
isOpen: boolean;
|
|
|
|
|
onOpenChange: (open: boolean) => void;
|
|
|
|
|
task: Task | null;
|
|
|
|
|
projectId: string;
|
|
|
|
|
onError: (error: string) => void;
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const statusLabels: Record<TaskStatus, string> = {
|
2025-06-16 20:23:57 -04:00
|
|
|
todo: "To Do",
|
|
|
|
|
inprogress: "In Progress",
|
|
|
|
|
inreview: "In Review",
|
|
|
|
|
done: "Done",
|
|
|
|
|
cancelled: "Cancelled",
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-19 11:09:32 -04:00
|
|
|
const getAttemptStatusDisplay = (status: TaskAttemptStatus): { label: string; className: string } => {
|
|
|
|
|
switch (status) {
|
|
|
|
|
case "setuprunning":
|
2025-06-20 16:20:22 +01:00
|
|
|
return { label: "Setup Running", className: "bg-status-running text-status-running-foreground" };
|
2025-06-19 11:09:32 -04:00
|
|
|
case "setupcomplete":
|
2025-06-20 16:20:22 +01:00
|
|
|
return { label: "Setup Complete", className: "bg-status-complete text-status-complete-foreground" };
|
2025-06-19 11:09:32 -04:00
|
|
|
case "setupfailed":
|
2025-06-20 16:20:22 +01:00
|
|
|
return { label: "Setup Failed", className: "bg-status-failed text-status-failed-foreground" };
|
2025-06-19 11:09:32 -04:00
|
|
|
case "executorrunning":
|
2025-06-20 16:20:22 +01:00
|
|
|
return { label: "Executor Running", className: "bg-status-running text-status-running-foreground" };
|
2025-06-19 11:09:32 -04:00
|
|
|
case "executorcomplete":
|
2025-06-20 16:20:22 +01:00
|
|
|
return { label: "Executor Complete", className: "bg-status-complete text-status-complete-foreground" };
|
2025-06-19 11:09:32 -04:00
|
|
|
case "executorfailed":
|
2025-06-20 16:20:22 +01:00
|
|
|
return { label: "Executor Failed", className: "bg-status-failed text-status-failed-foreground" };
|
2025-06-19 11:09:32 -04:00
|
|
|
default:
|
2025-06-20 16:20:22 +01:00
|
|
|
return { label: "Unknown", className: "bg-status-init text-status-init-foreground" };
|
2025-06-19 11:09:32 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-16 20:23:57 -04:00
|
|
|
export function TaskDetailsDialog({
|
|
|
|
|
isOpen,
|
|
|
|
|
onOpenChange,
|
|
|
|
|
task,
|
|
|
|
|
projectId,
|
|
|
|
|
onError,
|
|
|
|
|
}: TaskDetailsDialogProps) {
|
|
|
|
|
const [taskAttempts, setTaskAttempts] = useState<TaskAttempt[]>([]);
|
|
|
|
|
const [taskAttemptsLoading, setTaskAttemptsLoading] = useState(false);
|
|
|
|
|
const [selectedAttempt, setSelectedAttempt] = useState<TaskAttempt | null>(
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
const [attemptActivities, setAttemptActivities] = useState<
|
|
|
|
|
TaskAttemptActivity[]
|
|
|
|
|
>([]);
|
|
|
|
|
const [activitiesLoading, setActivitiesLoading] = useState(false);
|
2025-06-17 20:59:15 -04:00
|
|
|
const [selectedExecutor, setSelectedExecutor] = useState<string>("claude");
|
2025-06-16 20:23:57 -04:00
|
|
|
const [creatingAttempt, setCreatingAttempt] = useState(false);
|
2025-06-16 20:45:34 -04:00
|
|
|
const [stoppingAttempt, setStoppingAttempt] = useState(false);
|
2025-06-16 16:16:42 -04:00
|
|
|
|
2025-06-16 20:23:57 -04:00
|
|
|
// Edit mode state
|
|
|
|
|
const [isEditMode, setIsEditMode] = useState(false);
|
|
|
|
|
const [editedTitle, setEditedTitle] = useState("");
|
|
|
|
|
const [editedDescription, setEditedDescription] = useState("");
|
|
|
|
|
const [editedStatus, setEditedStatus] = useState<TaskStatus>("todo");
|
|
|
|
|
const [savingTask, setSavingTask] = useState(false);
|
2025-06-16 16:16:42 -04:00
|
|
|
|
2025-06-19 11:09:32 -04:00
|
|
|
// Check if the selected attempt is active (not in a final state)
|
2025-06-18 00:17:06 -04:00
|
|
|
const isAttemptRunning =
|
|
|
|
|
selectedAttempt &&
|
|
|
|
|
attemptActivities.length > 0 &&
|
2025-06-21 20:04:15 +01:00
|
|
|
(attemptActivities[0].status === "setuprunning" ||
|
2025-06-19 11:09:32 -04:00
|
|
|
attemptActivities[0].status === "setupcomplete" ||
|
|
|
|
|
attemptActivities[0].status === "executorrunning");
|
2025-06-16 20:45:34 -04:00
|
|
|
|
2025-06-16 16:16:42 -04:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (isOpen && task) {
|
2025-06-16 20:48:12 -04:00
|
|
|
// Reset attempt-related state when switching tasks
|
|
|
|
|
setSelectedAttempt(null);
|
|
|
|
|
setAttemptActivities([]);
|
|
|
|
|
setActivitiesLoading(false);
|
2025-06-18 00:17:06 -04:00
|
|
|
|
2025-06-16 20:23:57 -04:00
|
|
|
fetchTaskAttempts(task.id);
|
|
|
|
|
// Initialize edit state with current task values
|
|
|
|
|
setEditedTitle(task.title);
|
|
|
|
|
setEditedDescription(task.description || "");
|
|
|
|
|
setEditedStatus(task.status);
|
|
|
|
|
setIsEditMode(false);
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
2025-06-16 20:23:57 -04:00
|
|
|
}, [isOpen, task]);
|
2025-06-16 16:16:42 -04:00
|
|
|
|
|
|
|
|
const fetchTaskAttempts = async (taskId: string) => {
|
|
|
|
|
try {
|
2025-06-16 20:23:57 -04:00
|
|
|
setTaskAttemptsLoading(true);
|
2025-06-17 14:17:31 -04:00
|
|
|
const response = await makeRequest(
|
2025-06-16 20:23:57 -04:00
|
|
|
`/api/projects/${projectId}/tasks/${taskId}/attempts`
|
|
|
|
|
);
|
|
|
|
|
|
2025-06-16 16:16:42 -04:00
|
|
|
if (response.ok) {
|
2025-06-16 20:23:57 -04:00
|
|
|
const result: ApiResponse<TaskAttempt[]> = await response.json();
|
2025-06-16 16:16:42 -04:00
|
|
|
if (result.success && result.data) {
|
2025-06-16 20:23:57 -04:00
|
|
|
setTaskAttempts(result.data);
|
2025-06-16 20:27:25 -04:00
|
|
|
// Automatically select the latest attempt if available
|
|
|
|
|
if (result.data.length > 0) {
|
2025-06-16 20:38:20 -04:00
|
|
|
const latestAttempt = result.data.reduce((latest, current) =>
|
|
|
|
|
new Date(current.created_at) > new Date(latest.created_at)
|
|
|
|
|
? current
|
|
|
|
|
: latest
|
2025-06-16 20:27:25 -04:00
|
|
|
);
|
|
|
|
|
setSelectedAttempt(latestAttempt);
|
|
|
|
|
fetchAttemptActivities(latestAttempt.id);
|
|
|
|
|
}
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2025-06-16 20:23:57 -04:00
|
|
|
onError("Failed to load task attempts");
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2025-06-16 20:23:57 -04:00
|
|
|
onError("Failed to load task attempts");
|
2025-06-16 16:16:42 -04:00
|
|
|
} finally {
|
2025-06-16 20:23:57 -04:00
|
|
|
setTaskAttemptsLoading(false);
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
2025-06-16 20:23:57 -04:00
|
|
|
};
|
2025-06-16 16:16:42 -04:00
|
|
|
|
|
|
|
|
const fetchAttemptActivities = async (attemptId: string) => {
|
2025-06-16 20:23:57 -04:00
|
|
|
if (!task) return;
|
|
|
|
|
|
2025-06-16 16:16:42 -04:00
|
|
|
try {
|
2025-06-16 20:23:57 -04:00
|
|
|
setActivitiesLoading(true);
|
2025-06-17 14:17:31 -04:00
|
|
|
const response = await makeRequest(
|
2025-06-16 20:23:57 -04:00
|
|
|
`/api/projects/${projectId}/tasks/${task.id}/attempts/${attemptId}/activities`
|
|
|
|
|
);
|
|
|
|
|
|
2025-06-16 16:16:42 -04:00
|
|
|
if (response.ok) {
|
2025-06-16 20:23:57 -04:00
|
|
|
const result: ApiResponse<TaskAttemptActivity[]> =
|
|
|
|
|
await response.json();
|
2025-06-16 16:16:42 -04:00
|
|
|
if (result.success && result.data) {
|
2025-06-16 20:23:57 -04:00
|
|
|
setAttemptActivities(result.data);
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2025-06-16 20:23:57 -04:00
|
|
|
onError("Failed to load attempt activities");
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2025-06-16 20:23:57 -04:00
|
|
|
onError("Failed to load attempt activities");
|
2025-06-16 16:16:42 -04:00
|
|
|
} finally {
|
2025-06-16 20:23:57 -04:00
|
|
|
setActivitiesLoading(false);
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|
2025-06-16 20:23:57 -04:00
|
|
|
};
|
2025-06-16 16:16:42 -04:00
|
|
|
|
|
|
|
|
const handleAttemptClick = (attempt: TaskAttempt) => {
|
2025-06-16 20:23:57 -04:00
|
|
|
setSelectedAttempt(attempt);
|
|
|
|
|
fetchAttemptActivities(attempt.id);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const saveTaskChanges = async () => {
|
|
|
|
|
if (!task) return;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
setSavingTask(true);
|
2025-06-17 14:17:31 -04:00
|
|
|
const response = await makeRequest(
|
2025-06-16 20:23:57 -04:00
|
|
|
`/api/projects/${projectId}/tasks/${task.id}`,
|
|
|
|
|
{
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
title: editedTitle,
|
|
|
|
|
description: editedDescription || null,
|
|
|
|
|
status: editedStatus,
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
setIsEditMode(false);
|
|
|
|
|
// Update the local task state would require parent component to refresh
|
|
|
|
|
// For now, just exit edit mode
|
|
|
|
|
} else {
|
|
|
|
|
onError("Failed to save task changes");
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
onError("Failed to save task changes");
|
|
|
|
|
} finally {
|
|
|
|
|
setSavingTask(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const cancelEdit = () => {
|
|
|
|
|
if (task) {
|
|
|
|
|
setEditedTitle(task.title);
|
|
|
|
|
setEditedDescription(task.description || "");
|
|
|
|
|
setEditedStatus(task.status);
|
|
|
|
|
}
|
|
|
|
|
setIsEditMode(false);
|
|
|
|
|
};
|
2025-06-16 16:16:42 -04:00
|
|
|
|
2025-06-16 17:40:36 -04:00
|
|
|
const createNewAttempt = async () => {
|
2025-06-16 20:23:57 -04:00
|
|
|
if (!task) return;
|
|
|
|
|
|
2025-06-16 17:40:36 -04:00
|
|
|
try {
|
2025-06-16 20:23:57 -04:00
|
|
|
setCreatingAttempt(true);
|
|
|
|
|
const worktreePath = `/tmp/task-${task.id}-attempt-${Date.now()}`;
|
|
|
|
|
|
2025-06-17 14:17:31 -04:00
|
|
|
const response = await makeRequest(
|
2025-06-16 17:40:36 -04:00
|
|
|
`/api/projects/${projectId}/tasks/${task.id}/attempts`,
|
|
|
|
|
{
|
2025-06-16 20:23:57 -04:00
|
|
|
method: "POST",
|
2025-06-16 17:40:36 -04:00
|
|
|
headers: {
|
2025-06-16 20:23:57 -04:00
|
|
|
"Content-Type": "application/json",
|
2025-06-16 17:40:36 -04:00
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
task_id: task.id,
|
|
|
|
|
worktree_path: worktreePath,
|
|
|
|
|
base_commit: null,
|
|
|
|
|
merge_commit: null,
|
2025-06-16 20:38:20 -04:00
|
|
|
executor: selectedExecutor,
|
2025-06-16 17:40:36 -04:00
|
|
|
}),
|
|
|
|
|
}
|
2025-06-16 20:23:57 -04:00
|
|
|
);
|
|
|
|
|
|
2025-06-16 17:40:36 -04:00
|
|
|
if (response.ok) {
|
|
|
|
|
// Refresh the attempts list
|
2025-06-16 20:23:57 -04:00
|
|
|
await fetchTaskAttempts(task.id);
|
2025-06-16 17:40:36 -04:00
|
|
|
} else {
|
2025-06-16 20:23:57 -04:00
|
|
|
onError("Failed to create task attempt");
|
2025-06-16 17:40:36 -04:00
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2025-06-16 20:23:57 -04:00
|
|
|
onError("Failed to create task attempt");
|
2025-06-16 17:40:36 -04:00
|
|
|
} finally {
|
2025-06-16 20:23:57 -04:00
|
|
|
setCreatingAttempt(false);
|
2025-06-16 17:40:36 -04:00
|
|
|
}
|
2025-06-16 20:23:57 -04:00
|
|
|
};
|
2025-06-16 17:40:36 -04:00
|
|
|
|
2025-06-16 20:45:34 -04:00
|
|
|
const stopTaskAttempt = async () => {
|
|
|
|
|
if (!task || !selectedAttempt) return;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
setStoppingAttempt(true);
|
2025-06-17 14:17:31 -04:00
|
|
|
const response = await makeRequest(
|
2025-06-16 20:45:34 -04:00
|
|
|
`/api/projects/${projectId}/tasks/${task.id}/attempts/${selectedAttempt.id}/stop`,
|
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
// Refresh the activities list to show the stopped status
|
|
|
|
|
fetchAttemptActivities(selectedAttempt.id);
|
|
|
|
|
} else {
|
|
|
|
|
onError("Failed to stop task attempt");
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
onError("Failed to stop task attempt");
|
|
|
|
|
} finally {
|
|
|
|
|
setStoppingAttempt(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-16 16:16:42 -04:00
|
|
|
return (
|
2025-06-16 20:23:57 -04:00
|
|
|
<Dialog open={isOpen} onOpenChange={onOpenChange} className="max-w-7xl">
|
|
|
|
|
<DialogContent className="max-h-[85vh] overflow-y-auto">
|
2025-06-16 16:16:42 -04:00
|
|
|
<DialogHeader>
|
2025-06-16 20:23:57 -04:00
|
|
|
<div className="flex justify-between items-start">
|
|
|
|
|
<DialogTitle className="text-xl">
|
|
|
|
|
{isEditMode ? "Edit Task" : "Task Details"}
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
{isEditMode ? (
|
|
|
|
|
<>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={saveTaskChanges}
|
|
|
|
|
disabled={savingTask}
|
|
|
|
|
size="sm"
|
2025-06-16 20:06:15 -04:00
|
|
|
>
|
2025-06-16 20:23:57 -04:00
|
|
|
{savingTask ? "Saving..." : "Save"}
|
|
|
|
|
</Button>
|
|
|
|
|
<Button onClick={cancelEdit} variant="outline" size="sm">
|
|
|
|
|
Cancel
|
|
|
|
|
</Button>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => setIsEditMode(true)}
|
|
|
|
|
variant="outline"
|
2025-06-16 20:06:15 -04:00
|
|
|
size="sm"
|
|
|
|
|
>
|
2025-06-16 20:23:57 -04:00
|
|
|
Edit
|
2025-06-16 20:06:15 -04:00
|
|
|
</Button>
|
2025-06-16 20:23:57 -04:00
|
|
|
)}
|
2025-06-16 17:40:36 -04:00
|
|
|
</div>
|
2025-06-16 20:23:57 -04:00
|
|
|
</div>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
|
|
|
|
|
<div className="grid grid-cols-3 gap-6">
|
|
|
|
|
{/* Main Content */}
|
|
|
|
|
<div className="col-span-2 space-y-6">
|
|
|
|
|
{/* Task Details */}
|
|
|
|
|
<Card>
|
|
|
|
|
<CardContent className="p-6">
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<div>
|
|
|
|
|
<Label className="text-sm font-medium">Title</Label>
|
|
|
|
|
{isEditMode ? (
|
|
|
|
|
<Input
|
|
|
|
|
value={editedTitle}
|
|
|
|
|
onChange={(e) => setEditedTitle(e.target.value)}
|
|
|
|
|
className="mt-1"
|
|
|
|
|
placeholder="Enter task title..."
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<h2 className="text-lg font-semibold mt-1">
|
|
|
|
|
{task?.title}
|
|
|
|
|
</h2>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<Label className="text-sm font-medium">Description</Label>
|
|
|
|
|
{isEditMode ? (
|
|
|
|
|
<Textarea
|
|
|
|
|
value={editedDescription}
|
|
|
|
|
onChange={(e) => setEditedDescription(e.target.value)}
|
|
|
|
|
className="mt-1 min-h-[100px]"
|
|
|
|
|
placeholder="Enter task description..."
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
2025-06-20 16:20:22 +01:00
|
|
|
<div className="mt-1 p-3 bg-muted rounded-md min-h-[60px]">
|
2025-06-16 20:23:57 -04:00
|
|
|
{task?.description ? (
|
2025-06-20 16:20:22 +01:00
|
|
|
<p className="text-sm text-foreground whitespace-pre-wrap">
|
2025-06-16 20:23:57 -04:00
|
|
|
{task.description}
|
|
|
|
|
</p>
|
|
|
|
|
) : (
|
2025-06-20 16:20:22 +01:00
|
|
|
<p className="text-sm text-muted-foreground italic">
|
2025-06-16 20:23:57 -04:00
|
|
|
No description provided
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
2025-06-20 22:55:30 +01:00
|
|
|
{/* TODO: Task Attempt Output - migrate to use ExecutionProcess data */}
|
|
|
|
|
{/* ExecutionProcess stdout/stderr display will be implemented when execution processes are exposed via API */}
|
2025-06-16 16:16:42 -04:00
|
|
|
</div>
|
|
|
|
|
|
2025-06-16 20:23:57 -04:00
|
|
|
{/* Sidebar */}
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<Card>
|
|
|
|
|
<CardContent className="p-4">
|
|
|
|
|
<h4 className="font-semibold mb-3">Details</h4>
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div>
|
|
|
|
|
<Label className="text-xs text-muted-foreground">
|
|
|
|
|
Status
|
|
|
|
|
</Label>
|
|
|
|
|
{isEditMode ? (
|
|
|
|
|
<Select
|
|
|
|
|
value={editedStatus}
|
|
|
|
|
onValueChange={(value) =>
|
|
|
|
|
setEditedStatus(value as TaskStatus)
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<SelectTrigger className="mt-1">
|
|
|
|
|
<SelectValue />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
<SelectItem value="todo">To Do</SelectItem>
|
|
|
|
|
<SelectItem value="inprogress">
|
|
|
|
|
In Progress
|
|
|
|
|
</SelectItem>
|
|
|
|
|
<SelectItem value="inreview">In Review</SelectItem>
|
|
|
|
|
<SelectItem value="done">Done</SelectItem>
|
|
|
|
|
<SelectItem value="cancelled">Cancelled</SelectItem>
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
) : (
|
|
|
|
|
<div
|
|
|
|
|
className={`mt-1 px-2 py-1 rounded-full text-xs font-medium w-fit ${
|
|
|
|
|
task?.status === "todo"
|
2025-06-20 16:20:22 +01:00
|
|
|
? "bg-neutral text-neutral-foreground"
|
2025-06-16 20:23:57 -04:00
|
|
|
: task?.status === "inprogress"
|
2025-06-20 16:20:22 +01:00
|
|
|
? "bg-info text-info-foreground"
|
2025-06-16 20:23:57 -04:00
|
|
|
: task?.status === "inreview"
|
2025-06-20 16:20:22 +01:00
|
|
|
? "bg-warning text-warning-foreground"
|
2025-06-16 20:23:57 -04:00
|
|
|
: task?.status === "done"
|
2025-06-20 16:20:22 +01:00
|
|
|
? "bg-success text-success-foreground"
|
|
|
|
|
: "bg-destructive text-destructive-foreground"
|
2025-06-16 20:23:57 -04:00
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{task ? statusLabels[task.status] : ""}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Separator />
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<Label className="text-xs text-muted-foreground">
|
|
|
|
|
Created
|
|
|
|
|
</Label>
|
|
|
|
|
<p className="text-sm mt-1">
|
|
|
|
|
{task
|
|
|
|
|
? new Date(task.created_at).toLocaleDateString()
|
|
|
|
|
: ""}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<Label className="text-xs text-muted-foreground">
|
|
|
|
|
Updated
|
|
|
|
|
</Label>
|
|
|
|
|
<p className="text-sm mt-1">
|
|
|
|
|
{task
|
|
|
|
|
? new Date(task.updated_at).toLocaleDateString()
|
|
|
|
|
: ""}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<Label className="text-xs text-muted-foreground">
|
|
|
|
|
Project ID
|
|
|
|
|
</Label>
|
|
|
|
|
<p className="text-xs text-muted-foreground mt-1 font-mono">
|
|
|
|
|
{projectId}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2025-06-16 16:16:42 -04:00
|
|
|
</div>
|
2025-06-16 20:23:57 -04:00
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
{/* Task Attempts */}
|
|
|
|
|
<Card>
|
|
|
|
|
<CardContent className="p-4">
|
|
|
|
|
<h4 className="font-semibold mb-3">Task Attempts</h4>
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div>
|
|
|
|
|
<Label className="text-xs text-muted-foreground mb-2 block">
|
|
|
|
|
Select Attempt
|
|
|
|
|
</Label>
|
|
|
|
|
{taskAttemptsLoading ? (
|
|
|
|
|
<div className="text-center py-2 text-sm text-muted-foreground">
|
|
|
|
|
Loading...
|
|
|
|
|
</div>
|
|
|
|
|
) : taskAttempts.length === 0 ? (
|
|
|
|
|
<div className="text-center py-2 text-sm text-muted-foreground">
|
|
|
|
|
No attempts found
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<Select
|
|
|
|
|
value={selectedAttempt?.id || ""}
|
|
|
|
|
onValueChange={(value) => {
|
|
|
|
|
const attempt = taskAttempts.find(
|
|
|
|
|
(a) => a.id === value
|
|
|
|
|
);
|
|
|
|
|
if (attempt) {
|
|
|
|
|
handleAttemptClick(attempt);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<SelectTrigger>
|
|
|
|
|
<SelectValue placeholder="Select an attempt..." />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
{taskAttempts.map((attempt) => (
|
|
|
|
|
<SelectItem key={attempt.id} value={attempt.id}>
|
|
|
|
|
<div className="flex flex-col">
|
|
|
|
|
<span className="font-medium">
|
|
|
|
|
{new Date(
|
|
|
|
|
attempt.created_at
|
|
|
|
|
).toLocaleDateString()}{" "}
|
|
|
|
|
{new Date(
|
|
|
|
|
attempt.created_at
|
|
|
|
|
).toLocaleTimeString()}
|
|
|
|
|
</span>
|
2025-06-16 20:38:20 -04:00
|
|
|
<span className="text-xs text-muted-foreground text-left">
|
|
|
|
|
{attempt.executor || "executor"}
|
2025-06-16 20:23:57 -04:00
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</SelectItem>
|
|
|
|
|
))}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Separator />
|
|
|
|
|
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
<Label className="text-xs text-muted-foreground">
|
2025-06-16 20:45:34 -04:00
|
|
|
Actions
|
2025-06-16 20:23:57 -04:00
|
|
|
</Label>
|
|
|
|
|
<div className="flex flex-col gap-2">
|
2025-06-16 20:45:34 -04:00
|
|
|
{isAttemptRunning && (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={stopTaskAttempt}
|
|
|
|
|
disabled={stoppingAttempt}
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="destructive"
|
|
|
|
|
className="w-full"
|
|
|
|
|
>
|
|
|
|
|
{stoppingAttempt ? "Stopping..." : "Stop Execution"}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
<Label className="text-xs text-muted-foreground">
|
|
|
|
|
New Attempt
|
|
|
|
|
</Label>
|
|
|
|
|
<Select
|
|
|
|
|
value={selectedExecutor}
|
|
|
|
|
onValueChange={(value) =>
|
2025-06-18 00:17:06 -04:00
|
|
|
setSelectedExecutor(
|
|
|
|
|
value as "echo" | "claude" | "amp"
|
|
|
|
|
)
|
2025-06-16 20:45:34 -04:00
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<SelectTrigger>
|
|
|
|
|
<SelectValue />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
<SelectItem value="claude">Claude</SelectItem>
|
2025-06-18 00:17:06 -04:00
|
|
|
<SelectItem value="amp">Amp</SelectItem>
|
|
|
|
|
<SelectItem value="echo">Echo</SelectItem>
|
2025-06-16 20:45:34 -04:00
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={createNewAttempt}
|
|
|
|
|
disabled={creatingAttempt}
|
|
|
|
|
size="sm"
|
|
|
|
|
className="w-full"
|
|
|
|
|
>
|
|
|
|
|
{creatingAttempt ? "Creating..." : "Create Attempt"}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
2025-06-16 20:23:57 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
{/* Activity History */}
|
|
|
|
|
{selectedAttempt && (
|
|
|
|
|
<Card>
|
|
|
|
|
<CardContent className="p-4">
|
|
|
|
|
<h4 className="font-semibold mb-3">Activity History</h4>
|
|
|
|
|
<p className="text-xs text-muted-foreground mb-3">
|
|
|
|
|
{selectedAttempt.worktree_path}
|
|
|
|
|
</p>
|
|
|
|
|
{activitiesLoading ? (
|
|
|
|
|
<div className="text-center py-4">
|
|
|
|
|
Loading activities...
|
|
|
|
|
</div>
|
|
|
|
|
) : attemptActivities.length === 0 ? (
|
|
|
|
|
<div className="text-center py-4 text-muted-foreground">
|
|
|
|
|
No activities found
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
{attemptActivities.map((activity) => (
|
|
|
|
|
<div
|
|
|
|
|
key={activity.id}
|
2025-06-20 16:20:22 +01:00
|
|
|
className="border-l-2 border-border pl-3 pb-2"
|
2025-06-16 20:23:57 -04:00
|
|
|
>
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<span
|
|
|
|
|
className={`px-2 py-1 rounded-full text-xs font-medium ${
|
2025-06-19 11:09:32 -04:00
|
|
|
getAttemptStatusDisplay(activity.status).className
|
2025-06-16 20:23:57 -04:00
|
|
|
}`}
|
|
|
|
|
>
|
2025-06-19 11:09:32 -04:00
|
|
|
{getAttemptStatusDisplay(activity.status).label}
|
2025-06-16 20:23:57 -04:00
|
|
|
</span>
|
|
|
|
|
<p className="text-xs text-muted-foreground">
|
|
|
|
|
{new Date(activity.created_at).toLocaleString()}
|
|
|
|
|
</p>
|
2025-06-16 16:16:42 -04:00
|
|
|
</div>
|
2025-06-16 20:23:57 -04:00
|
|
|
{activity.note && (
|
|
|
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
|
|
|
{activity.note}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
2025-06-16 16:16:42 -04:00
|
|
|
</div>
|
2025-06-16 20:23:57 -04:00
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2025-06-16 16:16:42 -04:00
|
|
|
</div>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
2025-06-16 20:23:57 -04:00
|
|
|
);
|
2025-06-16 16:16:42 -04:00
|
|
|
}
|