diff --git a/src/renderer/components/TaskCreate.tsx b/src/renderer/components/TaskCreate.tsx index a03599c29f..93af0b965e 100644 --- a/src/renderer/components/TaskCreate.tsx +++ b/src/renderer/components/TaskCreate.tsx @@ -22,6 +22,7 @@ import { useHotkeys } from "react-hotkeys-hook"; import { useRepositoryIntegration } from "../hooks/useRepositoryIntegration"; import { useCreateTask } from "../hooks/useTasks"; import { useAuthStore } from "../stores/authStore"; +import { useFolderPickerStore } from "../stores/folderPickerStore"; import { useTabStore } from "../stores/tabStore"; import { useTaskExecutionStore } from "../stores/taskExecutionStore"; import { @@ -45,6 +46,7 @@ export function TaskCreate({ open, onOpenChange }: TaskCreateProps) { const { client, isAuthenticated } = useAuthStore(); const { setRepoPath: saveRepoPath, setRepoWorkingDir } = useTaskExecutionStore(); + const { lastSelectedFolder, setLastSelectedFolder } = useFolderPickerStore(); const [isExpanded, setIsExpanded] = useState(false); const [createMore, setCreateMore] = useState(false); @@ -63,7 +65,7 @@ export function TaskCreate({ open, onOpenChange }: TaskCreateProps) { title: "", description: "", repository: "", - folderPath: "", + folderPath: lastSelectedFolder || "", }, }); @@ -135,6 +137,7 @@ export function TaskCreate({ open, onOpenChange }: TaskCreateProps) { // Save the local working directory to the task execution store if (data.folderPath && data.folderPath.trim().length > 0) { saveRepoPath(newTask.id, data.folderPath); + setLastSelectedFolder(data.folderPath); // Also save the mapping for GitHub repos to reuse later if (repositoryConfig) { diff --git a/src/renderer/components/TaskItem.tsx b/src/renderer/components/TaskItem.tsx index c2da0d001f..19e9497d16 100644 --- a/src/renderer/components/TaskItem.tsx +++ b/src/renderer/components/TaskItem.tsx @@ -55,6 +55,7 @@ function TaskItemComponent({ const createdAt = new Date(task.created_at); const timeAgo = formatDistanceToNow(createdAt, { addSuffix: true }); const dragPreviewRef = useRef(null); + const status = task.status || "Backlog"; const handleDragStart = (e: React.DragEvent) => { if (dragPreviewRef.current) { diff --git a/src/renderer/hooks/useTasks.ts b/src/renderer/hooks/useTasks.ts index bc98335c4b..24103b3a1f 100644 --- a/src/renderer/hooks/useTasks.ts +++ b/src/renderer/hooks/useTasks.ts @@ -1,6 +1,7 @@ import type { Task } from "@shared/types"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useAuthStore } from "../stores/authStore"; +import { useTaskExecutionStore } from "../stores/taskExecutionStore"; export const taskKeys = { all: ["tasks"] as const, @@ -120,7 +121,15 @@ export function useDuplicateTask() { if (!client) throw new Error("Not authenticated"); return (await client.duplicateTask(taskId)) as unknown as Task; }, - onSuccess: () => { + onSuccess: (newTask, originalTaskId) => { + // Copy working directory from original task to new task + const { getTaskState, setRepoPath } = useTaskExecutionStore.getState(); + const originalState = getTaskState(originalTaskId); + + if (originalState.repoPath) { + setRepoPath(newTask.id, originalState.repoPath); + } + queryClient.invalidateQueries({ queryKey: taskKeys.lists() }); }, }); diff --git a/src/renderer/stores/folderPickerStore.ts b/src/renderer/stores/folderPickerStore.ts index 6e4eb6363e..aace624db3 100644 --- a/src/renderer/stores/folderPickerStore.ts +++ b/src/renderer/stores/folderPickerStore.ts @@ -3,7 +3,9 @@ import { persist } from "zustand/middleware"; interface FolderPickerStore { recentDirectories: string[]; + lastSelectedFolder: string | null; addRecentDirectory: (path: string) => void; + setLastSelectedFolder: (path: string) => void; getFilteredRecent: (query: string) => string[]; } @@ -11,6 +13,7 @@ export const useFolderPickerStore = create()( persist( (set, get) => ({ recentDirectories: [], + lastSelectedFolder: null, addRecentDirectory: (path: string) => { if (!path || path.trim().length === 0) return; @@ -22,6 +25,10 @@ export const useFolderPickerStore = create()( }); }, + setLastSelectedFolder: (path: string) => { + set({ lastSelectedFolder: path }); + }, + getFilteredRecent: (query: string) => { const state = get(); if (!query || query.trim().length === 0) { diff --git a/vite.main.config.mts b/vite.main.config.mts index 7fb1e92efd..58902f1647 100644 --- a/vite.main.config.mts +++ b/vite.main.config.mts @@ -1,6 +1,6 @@ +import { copyFileSync, mkdirSync } from "node:fs"; +import { join } from "node:path"; import { defineConfig, type Plugin } from "vite"; -import { copyFileSync, mkdirSync } from "fs"; -import { join } from "path"; /** * Custom Vite plugin to fix circular __filename references in bundled ESM packages. @@ -38,8 +38,14 @@ function copyAgentTemplates(): Plugin { return { name: "copy-agent-templates", writeBundle() { - const templateSrc = join(__dirname, "node_modules/@posthog/agent/dist/templates/plan-template.md"); - const templateDest = join(__dirname, ".vite/build/templates/plan-template.md"); + const templateSrc = join( + __dirname, + "node_modules/@posthog/agent/dist/templates/plan-template.md", + ); + const templateDest = join( + __dirname, + ".vite/build/templates/plan-template.md", + ); mkdirSync(join(__dirname, ".vite/build/templates"), { recursive: true }); copyFileSync(templateSrc, templateDest);