Fix bug in create and start
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ArrowLeft, FolderOpen, Settings } from "lucide-react";
|
||||
import { FolderOpen, Settings } from "lucide-react";
|
||||
import { Logo } from "@/components/logo";
|
||||
|
||||
export function Navbar() {
|
||||
const location = useLocation();
|
||||
const isHome = location.pathname === "/";
|
||||
|
||||
return (
|
||||
<div className="border-b">
|
||||
|
||||
@@ -16,7 +16,8 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue
|
||||
} from '@/components/ui/select'
|
||||
import type { TaskStatus } from 'shared/types'
|
||||
import { useConfig } from '@/components/config-provider'
|
||||
import type { TaskStatus, ExecutorConfig } from 'shared/types'
|
||||
|
||||
interface Task {
|
||||
id: string
|
||||
@@ -34,7 +35,7 @@ interface TaskFormDialogProps {
|
||||
task?: Task | null // Optional for create mode
|
||||
projectId?: string // For file search functionality
|
||||
onCreateTask?: (title: string, description: string) => Promise<void>
|
||||
onCreateAndStartTask?: (title: string, description: string) => Promise<void>
|
||||
onCreateAndStartTask?: (title: string, description: string, executor?: ExecutorConfig) => Promise<void>
|
||||
onUpdateTask?: (title: string, description: string, status: TaskStatus) => Promise<void>
|
||||
}
|
||||
|
||||
@@ -53,6 +54,7 @@ export function TaskFormDialog({
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const [isSubmittingAndStart, setIsSubmittingAndStart] = useState(false)
|
||||
|
||||
const { config } = useConfig()
|
||||
const isEditMode = Boolean(task)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -99,7 +101,7 @@ export function TaskFormDialog({
|
||||
setIsSubmittingAndStart(true)
|
||||
try {
|
||||
if (!isEditMode && onCreateAndStartTask) {
|
||||
await onCreateAndStartTask(title, description)
|
||||
await onCreateAndStartTask(title, description, config?.executor)
|
||||
}
|
||||
|
||||
// Reset form on successful creation
|
||||
|
||||
@@ -14,7 +14,13 @@ import {
|
||||
|
||||
import { TaskKanbanBoard } from "@/components/tasks/TaskKanbanBoard";
|
||||
import { TaskDetailsPanel } from "@/components/tasks/TaskDetailsPanel";
|
||||
import type { TaskStatus, TaskWithAttemptStatus, Project } from "shared/types";
|
||||
import type {
|
||||
TaskStatus,
|
||||
TaskWithAttemptStatus,
|
||||
Project,
|
||||
ExecutorConfig,
|
||||
CreateTaskAndStart,
|
||||
} from "shared/types";
|
||||
import type { DragEndEvent } from "@/components/ui/shadcn-io/kanban";
|
||||
|
||||
type Task = TaskWithAttemptStatus;
|
||||
@@ -26,7 +32,10 @@ interface ApiResponse<T> {
|
||||
}
|
||||
|
||||
export function ProjectTasks() {
|
||||
const { projectId, taskId } = useParams<{ projectId: string; taskId?: string }>();
|
||||
const { projectId, taskId } = useParams<{
|
||||
projectId: string;
|
||||
taskId?: string;
|
||||
}>();
|
||||
const navigate = useNavigate();
|
||||
const [tasks, setTasks] = useState<Task[]>([]);
|
||||
const [project, setProject] = useState<Project | null>(null);
|
||||
@@ -73,7 +82,7 @@ export function ProjectTasks() {
|
||||
// Handle direct navigation to task URLs
|
||||
useEffect(() => {
|
||||
if (taskId && tasks.length > 0) {
|
||||
const task = tasks.find(t => t.id === taskId);
|
||||
const task = tasks.find((t) => t.id === taskId);
|
||||
if (task) {
|
||||
setSelectedTask(task);
|
||||
setIsPanelOpen(true);
|
||||
@@ -115,15 +124,21 @@ export function ProjectTasks() {
|
||||
if (JSON.stringify(prevTasks) === JSON.stringify(newTasks)) {
|
||||
return prevTasks; // Return same reference to prevent re-render
|
||||
}
|
||||
|
||||
|
||||
// Update selectedTask if it exists and has been modified
|
||||
if (selectedTask) {
|
||||
const updatedSelectedTask = newTasks.find(task => task.id === selectedTask.id);
|
||||
if (updatedSelectedTask && JSON.stringify(selectedTask) !== JSON.stringify(updatedSelectedTask)) {
|
||||
const updatedSelectedTask = newTasks.find(
|
||||
(task) => task.id === selectedTask.id
|
||||
);
|
||||
if (
|
||||
updatedSelectedTask &&
|
||||
JSON.stringify(selectedTask) !==
|
||||
JSON.stringify(updatedSelectedTask)
|
||||
) {
|
||||
setSelectedTask(updatedSelectedTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return newTasks;
|
||||
});
|
||||
}
|
||||
@@ -162,18 +177,22 @@ export function ProjectTasks() {
|
||||
|
||||
const handleCreateAndStartTask = async (
|
||||
title: string,
|
||||
description: string
|
||||
description: string,
|
||||
executor?: ExecutorConfig
|
||||
) => {
|
||||
try {
|
||||
const payload: CreateTaskAndStart = {
|
||||
project_id: projectId!,
|
||||
title,
|
||||
description: description || null,
|
||||
executor: executor || null,
|
||||
};
|
||||
|
||||
const response = await makeRequest(
|
||||
`/api/projects/${projectId}/tasks/create-and-start`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
project_id: projectId,
|
||||
title,
|
||||
description: description || null,
|
||||
}),
|
||||
body: JSON.stringify(payload),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user