Skip to content

Commit df6b057

Browse files
committed
feat: integrate task directory store into execution flow
- Use taskDirectoryStore for directory resolution in initializeRepoPath() - Persist directory mappings when setRepoPath() is called - Save repo→directory mapping after clone completion - Support tasks without repository_config Enables per-task directory customization and repo sharing across tasks.
1 parent eea62c0 commit df6b057

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
@@ -12,6 +12,7 @@ import type {
1212
TaskRun,
1313
} from "@shared/types";
1414
import { cloneStore } from "@stores/cloneStore";
15+
import { useTaskDirectoryStore } from "@stores/taskDirectoryStore";
1516
import { expandTildePath } from "@utils/path";
1617
import { create } from "zustand";
1718
import { persist } from "zustand/middleware";
@@ -247,6 +248,11 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
247248

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

252258
setCurrentTaskId: (taskId: string, currentTaskId: string | null) => {
@@ -732,7 +738,33 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
732738
const store = get();
733739
const taskState = store.getTaskState(taskId);
734740

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

737769
const { defaultWorkspace } = useAuthStore.getState();
738770
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)