@@ -25,8 +25,8 @@ interface GenerationProgress {
2525}
2626
2727interface UseGenerationReturn extends GenerationState {
28- generate : ( prompt : string , imagePath : string | null , settings : GenerationSettings , audioPath ?: string | null ) => Promise < void >
29- generateImage : ( prompt : string , settings : GenerationSettings ) => Promise < void >
28+ generate : ( prompt : string , imagePath : string | null , settings : GenerationSettings , audioPath ?: string | null ) => Promise < { success : boolean ; videoUrl : string | null ; videoPath : string | null } >
29+ generateImage : ( prompt : string , settings : GenerationSettings ) => Promise < { success : boolean } >
3030 cancel : ( ) => void
3131 reset : ( ) => void
3232}
@@ -111,7 +111,7 @@ export function useGeneration(): UseGenerationReturn {
111111 imagePath : string | null ,
112112 settings : GenerationSettings ,
113113 audioPath ?: string | null ,
114- ) => {
114+ ) : Promise < { success : boolean ; videoUrl : string | null ; videoPath : string | null } > => {
115115 const statusMsg = settings . model === 'pro'
116116 ? 'Loading Pro model & generating...'
117117 : 'Generating video...'
@@ -132,6 +132,9 @@ export function useGeneration(): UseGenerationReturn {
132132 abortControllerRef . current = new AbortController ( )
133133 let progressInterval : ReturnType < typeof setInterval > | null = null
134134 let shouldApplyPollingUpdates = true
135+ let succeeded = false
136+ let resultVideoUrl : string | null = null
137+ let resultVideoPath : string | null = null
135138
136139 try {
137140 // Prepare JSON body
@@ -223,6 +226,8 @@ export function useGeneration(): UseGenerationReturn {
223226 const videoPathNormalized = result . video_path . replace ( / \\ / g, '/' )
224227 const fileUrl = videoPathNormalized . startsWith ( '/' ) ? `file://${ videoPathNormalized } ` : `file:///${ videoPathNormalized } `
225228
229+ resultVideoUrl = fileUrl
230+ resultVideoPath = result . video_path
226231 setState ( {
227232 isGenerating : false ,
228233 progress : 100 ,
@@ -235,6 +240,7 @@ export function useGeneration(): UseGenerationReturn {
235240 imagePaths : [ ] ,
236241 error : null ,
237242 } )
243+ succeeded = true
238244 } else if ( result . status === 'cancelled' ) {
239245 setState ( prev => ( {
240246 ...prev ,
@@ -265,6 +271,7 @@ export function useGeneration(): UseGenerationReturn {
265271 clearInterval ( progressInterval )
266272 }
267273 }
274+ return { success : succeeded , videoUrl : resultVideoUrl , videoPath : resultVideoPath }
268275 } , [ ] )
269276
270277 const cancel = useCallback ( async ( ) => {
@@ -288,7 +295,7 @@ export function useGeneration(): UseGenerationReturn {
288295 const generateImage = useCallback ( async (
289296 prompt : string ,
290297 settings : GenerationSettings
291- ) => {
298+ ) : Promise < { success : boolean } > => {
292299 if ( forceApiGenerations ) {
293300 try {
294301 const response = await backendFetch ( '/api/settings' )
@@ -304,7 +311,7 @@ export function useGeneration(): UseGenerationReturn {
304311 blocking : false ,
305312 } ,
306313 } ) )
307- return
314+ return { success : false }
308315 }
309316 }
310317 } catch {
@@ -317,7 +324,7 @@ export function useGeneration(): UseGenerationReturn {
317324 blocking : false ,
318325 } ,
319326 } ) )
320- return
327+ return { success : false }
321328 }
322329 }
323330 }
@@ -338,6 +345,7 @@ export function useGeneration(): UseGenerationReturn {
338345 } )
339346
340347 abortControllerRef . current = new AbortController ( )
348+ let succeeded = false
341349
342350 try {
343351 // Skip prompt enhancement for T2I - use original prompt directly
@@ -425,6 +433,7 @@ export function useGeneration(): UseGenerationReturn {
425433 imagePaths : rawPaths , // All image paths
426434 error : null ,
427435 } )
436+ succeeded = true
428437 }
429438 } else if ( result . status === 'cancelled' ) {
430439 setState ( prev => ( {
@@ -451,6 +460,7 @@ export function useGeneration(): UseGenerationReturn {
451460 } ) )
452461 }
453462 }
463+ return { success : succeeded }
454464 } , [ appSettings . hasFalApiKey , forceApiGenerations , refreshSettings ] )
455465
456466 const reset = useCallback ( ( ) => {
0 commit comments