Skip to content

Commit 45e1282

Browse files
jonathanlabclaude
andcommitted
fix: copy working directory when duplicating task
- Update useDuplicateTask to copy repoPath from original task to new task - Ensures duplicated tasks inherit the working directory configuration - Apply linter formatting to vite.main.config.mts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent c84c632 commit 45e1282

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
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
});

vite.main.config.mts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { copyFileSync, mkdirSync } from "node:fs";
2+
import { join } from "node:path";
13
import { defineConfig, type Plugin } from "vite";
2-
import { copyFileSync, mkdirSync } from "fs";
3-
import { join } from "path";
44

55
/**
66
* Custom Vite plugin to fix circular __filename references in bundled ESM packages.
@@ -38,8 +38,14 @@ function copyAgentTemplates(): Plugin {
3838
return {
3939
name: "copy-agent-templates",
4040
writeBundle() {
41-
const templateSrc = join(__dirname, "node_modules/@posthog/agent/dist/templates/plan-template.md");
42-
const templateDest = join(__dirname, ".vite/build/templates/plan-template.md");
41+
const templateSrc = join(
42+
__dirname,
43+
"node_modules/@posthog/agent/dist/templates/plan-template.md",
44+
);
45+
const templateDest = join(
46+
__dirname,
47+
".vite/build/templates/plan-template.md",
48+
);
4349

4450
mkdirSync(join(__dirname, ".vite/build/templates"), { recursive: true });
4551
copyFileSync(templateSrc, templateDest);

0 commit comments

Comments
 (0)