From 8c486e7efa254bc11f7727ae2aa581b366b9ffa8 Mon Sep 17 00:00:00 2001
From: hit-cxf <2024111082@stu.hit.edu.cn>
Date: Sat, 04 Apr 2026 20:28:34 +0800
Subject: [PATCH] aigc-claw-v2

---
 aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx |   67 +++++++++++++++++++++++++--------
 1 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx b/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
index 209ecbf..e021c92 100644
--- a/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
+++ b/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
@@ -130,6 +130,15 @@
           pollRef.current = null;
           return;
         }
+        if (status.status === 'stopped') {
+          updateStageState(stageId, {
+            status: 'stopped',
+            error: '手动停止',
+            progressMessage: '已停止',
+          });
+          pollRef.current = null;
+          return;
+        }
         // 如果后端状态不再是 running,提前停止轮询(比如变成了 waiting_intervention 或已完成)
         if (status.status !== 'running') {
           pollRef.current = null;
@@ -434,12 +443,15 @@
       const result = await startProject({
         idea: params.idea,
         style: params.style,
+        video_ratio: params.video_ratio,
         llm_model: params.llm_model,
         vlm_model: params.vlm_model,
         image_t2i_model: params.image_t2i_model,
         image_it2i_model: params.image_it2i_model,
         video_model: params.video_model,
         enable_concurrency: params.enable_concurrency,
+        web_search: params.web_search,
+        expand_idea: params.expand_idea,
       });
       setSessionId(result.session_id);
 
@@ -460,6 +472,7 @@
         idea: params.idea,
         session_id: result.session_id,
         style: params.style,
+        video_ratio: params.video_ratio,
         llm_model: params.llm_model,
         vlm_model: params.vlm_model,
         image_t2i_model: params.image_t2i_model,
@@ -540,6 +553,7 @@
           image_t2i_model: projectParams?.image_t2i_model,
           image_it2i_model: projectParams?.image_it2i_model,
           video_model: projectParams?.video_model,
+          video_ratio: projectParams?.video_ratio,
           video_sound: videoSound,
           video_shot_type: videoShotType,
         };
@@ -619,6 +633,20 @@
   // ── 用户介入修改 ──
   const handleIntervene = async (stageId: string, modifications: Record<string, any>) => {
     if (!sessionId) return;
+    
+    // 构建完整的 inputData 传给后端,确保比例等参数能传递
+    const inputData: Record<string, any> = {
+      ...modifications,
+      session_id: sessionId,
+      style: projectParams?.style,
+      video_ratio: projectParams?.video_ratio,
+      llm_model: projectParams?.llm_model,
+      vlm_model: projectParams?.vlm_model,
+      image_t2i_model: projectParams?.image_t2i_model,
+      image_it2i_model: projectParams?.image_it2i_model,
+      video_model: projectParams?.video_model,
+    };
+
     // 设置 running 状态以便显示进度条(如 Logline 选择后生成剧本)
     // 若选择了 Logline,将其保存到 artifact 以便 ScriptStage 在生成期间展示
     // 若选择了模式,保留已选 Logline 并设置 generating 状态
@@ -630,7 +658,7 @@
     setIsRunning(true);
     updateStageState(stageId, { status: 'running', progress: 0, progressMessage: '处理中...', ...(artifactPatch ? { artifact: artifactPatch } : {}) });
     try {
-      const response = await intervene(sessionId, stageId, modifications);
+      const response = await intervene(sessionId, stageId, inputData);
       for await (const event of parseStreamEvents(response)) {
         if (event.type === 'progress') {
           updateStageState(stageId, {
@@ -887,8 +915,7 @@
         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,
+            video_ratio: projectParams?.video_ratio,
       };
 
       // 尝试获取场景数
@@ -959,14 +986,19 @@
         } catch { /* ignore */ }
       }
 
-      // 如果 current_stage 不在 completedStages 中,也需要显示(可能是 stage_completed 或 running 状态)
+      // 如果 current_stage 不在 completedStages 中,也需要显示(可能是 stage_completed、running, stopped, 或 error 状态)
       if (currentStage && !completedStages.includes(currentStage)) {
+        const isError = status.status === 'error';
+        const isWaiting = status.status === 'waiting_in_stage';
+        const isCompleted = status.status === 'stage_completed';
+        const isStopped = status.status === 'stopped';
+        
         newStates[currentStage] = {
-          status: status.status === 'waiting_in_stage' ? 'waiting' : (status.status === 'stage_completed' ? 'completed' : 'running'),
+          status: isError ? 'error' : (isWaiting ? 'waiting' : (isCompleted ? 'completed' : (isStopped ? 'stopped' : 'running'))),
           progress: 100,
-          progressMessage: status.status === 'waiting_in_stage' ? '等待确认' : (status.status === 'stage_completed' ? '已完成' : '进行中'),
+          progressMessage: isError ? '执行失败' : (isWaiting ? '等待确认' : (isCompleted ? '已完成' : (isStopped ? '已停止' : '进行中'))),
           artifact: null,
-          error: null,
+          error: isError ? (status.error || '执行出错') : (isStopped ? '手动停止' : null),
         };
         try {
           const artResult = await getArtifact(sid, currentStage);
@@ -988,6 +1020,7 @@
           video_model: s.video_model || '',
           expand_idea: s.expand_idea || false,
           enable_concurrency: s.enable_concurrency || false,
+          web_search: s.web_search || false,
         });
       }
 
@@ -1023,21 +1056,18 @@
   };
 
   // ── 删除历史记录 ──
-  const handleDeleteSession = async (sid: string, password: string) => {
-    await deleteSession(sid, password);
+  const handleDeleteSession = async (sid: string) => {
+    await deleteSession(sid);
     setHistory(prev => prev.filter(h => h.id !== sid));
   };
 
   // ── 模型配置变更处理 ──
   const handleModelConfigChange = (config: ModelConfig) => {
     setProjectParams(prev => prev ? { ...prev, ...config } : null);
-    // 同步到后端会话元数据(需要将 boolean 转为 string)
+    // 同步到后端会话元数据
     if (sessionId) {
-      const stringConfig: Record<string, string> = {};
-      for (const [key, value] of Object.entries(config)) {
-        stringConfig[key] = String(value);
-      }
-      updateModels(sessionId, stringConfig).catch(console.error);
+      const payload: Record<string, any> = { ...config };
+      updateModels(sessionId, payload).catch(console.error);
     }
   };
 
@@ -1051,6 +1081,8 @@
         video_model: projectParams.video_model,
         video_ratio: projectParams.video_ratio,
         enable_concurrency: projectParams.enable_concurrency || false,
+        // web_search: projectParams.web_search || false,
+        // expand_idea: projectParams.expand_idea || false,
       }
     : undefined;
 
@@ -1077,6 +1109,7 @@
     } else {
       // current_stage 本身:根据 stageStates 判断
       stageStatuses[s] = stageStates[s]?.status || 'pending';
+      if (stageStatuses[s] === 'stopped') stageStatuses[s] = 'stopped';
     }
   }
 
@@ -1092,12 +1125,14 @@
   if (hasRunning) computedStatus = 'running';
   else if (hasWaiting) computedStatus = 'waiting_in_stage';
   else if (hasError) computedStatus = 'error';
+  // Check if stopped in stageStates
+  else if (Object.values(stageStates).some(s => s.status === 'stopped')) computedStatus = 'stopped';
   else if (allCompleted && stageStates[STAGE_ORDER[STAGE_ORDER.length - 1]]?.status === 'completed') {
     computedStatus = 'session_completed';
   } else if (allCompleted) {
     computedStatus = 'stage_completed';
   } else {
-    computedStatus = 'idle';
+    computedStatus = Object.values(stageStates).some(s => s.status === 'stopped') ? 'stopped' : 'idle';
   }
 
   const projectStatus = sessionId ? computedStatus : undefined;

--
Gitblit v1.8.0