Просмотр исходного кода

fix: auto-run de-AI after content generation in marathon mode

nonvioce 6 месяцев назад
Родитель
Сommit
1d3dbdf007

+ 12 - 3
src/app/features/novel-writer/components/pipeline/Step4ContentEditor.tsx

@@ -675,6 +675,7 @@ ${antiText}
 
   // Auto-mode: auto-trigger generation on mount
   const autoContentStartedRef = useRef(false);
+  const autoDeAIStartedRef = useRef(false);
   useEffect(() => {
     if (autoMode && apiSettings && !autoContentStartedRef.current && !content && !isGenerating) {
       autoContentStartedRef.current = true;
@@ -682,15 +683,23 @@ ${antiText}
     }
   }, [autoMode]); // eslint-disable-line react-hooks/exhaustive-deps
 
-  // Auto-mode: auto-advance after generation completes
+  // Auto-mode: auto-run de-AI after generation, then auto-advance
   useEffect(() => {
-    if (autoMode && hasGenerated && content.trim() && !isGenerating) {
+    if (!autoMode) return;
+    // Step 1: Content generated, now auto-run de-AI
+    if (hasGenerated && content.trim() && !isGenerating && !isDeAI && !autoDeAIStartedRef.current && apiSettings) {
+      autoDeAIStartedRef.current = true;
+      handleDeAI();
+      return;
+    }
+    // Step 2: de-AI complete, auto-advance
+    if (hasGenerated && content.trim() && !isGenerating && !isDeAI && autoDeAIStartedRef.current) {
       const timer = setTimeout(() => {
         onNext(content);
       }, 2000);
       return () => clearTimeout(timer);
     }
-  }, [autoMode, hasGenerated, content, isGenerating, onNext]);
+  }, [autoMode, hasGenerated, content, isGenerating, isDeAI, onNext, apiSettings, handleDeAI]);
 
   const handleNext = () => {
     if (!content.trim()) return;