2025-06-21 16:49:16 +01:00
|
|
|
import { useState, useEffect } from "react";
|
2025-06-21 17:36:07 +01:00
|
|
|
import {
|
|
|
|
|
X,
|
|
|
|
|
History,
|
|
|
|
|
Send,
|
|
|
|
|
Clock,
|
|
|
|
|
FileText,
|
|
|
|
|
Code,
|
2025-06-21 19:13:42 +01:00
|
|
|
ChevronDown,
|
|
|
|
|
ChevronUp,
|
|
|
|
|
Plus,
|
2025-06-21 20:04:15 +01:00
|
|
|
Settings,
|
|
|
|
|
Settings2,
|
2025-06-21 17:36:07 +01:00
|
|
|
} from "lucide-react";
|
2025-06-21 16:49:16 +01:00
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { Card, CardContent } from "@/components/ui/card";
|
|
|
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
|
import { Textarea } from "@/components/ui/textarea";
|
2025-06-21 19:13:42 +01:00
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
DropdownMenu,
|
|
|
|
|
DropdownMenuContent,
|
|
|
|
|
DropdownMenuItem,
|
|
|
|
|
DropdownMenuTrigger,
|
|
|
|
|
} from "@/components/ui/dropdown-menu";
|
|
|
|
|
|
2025-06-21 16:49:16 +01:00
|
|
|
import { makeRequest } from "@/lib/api";
|
2025-06-21 19:13:42 +01:00
|
|
|
import {
|
|
|
|
|
getTaskPanelClasses,
|
|
|
|
|
getBackdropClasses,
|
|
|
|
|
} from "@/lib/responsive-config";
|
2025-06-21 16:49:16 +01:00
|
|
|
import type {
|
|
|
|
|
TaskStatus,
|
|
|
|
|
TaskAttempt,
|
|
|
|
|
TaskAttemptActivity,
|
|
|
|
|
TaskAttemptStatus,
|
|
|
|
|
ApiResponse,
|
|
|
|
|
TaskWithAttemptStatus,
|
|
|
|
|
} from "shared/types";
|
|
|
|
|
|
|
|
|
|
interface TaskDetailsPanelProps {
|
|
|
|
|
task: TaskWithAttemptStatus | null;
|
|
|
|
|
projectId: string;
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const statusLabels: Record<TaskStatus, string> = {
|
|
|
|
|
todo: "To Do",
|
2025-06-21 17:36:07 +01:00
|
|
|
inprogress: "In Progress",
|
2025-06-21 16:49:16 +01:00
|
|
|
inreview: "In Review",
|
|
|
|
|
done: "Done",
|
|
|
|
|
cancelled: "Cancelled",
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-21 17:36:07 +01:00
|
|
|
const getAttemptStatusDisplay = (
|
|
|
|
|
status: TaskAttemptStatus
|
|
|
|
|
): { label: string; className: string } => {
|
2025-06-21 16:49:16 +01:00
|
|
|
switch (status) {
|
|
|
|
|
case "setuprunning":
|
2025-06-21 17:36:07 +01:00
|
|
|
return {
|
|
|
|
|
label: "Setup Running",
|
|
|
|
|
className: "bg-status-running text-status-running-foreground",
|
|
|
|
|
};
|
2025-06-21 16:49:16 +01:00
|
|
|
case "setupcomplete":
|
2025-06-21 17:36:07 +01:00
|
|
|
return {
|
|
|
|
|
label: "Setup Complete",
|
|
|
|
|
className: "bg-status-complete text-status-complete-foreground",
|
|
|
|
|
};
|
2025-06-21 16:49:16 +01:00
|
|
|
case "setupfailed":
|
2025-06-21 17:36:07 +01:00
|
|
|
return {
|
|
|
|
|
label: "Setup Failed",
|
|
|
|
|
className: "bg-status-failed text-status-failed-foreground",
|
|
|
|
|
};
|
2025-06-21 16:49:16 +01:00
|
|
|
case "executorrunning":
|
2025-06-21 17:36:07 +01:00
|
|
|
return {
|
|
|
|
|
label: "Executor Running",
|
|
|
|
|
className: "bg-status-running text-status-running-foreground",
|
|
|
|
|
};
|
2025-06-21 16:49:16 +01:00
|
|
|
case "executorcomplete":
|
2025-06-21 17:36:07 +01:00
|
|
|
return {
|
|
|
|
|
label: "Executor Complete",
|
|
|
|
|
className: "bg-status-complete text-status-complete-foreground",
|
|
|
|
|
};
|
2025-06-21 16:49:16 +01:00
|
|
|
case "executorfailed":
|
2025-06-21 17:36:07 +01:00
|
|
|
return {
|
|
|
|
|
label: "Executor Failed",
|
|
|
|
|
className: "bg-status-failed text-status-failed-foreground",
|
|
|
|
|
};
|
2025-06-21 16:49:16 +01:00
|
|
|
default:
|
2025-06-21 17:36:07 +01:00
|
|
|
return {
|
|
|
|
|
label: "Unknown",
|
|
|
|
|
className: "bg-status-init text-status-init-foreground",
|
|
|
|
|
};
|
2025-06-21 16:49:16 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-21 17:36:07 +01:00
|
|
|
export function TaskDetailsPanel({
|
|
|
|
|
task,
|
|
|
|
|
projectId,
|
|
|
|
|
isOpen,
|
|
|
|
|
onClose,
|
|
|
|
|
}: TaskDetailsPanelProps) {
|
2025-06-21 16:49:16 +01:00
|
|
|
const [taskAttempts, setTaskAttempts] = useState<TaskAttempt[]>([]);
|
2025-06-21 17:36:07 +01:00
|
|
|
const [selectedAttempt, setSelectedAttempt] = useState<TaskAttempt | null>(
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
const [attemptActivities, setAttemptActivities] = useState<
|
|
|
|
|
TaskAttemptActivity[]
|
|
|
|
|
>([]);
|
2025-06-21 16:49:16 +01:00
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
const [followUpMessage, setFollowUpMessage] = useState("");
|
2025-06-21 19:13:42 +01:00
|
|
|
const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false);
|
2025-06-21 20:04:15 +01:00
|
|
|
const [selectedExecutor, setSelectedExecutor] = useState("claude");
|
|
|
|
|
|
|
|
|
|
// Available executors
|
|
|
|
|
const availableExecutors = [
|
|
|
|
|
{ id: "echo", name: "Echo" },
|
|
|
|
|
{ id: "claude", name: "Claude" },
|
|
|
|
|
{ id: "amp", name: "Amp" },
|
|
|
|
|
];
|
2025-06-21 16:49:16 +01:00
|
|
|
|
|
|
|
|
// Check if the selected attempt is active (not in a final state)
|
|
|
|
|
const isAttemptRunning =
|
|
|
|
|
selectedAttempt &&
|
|
|
|
|
attemptActivities.length > 0 &&
|
2025-06-21 20:04:15 +01:00
|
|
|
(attemptActivities[0].status === "setuprunning" ||
|
2025-06-21 16:49:16 +01:00
|
|
|
attemptActivities[0].status === "setupcomplete" ||
|
|
|
|
|
attemptActivities[0].status === "executorrunning");
|
|
|
|
|
|
|
|
|
|
// Polling for updates when attempt is running
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!isAttemptRunning || !task) return;
|
|
|
|
|
|
|
|
|
|
const interval = setInterval(() => {
|
|
|
|
|
if (selectedAttempt) {
|
|
|
|
|
fetchAttemptActivities(selectedAttempt.id, true);
|
|
|
|
|
}
|
|
|
|
|
}, 2000);
|
|
|
|
|
|
|
|
|
|
return () => clearInterval(interval);
|
|
|
|
|
}, [isAttemptRunning, task?.id, selectedAttempt?.id]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (task && isOpen) {
|
|
|
|
|
fetchTaskAttempts();
|
|
|
|
|
}
|
|
|
|
|
}, [task, isOpen]);
|
|
|
|
|
|
|
|
|
|
const fetchTaskAttempts = async () => {
|
|
|
|
|
if (!task) return;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
const response = await makeRequest(
|
|
|
|
|
`/api/projects/${projectId}/tasks/${task.id}/attempts`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
const result: ApiResponse<TaskAttempt[]> = await response.json();
|
|
|
|
|
if (result.success && result.data) {
|
|
|
|
|
setTaskAttempts(result.data);
|
2025-06-21 17:36:07 +01:00
|
|
|
|
2025-06-21 16:49:16 +01:00
|
|
|
// Auto-select latest attempt
|
|
|
|
|
if (result.data.length > 0) {
|
|
|
|
|
const latestAttempt = result.data.reduce((latest, current) =>
|
|
|
|
|
new Date(current.created_at) > new Date(latest.created_at)
|
|
|
|
|
? current
|
|
|
|
|
: latest
|
|
|
|
|
);
|
|
|
|
|
setSelectedAttempt(latestAttempt);
|
|
|
|
|
fetchAttemptActivities(latestAttempt.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error("Failed to fetch task attempts:", err);
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-21 17:36:07 +01:00
|
|
|
const fetchAttemptActivities = async (
|
|
|
|
|
attemptId: string,
|
|
|
|
|
_isBackgroundUpdate = false
|
|
|
|
|
) => {
|
2025-06-21 16:49:16 +01:00
|
|
|
if (!task) return;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await makeRequest(
|
|
|
|
|
`/api/projects/${projectId}/tasks/${task.id}/attempts/${attemptId}/activities`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
2025-06-21 17:36:07 +01:00
|
|
|
const result: ApiResponse<TaskAttemptActivity[]> =
|
|
|
|
|
await response.json();
|
2025-06-21 16:49:16 +01:00
|
|
|
if (result.success && result.data) {
|
|
|
|
|
setAttemptActivities(result.data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error("Failed to fetch attempt activities:", err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleAttemptChange = (attemptId: string) => {
|
2025-06-21 17:36:07 +01:00
|
|
|
const attempt = taskAttempts.find((a) => a.id === attemptId);
|
2025-06-21 16:49:16 +01:00
|
|
|
if (attempt) {
|
|
|
|
|
setSelectedAttempt(attempt);
|
|
|
|
|
fetchAttemptActivities(attempt.id);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSendFollowUp = () => {
|
|
|
|
|
// TODO: Implement follow-up message API
|
|
|
|
|
console.log("Follow-up message:", followUpMessage);
|
|
|
|
|
setFollowUpMessage("");
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-21 19:13:42 +01:00
|
|
|
const openInEditor = async () => {
|
2025-06-21 16:49:16 +01:00
|
|
|
if (!task || !selectedAttempt) return;
|
|
|
|
|
|
|
|
|
|
try {
|
2025-06-21 19:13:42 +01:00
|
|
|
await makeRequest(
|
|
|
|
|
`/api/projects/${projectId}/tasks/${task.id}/attempts/${selectedAttempt.id}/open-editor`,
|
2025-06-21 16:49:16 +01:00
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
} catch (err) {
|
2025-06-21 19:13:42 +01:00
|
|
|
console.error("Failed to open editor:", err);
|
2025-06-21 16:49:16 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-21 20:04:15 +01:00
|
|
|
const createNewAttempt = async (executor?: string) => {
|
2025-06-21 19:13:42 +01:00
|
|
|
if (!task) return;
|
2025-06-21 16:49:16 +01:00
|
|
|
|
|
|
|
|
try {
|
2025-06-21 19:13:42 +01:00
|
|
|
const response = await makeRequest(
|
|
|
|
|
`/api/projects/${projectId}/tasks/${task.id}/attempts`,
|
2025-06-21 16:49:16 +01:00
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
2025-06-21 20:04:15 +01:00
|
|
|
body: JSON.stringify({
|
|
|
|
|
executor: executor || selectedExecutor,
|
|
|
|
|
}),
|
2025-06-21 16:49:16 +01:00
|
|
|
}
|
|
|
|
|
);
|
2025-06-21 19:13:42 +01:00
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
// Refresh the attempts list
|
|
|
|
|
fetchTaskAttempts();
|
|
|
|
|
}
|
2025-06-21 16:49:16 +01:00
|
|
|
} catch (err) {
|
2025-06-21 19:13:42 +01:00
|
|
|
console.error("Failed to create new attempt:", err);
|
2025-06-21 16:49:16 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!task) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{isOpen && (
|
|
|
|
|
<>
|
2025-06-21 18:00:28 +01:00
|
|
|
{/* Backdrop - only on smaller screens (overlay mode) */}
|
2025-06-21 19:13:42 +01:00
|
|
|
<div className={getBackdropClasses()} onClick={onClose} />
|
2025-06-21 17:36:07 +01:00
|
|
|
|
2025-06-21 16:49:16 +01:00
|
|
|
{/* Panel */}
|
2025-06-21 19:13:42 +01:00
|
|
|
<div className={getTaskPanelClasses()}>
|
2025-06-21 16:49:16 +01:00
|
|
|
<div className="flex flex-col h-full">
|
2025-06-21 17:36:07 +01:00
|
|
|
{/* Header */}
|
|
|
|
|
<div className="p-6 border-b space-y-4">
|
|
|
|
|
<div className="flex items-start justify-between">
|
|
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
<h2 className="text-xl font-bold mb-2 line-clamp-2">
|
|
|
|
|
{task.title}
|
|
|
|
|
</h2>
|
|
|
|
|
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
|
|
|
|
<span
|
|
|
|
|
className={`px-2 py-1 rounded-full text-xs font-medium ${
|
|
|
|
|
task.status === "todo"
|
|
|
|
|
? "bg-neutral text-neutral-foreground"
|
|
|
|
|
: task.status === "inprogress"
|
|
|
|
|
? "bg-info text-info-foreground"
|
|
|
|
|
: task.status === "inreview"
|
|
|
|
|
? "bg-warning text-warning-foreground"
|
|
|
|
|
: task.status === "done"
|
|
|
|
|
? "bg-success text-success-foreground"
|
|
|
|
|
: "bg-destructive text-destructive-foreground"
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{statusLabels[task.status]}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-1">
|
|
|
|
|
<Button variant="ghost" size="icon" onClick={onClose}>
|
|
|
|
|
<X className="h-4 w-4" />
|
2025-06-21 16:49:16 +01:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-06-21 19:13:42 +01:00
|
|
|
{/* Description */}
|
|
|
|
|
<div>
|
|
|
|
|
<div className="p-3 bg-muted rounded-md">
|
|
|
|
|
{task.description ? (
|
|
|
|
|
<div>
|
|
|
|
|
<p
|
|
|
|
|
className={`text-sm whitespace-pre-wrap ${
|
|
|
|
|
!isDescriptionExpanded &&
|
|
|
|
|
task.description.length > 200
|
|
|
|
|
? "line-clamp-3"
|
|
|
|
|
: ""
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{task.description}
|
|
|
|
|
</p>
|
|
|
|
|
{task.description.length > 200 && (
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="sm"
|
|
|
|
|
onClick={() =>
|
|
|
|
|
setIsDescriptionExpanded(!isDescriptionExpanded)
|
|
|
|
|
}
|
|
|
|
|
className="mt-2 p-0 h-auto text-xs text-muted-foreground hover:text-foreground"
|
|
|
|
|
>
|
|
|
|
|
{isDescriptionExpanded ? (
|
|
|
|
|
<>
|
|
|
|
|
<ChevronUp className="h-3 w-3 mr-1" />
|
|
|
|
|
Show less
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<ChevronDown className="h-3 w-3 mr-1" />
|
|
|
|
|
Show more
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<p className="text-sm text-muted-foreground italic">
|
|
|
|
|
No description provided
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-06-21 17:36:07 +01:00
|
|
|
{/* Attempt Selection */}
|
2025-06-21 19:13:42 +01:00
|
|
|
<div className="flex items-center gap-2 p-3 bg-muted/30 rounded-md">
|
|
|
|
|
<div className="flex items-center gap-2 flex-1">
|
|
|
|
|
<span className="text-sm text-muted-foreground">
|
|
|
|
|
Current attempt:
|
|
|
|
|
</span>
|
|
|
|
|
{selectedAttempt && (
|
2025-06-21 17:36:07 +01:00
|
|
|
<span className="text-sm font-medium">
|
|
|
|
|
{new Date(
|
|
|
|
|
selectedAttempt.created_at
|
|
|
|
|
).toLocaleDateString()}{" "}
|
|
|
|
|
{new Date(
|
|
|
|
|
selectedAttempt.created_at
|
|
|
|
|
).toLocaleTimeString()}
|
|
|
|
|
</span>
|
2025-06-21 19:13:42 +01:00
|
|
|
)}
|
|
|
|
|
<div className="flex gap-1">
|
2025-06-21 17:36:07 +01:00
|
|
|
{taskAttempts.length > 1 && (
|
2025-06-21 19:13:42 +01:00
|
|
|
<DropdownMenu>
|
|
|
|
|
<DropdownMenuTrigger asChild>
|
|
|
|
|
<Button variant="outline" size="sm">
|
2025-06-21 20:04:15 +01:00
|
|
|
<History className="h-4 w-4" />
|
2025-06-21 19:13:42 +01:00
|
|
|
</Button>
|
|
|
|
|
</DropdownMenuTrigger>
|
|
|
|
|
<DropdownMenuContent align="start" className="w-64">
|
|
|
|
|
{taskAttempts.map((attempt) => (
|
|
|
|
|
<DropdownMenuItem
|
|
|
|
|
key={attempt.id}
|
|
|
|
|
onClick={() => handleAttemptChange(attempt.id)}
|
|
|
|
|
className={
|
|
|
|
|
selectedAttempt?.id === attempt.id
|
|
|
|
|
? "bg-accent"
|
|
|
|
|
: ""
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex flex-col w-full">
|
|
|
|
|
<span className="font-medium text-sm">
|
|
|
|
|
{new Date(
|
|
|
|
|
attempt.created_at
|
|
|
|
|
).toLocaleDateString()}{" "}
|
|
|
|
|
{new Date(
|
|
|
|
|
attempt.created_at
|
|
|
|
|
).toLocaleTimeString()}
|
|
|
|
|
</span>
|
|
|
|
|
<span className="text-xs text-muted-foreground">
|
|
|
|
|
{attempt.executor || "executor"}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</DropdownMenuItem>
|
|
|
|
|
))}
|
|
|
|
|
</DropdownMenuContent>
|
|
|
|
|
</DropdownMenu>
|
2025-06-21 17:36:07 +01:00
|
|
|
)}
|
2025-06-21 20:04:15 +01:00
|
|
|
<div className="flex">
|
|
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="sm"
|
|
|
|
|
onClick={() => createNewAttempt()}
|
|
|
|
|
className="rounded-r-none border-r-0"
|
|
|
|
|
>
|
|
|
|
|
Attempt with{" "}
|
|
|
|
|
{
|
|
|
|
|
availableExecutors.find(
|
|
|
|
|
(e) => e.id === selectedExecutor
|
|
|
|
|
)?.name
|
|
|
|
|
}
|
|
|
|
|
</Button>
|
|
|
|
|
<DropdownMenu>
|
|
|
|
|
<DropdownMenuTrigger asChild>
|
2025-06-21 19:13:42 +01:00
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
2025-06-21 20:04:15 +01:00
|
|
|
size="sm"
|
|
|
|
|
className="rounded-l-none px-2"
|
2025-06-21 19:13:42 +01:00
|
|
|
>
|
2025-06-21 20:04:15 +01:00
|
|
|
<Settings2 className="h-4 w-4" />
|
2025-06-21 19:13:42 +01:00
|
|
|
</Button>
|
2025-06-21 20:04:15 +01:00
|
|
|
</DropdownMenuTrigger>
|
|
|
|
|
<DropdownMenuContent align="end">
|
|
|
|
|
{availableExecutors.map((executor) => (
|
|
|
|
|
<DropdownMenuItem
|
|
|
|
|
key={executor.id}
|
|
|
|
|
onClick={() => setSelectedExecutor(executor.id)}
|
|
|
|
|
className={
|
|
|
|
|
selectedExecutor === executor.id
|
|
|
|
|
? "bg-accent"
|
|
|
|
|
: ""
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{executor.name}
|
|
|
|
|
{selectedExecutor === executor.id &&
|
|
|
|
|
" (Default)"}
|
|
|
|
|
</DropdownMenuItem>
|
|
|
|
|
))}
|
|
|
|
|
</DropdownMenuContent>
|
|
|
|
|
</DropdownMenu>
|
|
|
|
|
</div>
|
2025-06-21 17:36:07 +01:00
|
|
|
</div>
|
2025-06-21 19:13:42 +01:00
|
|
|
</div>
|
2025-06-21 17:36:07 +01:00
|
|
|
|
|
|
|
|
{selectedAttempt && (
|
|
|
|
|
<div className="flex gap-1">
|
|
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="sm"
|
|
|
|
|
onClick={openInEditor}
|
|
|
|
|
>
|
|
|
|
|
<Code className="h-4 w-4 mr-1" />
|
|
|
|
|
Editor
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="sm"
|
|
|
|
|
onClick={() =>
|
|
|
|
|
window.open(
|
|
|
|
|
`/projects/${projectId}/tasks/${task.id}/attempts/${selectedAttempt.id}/compare`,
|
|
|
|
|
"_blank"
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<FileText className="h-4 w-4 mr-1" />
|
|
|
|
|
Changes
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Content */}
|
|
|
|
|
<div className="flex-1 overflow-y-auto p-6 space-y-6">
|
|
|
|
|
{loading ? (
|
|
|
|
|
<div className="text-center py-8">
|
|
|
|
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-foreground mx-auto mb-4"></div>
|
|
|
|
|
<p className="text-muted-foreground">Loading...</p>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
{/* Activity History */}
|
|
|
|
|
{selectedAttempt && (
|
|
|
|
|
<div>
|
|
|
|
|
<Label className="text-sm font-medium mb-3 block">
|
|
|
|
|
Activity History
|
|
|
|
|
</Label>
|
|
|
|
|
{attemptActivities.length === 0 ? (
|
|
|
|
|
<div className="text-center py-4 text-muted-foreground">
|
|
|
|
|
No activities found
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="space-y-3">
|
2025-06-21 20:04:15 +01:00
|
|
|
{attemptActivities.slice().map((activity) => (
|
2025-06-21 17:36:07 +01:00
|
|
|
<Card key={activity.id} className="border">
|
|
|
|
|
<CardContent className="p-4">
|
|
|
|
|
<div className="flex items-center justify-between mb-2">
|
|
|
|
|
<span
|
|
|
|
|
className={`px-2 py-1 rounded-full text-xs font-medium ${
|
|
|
|
|
getAttemptStatusDisplay(activity.status)
|
|
|
|
|
.className
|
|
|
|
|
}`}
|
2025-06-21 16:49:16 +01:00
|
|
|
>
|
2025-06-21 17:36:07 +01:00
|
|
|
{
|
|
|
|
|
getAttemptStatusDisplay(activity.status)
|
|
|
|
|
.label
|
|
|
|
|
}
|
|
|
|
|
</span>
|
|
|
|
|
<div className="flex items-center gap-1 text-xs text-muted-foreground">
|
|
|
|
|
<Clock className="h-3 w-3" />
|
|
|
|
|
{new Date(
|
|
|
|
|
activity.created_at
|
|
|
|
|
).toLocaleString()}
|
2025-06-21 16:49:16 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-06-21 17:36:07 +01:00
|
|
|
{activity.note && (
|
|
|
|
|
<p className="text-sm text-muted-foreground">
|
|
|
|
|
{activity.note}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-06-21 16:49:16 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
2025-06-21 17:36:07 +01:00
|
|
|
</>
|
2025-06-21 16:49:16 +01:00
|
|
|
)}
|
2025-06-21 17:36:07 +01:00
|
|
|
</div>
|
2025-06-21 16:49:16 +01:00
|
|
|
|
2025-06-21 17:36:07 +01:00
|
|
|
{/* Footer */}
|
|
|
|
|
<div className="border-t p-4">
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
<Label className="text-sm font-medium">
|
|
|
|
|
Follow-up question
|
|
|
|
|
</Label>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<Textarea
|
|
|
|
|
placeholder="Ask a follow-up question about this task..."
|
|
|
|
|
value={followUpMessage}
|
|
|
|
|
onChange={(e) => setFollowUpMessage(e.target.value)}
|
|
|
|
|
className="flex-1 min-h-[60px] resize-none"
|
|
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={handleSendFollowUp}
|
|
|
|
|
disabled={!followUpMessage.trim()}
|
|
|
|
|
className="self-end"
|
|
|
|
|
>
|
|
|
|
|
<Send className="h-4 w-4" />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground">
|
|
|
|
|
Follow-up functionality coming soon
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2025-06-21 16:49:16 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|