From 70e08853aa0f30b1eca4d08a89eeac855d7d4651 Mon Sep 17 00:00:00 2001 From: Louis Knight-Webb Date: Sat, 21 Jun 2025 22:55:12 +0100 Subject: [PATCH] Fixes --- frontend/src/components/layout/navbar.tsx | 10 -- .../src/components/projects/project-list.tsx | 166 ++++++++++-------- .../src/components/tasks/TaskDetailsPanel.tsx | 8 +- 3 files changed, 99 insertions(+), 85 deletions(-) diff --git a/frontend/src/components/layout/navbar.tsx b/frontend/src/components/layout/navbar.tsx index 5c558e7d..2a543380 100644 --- a/frontend/src/components/layout/navbar.tsx +++ b/frontend/src/components/layout/navbar.tsx @@ -40,16 +40,6 @@ export function Navbar() { -
- {!isHome && ( - - )} -
diff --git a/frontend/src/components/projects/project-list.tsx b/frontend/src/components/projects/project-list.tsx index 8a9f5ccd..147b36d3 100644 --- a/frontend/src/components/projects/project-list.tsx +++ b/frontend/src/components/projects/project-list.tsx @@ -1,80 +1,100 @@ -import { useState, useEffect } from 'react' -import { useNavigate } from 'react-router-dom' -import { Button } from '@/components/ui/button' -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' -import { Badge } from '@/components/ui/badge' -import { Alert, AlertDescription } from '@/components/ui/alert' -import { Project, ApiResponse } from 'shared/types' -import { ProjectForm } from './project-form' -import { makeRequest } from '@/lib/api' -import { Plus, Edit, Trash2, Calendar, AlertCircle, Loader2, MoreHorizontal, ExternalLink } from 'lucide-react' +import { useState, useEffect } from "react"; +import { useNavigate } from "react-router-dom"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { Badge } from "@/components/ui/badge"; +import { Alert, AlertDescription } from "@/components/ui/alert"; +import { Project, ApiResponse } from "shared/types"; +import { ProjectForm } from "./project-form"; +import { makeRequest } from "@/lib/api"; +import { + Plus, + Edit, + Trash2, + Calendar, + AlertCircle, + Loader2, + MoreHorizontal, + ExternalLink, +} from "lucide-react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, -} from '@/components/ui/dropdown-menu' +} from "@/components/ui/dropdown-menu"; export function ProjectList() { - const navigate = useNavigate() - const [projects, setProjects] = useState([]) - const [loading, setLoading] = useState(false) - const [showForm, setShowForm] = useState(false) - const [editingProject, setEditingProject] = useState(null) - const [error, setError] = useState('') + const navigate = useNavigate(); + const [projects, setProjects] = useState([]); + const [loading, setLoading] = useState(false); + const [showForm, setShowForm] = useState(false); + const [editingProject, setEditingProject] = useState(null); + const [error, setError] = useState(""); const fetchProjects = async () => { - setLoading(true) - setError('') + setLoading(true); + setError(""); try { - const response = await makeRequest('/api/projects') - const data: ApiResponse = await response.json() + const response = await makeRequest("/api/projects"); + const data: ApiResponse = await response.json(); if (data.success && data.data) { - setProjects(data.data) + setProjects(data.data); } else { - setError('Failed to load projects') + setError("Failed to load projects"); } } catch (error) { - console.error('Failed to fetch projects:', error) - setError('Failed to connect to server') + console.error("Failed to fetch projects:", error); + setError("Failed to connect to server"); } finally { - setLoading(false) + setLoading(false); } - } + }; const handleDelete = async (id: string, name: string) => { - if (!confirm(`Are you sure you want to delete "${name}"? This action cannot be undone.`)) return + if ( + !confirm( + `Are you sure you want to delete "${name}"? This action cannot be undone.` + ) + ) + return; try { const response = await makeRequest(`/api/projects/${id}`, { - method: 'DELETE', - }) + method: "DELETE", + }); if (response.ok) { - fetchProjects() + fetchProjects(); } } catch (error) { - console.error('Failed to delete project:', error) - setError('Failed to delete project') + console.error("Failed to delete project:", error); + setError("Failed to delete project"); } - } + }; const handleEdit = (project: Project) => { - setEditingProject(project) - setShowForm(true) - } + setEditingProject(project); + setShowForm(true); + }; const handleFormSuccess = () => { - setShowForm(false) - setEditingProject(null) - fetchProjects() - } + setShowForm(false); + setEditingProject(null); + fetchProjects(); + }; useEffect(() => { - fetchProjects() - }, []) + fetchProjects(); + }, []); return ( -
+

Projects

@@ -91,9 +111,7 @@ export function ProjectList() { {error && ( - - {error} - + {error} )} @@ -112,10 +130,7 @@ export function ProjectList() {

Get started by creating your first project.

- @@ -124,22 +139,21 @@ export function ProjectList() { ) : (
{projects.map((project) => ( - navigate(`/projects/${project.id}/tasks`)} >
- - {project.name} - + {project.name}
- - Active - + Active - e.stopPropagation()}> + e.stopPropagation()} + >
- ) + ); } diff --git a/frontend/src/components/tasks/TaskDetailsPanel.tsx b/frontend/src/components/tasks/TaskDetailsPanel.tsx index 286586c7..ed06c50f 100644 --- a/frontend/src/components/tasks/TaskDetailsPanel.tsx +++ b/frontend/src/components/tasks/TaskDetailsPanel.tsx @@ -203,6 +203,11 @@ export function TaskDetailsPanel({ ); setSelectedAttempt(latestAttempt); fetchAttemptActivities(latestAttempt.id); + } else { + // Clear state when no attempts exist + setSelectedAttempt(null); + setAttemptActivities([]); + setExecutionProcesses({}); } } } @@ -477,7 +482,8 @@ export function TaskDetailsPanel({ onClick={() => createNewAttempt()} className="rounded-r-none border-r-0" > - Attempt with{" "} + {selectedAttempt ? "Retry " : "Attempt "} + with{" "} { availableExecutors.find( (e) => e.id === selectedExecutor