From adbc6c83f305726683f921f7f3b1e74007d92207 Mon Sep 17 00:00:00 2001
From: hit-cxf <2024111082@stu.hit.edu.cn>
Date: Wed, 03 Jun 2026 10:47:29 +0800
Subject: [PATCH] Fix the concurrent blocking issue of image and video regeneration

---
 video-claw/video-claw/frontend/components/WorkflowPanel.tsx |   37 +++++++++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/video-claw/video-claw/frontend/components/WorkflowPanel.tsx b/video-claw/video-claw/frontend/components/WorkflowPanel.tsx
index d61b6e7..9e532b2 100644
--- a/video-claw/video-claw/frontend/components/WorkflowPanel.tsx
+++ b/video-claw/video-claw/frontend/components/WorkflowPanel.tsx
@@ -682,6 +682,13 @@
   // ── 用户介入修改 ──
   const handleIntervene = async (stageId: string, modifications: Record<string, any>) => {
     if (!sessionId) return;
+    const isBackgroundItemRegeneration =
+      (stageId === 'character_design' && (
+        Array.isArray(modifications.regenerate_characters) ||
+        Array.isArray(modifications.regenerate_settings)
+      )) ||
+      (stageId === 'reference_generation' && Array.isArray(modifications.regenerate_scenes)) ||
+      (stageId === 'video_generation' && Array.isArray(modifications.regenerate_clips));
     
     // 构建完整的 inputData 传给后端,确保比例等参数能传递
     const inputData: Record<string, any> = {
@@ -695,6 +702,8 @@
       image_t2i_model: projectParams?.image_t2i_model,
       image_it2i_model: projectParams?.image_it2i_model,
       video_model: projectParams?.video_model,
+      video_sound: videoSound,
+      video_shot_type: videoShotType,
     };
 
     // 设置 running 状态以便显示进度条(如 Logline 选择后生成剧本)
@@ -705,16 +714,22 @@
       : modifications.selected_mode
         ? { phase: 'generating', selected_logline: stageStates[stageId]?.artifact?.selected_logline }
         : undefined;
-    setIsRunning(true);
-    updateStageState(stageId, { status: 'running', progress: 0, progressMessage: '处理中...', ...(artifactPatch ? { artifact: artifactPatch } : {}) });
+    if (!isBackgroundItemRegeneration) {
+      setIsRunning(true);
+      updateStageState(stageId, { status: 'running', progress: 0, progressMessage: '处理中...', ...(artifactPatch ? { artifact: artifactPatch } : {}) });
+    } else if (artifactPatch) {
+      updateStageState(stageId, { artifact: artifactPatch });
+    }
     try {
       const response = await intervene(sessionId, stageId, inputData);
       for await (const event of parseStreamEvents(response)) {
         if (event.type === 'progress') {
-          updateStageState(stageId, {
-            progress: event.percent || 0,
-            progressMessage: event.message || '',
-          });
+          if (!isBackgroundItemRegeneration) {
+            updateStageState(stageId, {
+              progress: event.percent || 0,
+              progressMessage: event.message || '',
+            });
+          }
           // 处理 asset_complete 实时事件
           if (event.data?.asset_complete) {
             const assetUpdate = event.data.asset_complete;
@@ -790,7 +805,11 @@
           }
         } else if (event.type === 'stage_complete') {
           const artResult = await getArtifact(sessionId, stageId);
-          updateStageState(stageId, { artifact: artResult.artifact, status: 'waiting' });
+          if (isBackgroundItemRegeneration) {
+            updateStageState(stageId, { artifact: artResult.artifact });
+          } else {
+            updateStageState(stageId, { artifact: artResult.artifact, status: 'waiting' });
+          }
         } else if (event.type === 'error') {
           console.error('Intervention error:', event.content);
         }
@@ -798,7 +817,9 @@
     } catch (error: any) {
       console.error('Intervention error:', error);
     } finally {
-      setIsRunning(false);
+      if (!isBackgroundItemRegeneration) {
+        setIsRunning(false);
+      }
     }
   };
 

--
Gitblit v1.8.0