Add duplicate task button (vibe-kanban) (#593)

* ##  Implementation Complete!

I've successfully implemented the duplicate task feature. Here's what was accomplished:

### **Changes Made:**

1. **TaskDialogContext (`frontend/src/contexts/task-dialog-context.tsx`)**
   - Added `initialTask: Task | null` to dialog state
   - Created `openDuplicate(task, options)` method that opens create dialog with initial data
   - Updated all existing methods to include initialTask field

2. **TaskFormDialog (`frontend/src/components/tasks/TaskFormDialog.tsx`)**
   - Added `initialTask?: Task | null` prop
   - Enhanced prefill logic with priority: Edit → Duplicate → Template → Empty
   - Duplicated tasks reset status to 'todo' and start with no images

3. **TaskCard (`frontend/src/components/tasks/TaskCard.tsx`)**
   - Added Copy icon import
   - Added `onDuplicate?: (task: Task) => void` prop
   - Added "Duplicate" menu item with Copy icon between Edit and Delete

4. **TaskKanbanBoard (`frontend/src/components/tasks/TaskKanbanBoard.tsx`)**
   - Added `onDuplicateTask?: (task: Task) => void` prop
   - Passed duplicate handler through to TaskCard components

5. **ProjectTasks (`frontend/src/pages/project-tasks.tsx`)**
   - Added `openDuplicate` to useTaskDialog destructuring
   - Created `handleDuplicateTask` function
   - Passed duplicate handler to TaskKanbanBoard

6. **TaskFormDialogContainer (`frontend/src/components/tasks/TaskFormDialogContainer.tsx`)**
   - Added `initialTask={dialogState.initialTask}` prop to TaskFormDialog

### **How It Works:**

1. **User clicks** the "⋯" menu on any task card
2. **Sees "Duplicate"** option with copy icon between Edit and Delete
3. **Clicks Duplicate** → opens create task dialog with:
   - Title and description pre-filled from original task
   - Status reset to 'todo'
   - No images (clean slate)
   - User can modify and create as normal

### **Key Design Decisions:**
- **Treated as create mode** (not edit) - follows Oracle's recommendation
- **Status always resets to 'todo'** for duplicated tasks
- **No images copied** - simple and safe approach
- **Clean integration** with existing template system

The implementation passes all TypeScript checks and follows the existing codebase patterns. The feature is ready to use!

* Cleanup script changes for task attempt 16b21999-278c-414d-aaab-ae5767d42d77
This commit is contained in:
Louis Knight-Webb
2025-08-29 15:18:42 +01:00
committed by GitHub
parent 305ad90a70
commit 5505a387bc
7 changed files with 67 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ interface TaskDialogState {
mode: 'create' | 'edit';
task: Task | null;
initialTemplate: TaskTemplate | null;
initialTask: Task | null;
afterSubmit?: (task: Task) => void;
}
@@ -41,6 +42,7 @@ interface TaskDialogAPI {
template: TaskTemplate,
options?: TaskDialogOptions
) => void;
openDuplicate: (task: Task, options?: TaskDialogOptions) => void;
close: () => void;
// For dialog component to call after successful operations
@@ -59,6 +61,7 @@ export function TaskDialogProvider({ children }: TaskDialogProviderProps) {
mode: 'create',
task: null,
initialTemplate: null,
initialTask: null,
afterSubmit: undefined,
});
@@ -68,6 +71,7 @@ export function TaskDialogProvider({ children }: TaskDialogProviderProps) {
mode: 'create',
task: null,
initialTemplate: null,
initialTask: null,
afterSubmit: options?.onSuccess,
});
}, []);
@@ -78,6 +82,7 @@ export function TaskDialogProvider({ children }: TaskDialogProviderProps) {
mode: 'edit',
task,
initialTemplate: null,
initialTask: null,
afterSubmit: options?.onSuccess,
});
}, []);
@@ -89,6 +94,21 @@ export function TaskDialogProvider({ children }: TaskDialogProviderProps) {
mode: 'create',
task: null,
initialTemplate: template,
initialTask: null,
afterSubmit: options?.onSuccess,
});
},
[]
);
const openDuplicate = useCallback(
(sourceTask: Task, options?: TaskDialogOptions) => {
setDialogState({
isOpen: true,
mode: 'create',
task: null,
initialTemplate: null,
initialTask: sourceTask,
afterSubmit: options?.onSuccess,
});
},
@@ -119,10 +139,19 @@ export function TaskDialogProvider({ children }: TaskDialogProviderProps) {
openCreate,
openEdit,
openFromTemplate,
openDuplicate,
close,
handleSuccess,
}),
[dialogState, openCreate, openEdit, openFromTemplate, close, handleSuccess]
[
dialogState,
openCreate,
openEdit,
openFromTemplate,
openDuplicate,
close,
handleSuccess,
]
);
return (