Skip to content

Commit d09a467

Browse files
authored
feat: save last used project (#778)
### TL;DR Update the task directory handling to persist the last used directory when changed in the TaskInput component. ### What changed? - Added a new `setLastUsedDirectory` function to the `taskDirectoryStore` - Updated the `TaskInput` component to call `setLastUsedDirectory` when a directory is selected - This ensures the last used directory is properly saved when changed through the UI ### How to test? 1. Open the application and create a new task 2. Select a directory for the task 3. Create another new task 4. Verify that the previously selected directory is pre-selected ### Why make this change? Previously, when a user selected a directory in the TaskInput component, the selection wasn't being saved to the store's `lastUsedDirectory` state. This change improves the user experience by remembering their last directory choice, making it faster to create multiple tasks in the same directory.
1 parent 57d229a commit d09a467

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

apps/twig/src/renderer/features/task-detail/components/TaskInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function TaskInput() {
7070

7171
const handleDirectoryChange = (newPath: string) => {
7272
setSelectedDirectory(newPath);
73-
setLastUsedDirectory(newPath);
73+
setLastUsedDirectory(newPath || null);
7474
};
7575

7676
const effectiveWorkspaceMode = workspaceMode;

apps/twig/src/renderer/stores/taskDirectoryStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface TaskDirectoryState {
1010
lastUsedDirectory: string | null;
1111
getTaskDirectory: (taskId: string, repoKey?: string) => string | null;
1212
setRepoDirectory: (repoKey: string, directory: string) => void;
13-
setLastUsedDirectory: (directory: string) => void;
13+
setLastUsedDirectory: (directory: string | null) => void;
1414
clearRepoDirectory: (repoKey: string) => void;
1515
validateLastUsedDirectory: () => Promise<void>;
1616
}
@@ -52,7 +52,7 @@ export const useTaskDirectoryStore = create<TaskDirectoryState>()(
5252
}));
5353
},
5454

55-
setLastUsedDirectory: (directory: string) => {
55+
setLastUsedDirectory: (directory: string | null) => {
5656
set({ lastUsedDirectory: directory });
5757
},
5858

0 commit comments

Comments
 (0)