Skip to content

Commit 401412b

Browse files
jonathanlabclaude
andauthored
feat: remember last selected folder (#51)
Co-authored-by: Claude <[email protected]>
1 parent c84c632 commit 401412b

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/renderer/components/TaskCreate.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { useHotkeys } from "react-hotkeys-hook";
2222
import { useRepositoryIntegration } from "../hooks/useRepositoryIntegration";
2323
import { useCreateTask } from "../hooks/useTasks";
2424
import { useAuthStore } from "../stores/authStore";
25+
import { useFolderPickerStore } from "../stores/folderPickerStore";
2526
import { useTabStore } from "../stores/tabStore";
2627
import { useTaskExecutionStore } from "../stores/taskExecutionStore";
2728
import {
@@ -45,6 +46,7 @@ export function TaskCreate({ open, onOpenChange }: TaskCreateProps) {
4546
const { client, isAuthenticated } = useAuthStore();
4647
const { setRepoPath: saveRepoPath, setRepoWorkingDir } =
4748
useTaskExecutionStore();
49+
const { lastSelectedFolder, setLastSelectedFolder } = useFolderPickerStore();
4850

4951
const [isExpanded, setIsExpanded] = useState(false);
5052
const [createMore, setCreateMore] = useState(false);
@@ -63,7 +65,7 @@ export function TaskCreate({ open, onOpenChange }: TaskCreateProps) {
6365
title: "",
6466
description: "",
6567
repository: "",
66-
folderPath: "",
68+
folderPath: lastSelectedFolder || "",
6769
},
6870
});
6971

@@ -135,6 +137,7 @@ export function TaskCreate({ open, onOpenChange }: TaskCreateProps) {
135137
// Save the local working directory to the task execution store
136138
if (data.folderPath && data.folderPath.trim().length > 0) {
137139
saveRepoPath(newTask.id, data.folderPath);
140+
setLastSelectedFolder(data.folderPath);
138141

139142
// Also save the mapping for GitHub repos to reuse later
140143
if (repositoryConfig) {

src/renderer/components/TaskItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function TaskItemComponent({
5555
const createdAt = new Date(task.created_at);
5656
const timeAgo = formatDistanceToNow(createdAt, { addSuffix: true });
5757
const dragPreviewRef = useRef<HTMLDivElement>(null);
58+
const status = task.status || "Backlog";
5859

5960
const handleDragStart = (e: React.DragEvent) => {
6061
if (dragPreviewRef.current) {

src/renderer/stores/folderPickerStore.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ import { persist } from "zustand/middleware";
33

44
interface FolderPickerStore {
55
recentDirectories: string[];
6+
lastSelectedFolder: string | null;
67
addRecentDirectory: (path: string) => void;
8+
setLastSelectedFolder: (path: string) => void;
79
getFilteredRecent: (query: string) => string[];
810
}
911

1012
export const useFolderPickerStore = create<FolderPickerStore>()(
1113
persist(
1214
(set, get) => ({
1315
recentDirectories: [],
16+
lastSelectedFolder: null,
1417

1518
addRecentDirectory: (path: string) => {
1619
if (!path || path.trim().length === 0) return;
@@ -22,6 +25,10 @@ export const useFolderPickerStore = create<FolderPickerStore>()(
2225
});
2326
},
2427

28+
setLastSelectedFolder: (path: string) => {
29+
set({ lastSelectedFolder: path });
30+
},
31+
2532
getFilteredRecent: (query: string) => {
2633
const state = get();
2734
if (!query || query.trim().length === 0) {

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)