@@ -62,6 +62,8 @@ interface TaskExecutionState {
6262interface TaskExecutionStore {
6363 // State per task ID
6464 taskStates : Record < string , TaskExecutionState > ;
65+ // Repository (org/repo) to working directory mapping
66+ repoToCwd : Record < string , string > ;
6567
6668 // Basic state accessors
6769 getTaskState : ( taskId : string ) => TaskExecutionState ;
@@ -79,8 +81,12 @@ interface TaskExecutionStore {
7981 setProgress : ( taskId : string , progress : AgentTaskProgress | null ) => void ;
8082 clearTaskState : ( taskId : string ) => void ;
8183
84+ // Repository to working directory mapping
85+ getRepoWorkingDir : ( repoKey : string ) => string | null ;
86+ setRepoWorkingDir : ( repoKey : string , path : string ) => void ;
87+
8288 // High-level task execution actions
83- selectRepositoryForTask : ( taskId : string ) => Promise < void > ;
89+ selectRepositoryForTask : ( taskId : string , repoKey ?: string ) => Promise < void > ;
8490 runTask : ( taskId : string , task : Task ) => Promise < void > ;
8591 cancelTask : ( taskId : string ) => Promise < void > ;
8692 clearTaskLogs : ( taskId : string ) => void ;
@@ -105,12 +111,26 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
105111 persist (
106112 ( set , get ) => ( {
107113 taskStates : { } ,
114+ repoToCwd : { } ,
108115
109116 getTaskState : ( taskId : string ) => {
110117 const state = get ( ) ;
111118 return state . taskStates [ taskId ] || { ...defaultTaskState } ;
112119 } ,
113120
121+ getRepoWorkingDir : ( repoKey : string ) => {
122+ return get ( ) . repoToCwd [ repoKey ] || null ;
123+ } ,
124+
125+ setRepoWorkingDir : ( repoKey : string , path : string ) => {
126+ set ( ( state ) => ( {
127+ repoToCwd : {
128+ ...state . repoToCwd ,
129+ [ repoKey ] : path ,
130+ } ,
131+ } ) ) ;
132+ } ,
133+
114134 updateTaskState : (
115135 taskId : string ,
116136 updates : Partial < TaskExecutionState > ,
@@ -338,7 +358,7 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
338358 } ,
339359
340360 // High-level task execution actions
341- selectRepositoryForTask : async ( taskId : string ) => {
361+ selectRepositoryForTask : async ( taskId : string , repoKey ?: string ) => {
342362 const store = get ( ) ;
343363 try {
344364 const selected = await window . electronAPI ?. selectDirectory ( ) ;
@@ -372,11 +392,15 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
372392 const { response } = result ;
373393 if ( response === 0 ) {
374394 // Let user reselect and validate again
375- return store . selectRepositoryForTask ( taskId ) ;
395+ return store . selectRepositoryForTask ( taskId , repoKey ) ;
376396 }
377397 return ;
378398 }
379399 store . setRepoPath ( taskId , selected ) ;
400+ // Save mapping for future tasks with the same repository
401+ if ( repoKey ) {
402+ store . setRepoWorkingDir ( repoKey , selected ) ;
403+ }
380404 }
381405 } catch ( err ) {
382406 store . addLog (
0 commit comments