Skip to content

Commit 0a95dad

Browse files
jonathanlabclaude
andauthored
fix: copy working directory when duplicating task (#52)
Co-authored-by: Claude <[email protected]>
1 parent 401412b commit 0a95dad

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/renderer/hooks/useTasks.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Task } from "@shared/types";
22
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
33
import { useAuthStore } from "../stores/authStore";
4+
import { useTaskExecutionStore } from "../stores/taskExecutionStore";
45

56
export const taskKeys = {
67
all: ["tasks"] as const,
@@ -120,7 +121,15 @@ export function useDuplicateTask() {
120121
if (!client) throw new Error("Not authenticated");
121122
return (await client.duplicateTask(taskId)) as unknown as Task;
122123
},
123-
onSuccess: () => {
124+
onSuccess: (newTask, originalTaskId) => {
125+
// Copy working directory from original task to new task
126+
const { getTaskState, setRepoPath } = useTaskExecutionStore.getState();
127+
const originalState = getTaskState(originalTaskId);
128+
129+
if (originalState.repoPath) {
130+
setRepoPath(newTask.id, originalState.repoPath);
131+
}
132+
124133
queryClient.invalidateQueries({ queryKey: taskKeys.lists() });
125134
},
126135
});

0 commit comments

Comments
 (0)