From 6104bf884911469b3173335cbd8e6868cbb29f6b Mon Sep 17 00:00:00 2001 From: "IGNY8 VPS (Salman)" Date: Tue, 11 Nov 2025 19:14:04 +0000 Subject: [PATCH] image promtp ang progress modal texts --- backend/igny8_core/ai/engine.py | 20 +++ .../src/components/common/ProgressModal.tsx | 130 +++++++++++++++--- frontend/src/pages/Writer/Content.tsx | 2 +- 3 files changed, 131 insertions(+), 21 deletions(-) diff --git a/backend/igny8_core/ai/engine.py b/backend/igny8_core/ai/engine.py index c5d3a663..1426b30d 100644 --- a/backend/igny8_core/ai/engine.py +++ b/backend/igny8_core/ai/engine.py @@ -70,6 +70,17 @@ class AIEngine: return f"Preparing {count} content idea{'s' if count != 1 else ''}" elif function_name == 'generate_images': return f"Extracting image prompts from {count} task{'s' if count != 1 else ''}" + elif function_name == 'generate_image_prompts': + # Extract max_images from data if available + if isinstance(data, list) and len(data) > 0: + max_images = data[0].get('max_images', 2) + total_images = 1 + max_images # 1 featured + max_images in-article + return f"Mapping Content for {total_images} Image Prompts" + elif isinstance(data, dict) and 'max_images' in data: + max_images = data.get('max_images', 2) + total_images = 1 + max_images + return f"Mapping Content for {total_images} Image Prompts" + return f"Mapping Content for Image Prompts" return f"Preparing {count} item{'s' if count != 1 else ''}" def _get_ai_call_message(self, function_name: str, count: int) -> str: @@ -106,6 +117,12 @@ class AIEngine: return f"{count} article{'s' if count != 1 else ''} created" elif function_name == 'generate_images': return f"{count} image{'s' if count != 1 else ''} created" + elif function_name == 'generate_image_prompts': + # Count is total prompts, in-article is count - 1 (subtract featured) + in_article_count = max(0, count - 1) + if in_article_count > 0: + return f"Writing {in_article_count} In‑article Image Prompts" + return "Writing In‑article Image Prompts" return f"{count} item{'s' if count != 1 else ''} processed" def _get_save_message(self, function_name: str, count: int) -> str: @@ -118,6 +135,9 @@ class AIEngine: return f"Saving {count} article{'s' if count != 1 else ''}" elif function_name == 'generate_images': return f"Saving {count} image{'s' if count != 1 else ''}" + elif function_name == 'generate_image_prompts': + # Count is total prompts created + return f"Assigning {count} Prompts to Dedicated Slots" return f"Saving {count} item{'s' if count != 1 else ''}" def execute(self, fn: BaseAIFunction, payload: dict) -> dict: diff --git a/frontend/src/components/common/ProgressModal.tsx b/frontend/src/components/common/ProgressModal.tsx index 7b7ff720..a290a132 100644 --- a/frontend/src/components/common/ProgressModal.tsx +++ b/frontend/src/components/common/ProgressModal.tsx @@ -74,15 +74,51 @@ const getSuccessMessage = (functionId?: string, title?: string, stepLogs?: any[] return 'Article drafted successfully.'; } if (funcName.includes('image')) { - const imageCount = extractCount(/(\d+)\s+image/i, stepLogs || []); - const taskCount = extractCount(/(\d+)\s+task/i, stepLogs || []); - - if (imageCount) { - return `Images created successfully — ${imageCount} image${imageCount !== '1' ? 's' : ''} generated.`; - } else if (taskCount) { - return `Images created successfully — ${taskCount} task${taskCount !== '1' ? 's' : ''} completed.`; + // Try to extract from SAVE step message first (most reliable) + const saveStepLog = stepLogs?.find(log => log.stepName === 'SAVE'); + if (saveStepLog?.message) { + // Look for "Assigning X Prompts to Dedicated Slots" + const countMatch = saveStepLog.message.match(/Assigning (\d+)\s+Prompts/i); + if (countMatch) { + const totalPrompts = parseInt(countMatch[1], 10); + const inArticleCount = totalPrompts > 1 ? totalPrompts - 1 : 0; + if (inArticleCount > 0) { + return `Featured Image and ${inArticleCount} In‑article Image Prompts ready for image generation`; + } else { + return `Featured Image Prompt ready for image generation`; + } + } } - return 'Images created and saved successfully.'; + + // Try to extract from PREP step to get total count + const prepStepLog = stepLogs?.find(log => log.stepName === 'PREP'); + if (prepStepLog?.message) { + const match = prepStepLog.message.match(/Mapping Content for (\d+)\s+Image Prompts/i); + if (match && match[1]) { + const totalPrompts = parseInt(match[1], 10); + const inArticleCount = totalPrompts > 1 ? totalPrompts - 1 : 0; + if (inArticleCount > 0) { + return `Featured Image and ${inArticleCount} In‑article Image Prompts ready for image generation`; + } else { + return `Featured Image Prompt ready for image generation`; + } + } + } + + // Fallback: extract prompt count from any step log + const promptCount = extractCount(/(\d+)\s+prompt/i, stepLogs || []); + if (promptCount) { + const totalPrompts = parseInt(promptCount, 10); + const inArticleCount = totalPrompts > 1 ? totalPrompts - 1 : 0; + if (inArticleCount > 0) { + return `Featured Image and ${inArticleCount} In‑article Image Prompts ready for image generation`; + } else { + return `Featured Image Prompt ready for image generation`; + } + } + + // Default message + return 'Featured Image and X In‑article Image Prompts ready for image generation'; } return 'Task completed successfully.'; }; @@ -123,11 +159,11 @@ const getStepsForFunction = (functionId?: string, title?: string): Array<{phase: if (funcName.includes('image')) { return [ - { phase: 'INIT', label: 'Validating task' }, - { phase: 'PREP', label: 'Extracting image prompts' }, - { phase: 'AI_CALL', label: 'Creating images with Igny8 Semantic AI' }, - { phase: 'PARSE', label: 'Processing images' }, - { phase: 'SAVE', label: 'Saving images' }, + { phase: 'INIT', label: 'Checking content and image slots' }, + { phase: 'PREP', label: 'Mapping Content for X Image Prompts' }, + { phase: 'AI_CALL', label: 'Writing Featured Image Prompts' }, + { phase: 'PARSE', label: 'Writing X In‑article Image Prompts' }, + { phase: 'SAVE', label: 'Assigning Prompts to Dedicated Slots' }, ]; } @@ -337,14 +373,53 @@ export default function ProgressModal({ } } } else if (funcName.includes('image')) { - if (stepPhase === 'AI_CALL') { - // For AI_CALL: Show "Creating images with Igny8 Semantic AI" - return 'Creating images with Igny8 Semantic AI'; - } else if (stepPhase === 'PARSE') { - const imageCount = extractCount(/(\d+)\s+image/i); - if (imageCount) { - return `${imageCount} image${imageCount !== '1' ? 's' : ''} created`; + if (stepPhase === 'PREP') { + // Extract total image count from PREP step message + // Look for "Mapping Content for X Image Prompts" + const totalCount = extractCount(/(\d+)\s+Image Prompts/i) || extractCount(/(\d+)\s+image/i); + if (totalCount) { + return `Mapping Content for ${totalCount} Image Prompts`; } + // Try to extract from step log message + if (stepLog?.message) { + const match = stepLog.message.match(/Mapping Content for (\d+)\s+Image Prompts/i); + if (match && match[1]) { + return `Mapping Content for ${match[1]} Image Prompts`; + } + } + return 'Mapping Content for X Image Prompts'; + } else if (stepPhase === 'AI_CALL') { + // For AI_CALL: Show "Writing Featured Image Prompts" + return 'Writing Featured Image Prompts'; + } else if (stepPhase === 'PARSE') { + // Extract in-article image count from PARSE step + // Look for "Writing X In‑article Image Prompts" + const inArticleCount = extractCount(/(\d+)\s+In‑article/i) || extractCount(/(\d+)\s+In-article/i); + if (inArticleCount) { + return `Writing ${inArticleCount} In‑article Image Prompts`; + } + // Try to extract from step log message + if (stepLog?.message) { + const match = stepLog.message.match(/Writing (\d+)\s+In[‑-]article Image Prompts/i); + if (match && match[1]) { + return `Writing ${match[1]} In‑article Image Prompts`; + } + } + return 'Writing X In‑article Image Prompts'; + } else if (stepPhase === 'SAVE') { + // For SAVE: Extract prompt count from message + const promptCount = extractCount(/(\d+)\s+Prompts/i) || extractCount(/(\d+)\s+prompt/i); + if (promptCount) { + return `Assigning ${promptCount} Prompts to Dedicated Slots`; + } + // Try to extract from step log message + if (stepLog?.message) { + const match = stepLog.message.match(/Assigning (\d+)\s+Prompts/i); + if (match && match[1]) { + return `Assigning ${match[1]} Prompts to Dedicated Slots`; + } + } + return 'Assigning Prompts to Dedicated Slots'; } } @@ -513,10 +588,25 @@ export default function ProgressModal({ } else if (funcName.includes('idea')) { // For idea generation, use fixed heading return 'Generating Content Ideas & Outline'; + } else if (funcName.includes('image')) { + // For image prompts, use fixed heading + return 'Smart Image Prompts'; } return title; })()} + {/* Subtitle for image prompts */} + {(() => { + const funcName = (functionId || title || '').toLowerCase(); + if (funcName.includes('image')) { + return ( +

+ Powered by Igny8 Visual Intelligence +

+ ); + } + return null; + })()} {!showSuccess && status !== 'completed' && (

{message}

)} diff --git a/frontend/src/pages/Writer/Content.tsx b/frontend/src/pages/Writer/Content.tsx index fc45b887..31ecb110 100644 --- a/frontend/src/pages/Writer/Content.tsx +++ b/frontend/src/pages/Writer/Content.tsx @@ -161,7 +161,7 @@ export default function Content() { // Open progress modal for async task progressModal.openModal( result.task_id, - 'Generate Image Prompts', + 'Smart Image Prompts', 'ai-generate-image-prompts-01-desktop' ); } else {