@@ -287,8 +287,8 @@ Object.assign(CodemanApp.prototype, {
287287 } ) ;
288288 const createCaseData = await createCaseRes . json ( ) ;
289289 if ( ! createCaseData . success ) throw new Error ( createCaseData . error || 'Failed to create case' ) ;
290- // Use the newly created case data ( API returns { success, case: { name, path } })
291- caseData = createCaseData . case ;
290+ // API returns { success, data: { case: { name, path } } }
291+ caseData = createCaseData . data . case ;
292292 }
293293
294294 const workingDir = caseData . path ;
@@ -425,7 +425,21 @@ Object.assign(CodemanApp.prototype, {
425425 try {
426426 // Get the case path
427427 const caseRes = await fetch ( `/api/cases/${ caseName } ` ) ;
428- const caseData = await caseRes . json ( ) ;
428+ let caseData = await caseRes . json ( ) ;
429+
430+ // Create the case if it doesn't exist
431+ if ( ! caseData . path ) {
432+ const createCaseRes = await fetch ( '/api/cases' , {
433+ method : 'POST' ,
434+ headers : { 'Content-Type' : 'application/json' } ,
435+ body : JSON . stringify ( { name : caseName , description : '' } )
436+ } ) ;
437+ const createCaseData = await createCaseRes . json ( ) ;
438+ if ( ! createCaseData . success ) throw new Error ( createCaseData . error || 'Failed to create case' ) ;
439+ // API returns { success, data: { case: { name, path } } }
440+ caseData = createCaseData . data . case ;
441+ }
442+
429443 const workingDir = caseData . path ;
430444 if ( ! workingDir ) throw new Error ( 'Case path not found' ) ;
431445
0 commit comments