Skip to content

Commit 236fc37

Browse files
feat: integrate task directory store into execution flow (#131)
## Summary - Integrates `taskDirectoryStore` into task execution flow - Tasks now check stored directory mappings before deriving paths from workspace - Persists directory assignments when repos are set or cloned - Enables per-task directory customization and repo sharing across tasks ## Changes - **`taskExecutionStore.ts`**: Updated `initializeRepoPath()` to check `taskDirectoryStore` first, then fall back to workspace-based derivation. Updated `setRepoPath()` to persist task→directory mapping. - **`cloneStore.ts`**: Updated `handleComplete()` to save repo→directory mapping after successful clone for future task reuse. ## Test Plan - [ ] Clone a repo for a task → verify mapping is saved - [ ] Run another task with the same repo → verify it reuses the cloned directory - [ ] Manually set a directory for a task → verify it persists across app restarts - [ ] Verify tasks without `repository_config` still work --- **Stack**: Built on top of: - PR #128: Clone progress UI - PR #130: Task directory store foundation
1 parent f801277 commit 236fc37

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/renderer/features/task-detail/stores/taskExecutionStore.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
} from "@shared/types";
1414
import { cloneStore } from "@stores/cloneStore";
1515
import { repositoryWorkspaceStore } from "@stores/repositoryWorkspaceStore";
16+
import { useTaskDirectoryStore } from "@stores/taskDirectoryStore";
1617
import { expandTildePath } from "@utils/path";
1718
import { create } from "zustand";
1819
import { persist } from "zustand/middleware";
@@ -248,6 +249,11 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
248249

249250
setRepoPath: (taskId: string, repoPath: string | null) => {
250251
get().updateTaskState(taskId, { repoPath });
252+
253+
// Persist to taskDirectoryStore
254+
if (repoPath) {
255+
useTaskDirectoryStore.getState().setTaskDirectory(taskId, repoPath);
256+
}
251257
},
252258

253259
setCurrentTaskId: (taskId: string, currentTaskId: string | null) => {
@@ -729,7 +735,33 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
729735
const store = get();
730736
const taskState = store.getTaskState(taskId);
731737

732-
if (taskState.repoPath || !task.repository_config) return;
738+
if (taskState.repoPath) return;
739+
740+
// 1. Check taskDirectoryStore first
741+
const repoKey = task.repository_config
742+
? `${task.repository_config.organization}/${task.repository_config.repository}`
743+
: undefined;
744+
745+
const storedDirectory = useTaskDirectoryStore
746+
.getState()
747+
.getTaskDirectory(taskId, repoKey);
748+
if (storedDirectory) {
749+
store.setRepoPath(taskId, storedDirectory);
750+
751+
// Validate repo exists
752+
window.electronAPI
753+
?.validateRepo(storedDirectory)
754+
.then((exists) => {
755+
store.updateTaskState(taskId, { repoExists: exists });
756+
})
757+
.catch(() => {
758+
store.updateTaskState(taskId, { repoExists: false });
759+
});
760+
return;
761+
}
762+
763+
// 2. Fallback to deriving from workspace (existing logic)
764+
if (!task.repository_config) return;
733765

734766
const { defaultWorkspace } = useAuthStore.getState();
735767
if (!defaultWorkspace) return;

src/renderer/stores/cloneStore.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useTaskExecutionStore } from "@features/task-detail/stores/taskExecutionStore";
22
import type { RepositoryConfig } from "@shared/types";
3+
import { useTaskDirectoryStore } from "@stores/taskDirectoryStore";
34
import { create } from "zustand";
45

56
type CloneStatus = "cloning" | "complete" | "error";
@@ -50,6 +51,12 @@ export const cloneStore = create<CloneStore>((set, get) => {
5051
const operation = get().operations[cloneId];
5152
if (operation) {
5253
updateTaskRepoExists(operation.targetPath, true);
54+
55+
// Save repo → directory mapping for future tasks
56+
const repoKey = `${operation.repository.organization}/${operation.repository.repository}`;
57+
useTaskDirectoryStore
58+
.getState()
59+
.setRepoDirectory(repoKey, operation.targetPath);
5360
}
5461

5562
window.setTimeout(

0 commit comments

Comments
 (0)