dup remocal
This commit is contained in:
@@ -73,15 +73,8 @@ const getSuccessMessage = (functionId?: string, title?: string, stepLogs?: any[]
|
||||
}
|
||||
return 'Article drafted successfully.';
|
||||
}
|
||||
// Check for image generation from prompts FIRST (more specific)
|
||||
if (funcName.includes('image') && funcName.includes('from')) {
|
||||
// Image generation from prompts
|
||||
const imageCount = extractCount(/(\d+)\s+image/i, stepLogs || []);
|
||||
if (imageCount) {
|
||||
return `${imageCount} image${imageCount !== '1' ? 's' : ''} generated successfully`;
|
||||
}
|
||||
return 'Images generated successfully';
|
||||
} else if (funcName.includes('image') && (funcName.includes('prompt') || funcName.includes('extract'))) {
|
||||
// Image prompt generation (generate_image_prompts)
|
||||
if (funcName.includes('image') && (funcName.includes('prompt') || funcName.includes('extract'))) {
|
||||
// Image prompt generation
|
||||
// Try to extract from SAVE step message first (most reliable)
|
||||
const saveStepLog = stepLogs?.find(log => log.stepName === 'SAVE');
|
||||
@@ -166,17 +159,8 @@ const getStepsForFunction = (functionId?: string, title?: string): Array<{phase:
|
||||
];
|
||||
}
|
||||
|
||||
// Check for image generation from prompts FIRST (more specific)
|
||||
if (funcName.includes('image') && funcName.includes('from')) {
|
||||
// Image generation from prompts
|
||||
return [
|
||||
{ phase: 'INIT', label: 'Validating image prompts' },
|
||||
{ phase: 'PREP', label: 'Preparing image generation queue' },
|
||||
{ phase: 'AI_CALL', label: 'Generating images with AI' },
|
||||
{ phase: 'PARSE', label: 'Processing image URLs' },
|
||||
{ phase: 'SAVE', label: 'Saving image URLs' },
|
||||
];
|
||||
} else if (funcName.includes('image') && (funcName.includes('prompt') || funcName.includes('extract'))) {
|
||||
// Image prompt generation (generate_image_prompts)
|
||||
if (funcName.includes('image') && (funcName.includes('prompt') || funcName.includes('extract'))) {
|
||||
// Image prompt generation
|
||||
return [
|
||||
{ phase: 'INIT', label: 'Checking content and image slots' },
|
||||
@@ -392,55 +376,6 @@ export default function ProgressModal({
|
||||
return `${articleCount} article${articleCount !== '1' ? 's' : ''} created`;
|
||||
}
|
||||
}
|
||||
} else if (funcName.includes('image') && funcName.includes('from')) {
|
||||
// Image generation from prompts
|
||||
if (stepPhase === 'PREP') {
|
||||
// Extract image count from PREP step message
|
||||
const imageCount = extractCount(/(\d+)\s+image/i);
|
||||
if (imageCount) {
|
||||
return `Preparing to generate ${imageCount} image${imageCount !== '1' ? 's' : ''}`;
|
||||
}
|
||||
if (stepLog?.message) {
|
||||
const match = stepLog.message.match(/Preparing to generate (\d+)\s+image/i);
|
||||
if (match && match[1]) {
|
||||
return `Preparing to generate ${match[1]} image${match[1] !== '1' ? 's' : ''}`;
|
||||
}
|
||||
}
|
||||
return 'Preparing image generation queue';
|
||||
} else if (stepPhase === 'AI_CALL') {
|
||||
// Extract current image number from message
|
||||
const match = stepLog?.message?.match(/Generating.*image (\d+)/i);
|
||||
if (match && match[1]) {
|
||||
return `Generating image ${match[1]} with AI`;
|
||||
}
|
||||
return 'Generating images with AI';
|
||||
} else if (stepPhase === 'PARSE') {
|
||||
// Extract image count from PARSE step
|
||||
const imageCount = extractCount(/(\d+)\s+image/i);
|
||||
if (imageCount) {
|
||||
return `${imageCount} image${imageCount !== '1' ? 's' : ''} generated successfully`;
|
||||
}
|
||||
if (stepLog?.message) {
|
||||
const match = stepLog.message.match(/(\d+)\s+image.*generated/i);
|
||||
if (match && match[1]) {
|
||||
return `${match[1]} image${match[1] !== '1' ? 's' : ''} generated successfully`;
|
||||
}
|
||||
}
|
||||
return 'Processing image URLs';
|
||||
} else if (stepPhase === 'SAVE') {
|
||||
// Extract image count from SAVE step
|
||||
const imageCount = extractCount(/(\d+)\s+image/i);
|
||||
if (imageCount) {
|
||||
return `Saving ${imageCount} image${imageCount !== '1' ? 's' : ''}`;
|
||||
}
|
||||
if (stepLog?.message) {
|
||||
const match = stepLog.message.match(/Saved image (\d+)/i);
|
||||
if (match && match[1]) {
|
||||
return `Saving image ${match[1]}`;
|
||||
}
|
||||
}
|
||||
return 'Saving image URLs';
|
||||
}
|
||||
} else if (funcName.includes('image') && (funcName.includes('prompt') || funcName.includes('extract'))) {
|
||||
// Image prompt generation
|
||||
if (stepPhase === 'PREP') {
|
||||
@@ -658,30 +593,17 @@ 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') && funcName.includes('from')) {
|
||||
// For image generation from prompts
|
||||
return 'Generate Images';
|
||||
} else if (funcName.includes('image') && (funcName.includes('prompt') || funcName.includes('extract'))) {
|
||||
// For image prompt generation
|
||||
return 'Smart Image Prompts';
|
||||
} else if (funcName.includes('image')) {
|
||||
// Fallback for other image functions
|
||||
return 'Generate Images';
|
||||
}
|
||||
return title;
|
||||
})()}
|
||||
</h3>
|
||||
{/* Subtitle for image functions */}
|
||||
{/* Subtitle for image prompt generation */}
|
||||
{(() => {
|
||||
const funcName = (functionId || title || '').toLowerCase();
|
||||
if (funcName.includes('image') && funcName.includes('from')) {
|
||||
// Image generation from prompts
|
||||
return (
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 text-center mt-1">
|
||||
Generating images from prompts using AI
|
||||
</p>
|
||||
);
|
||||
} else if (funcName.includes('image') && (funcName.includes('prompt') || funcName.includes('extract'))) {
|
||||
if (funcName.includes('image') && (funcName.includes('prompt') || funcName.includes('extract'))) {
|
||||
// Image prompt generation
|
||||
return (
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 text-center mt-1">
|
||||
@@ -693,22 +615,7 @@ export default function ProgressModal({
|
||||
})()}
|
||||
{!showSuccess && status !== 'completed' && (
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400 text-center">
|
||||
{(() => {
|
||||
const funcName = (functionId || title || '').toLowerCase();
|
||||
// For image generation, show a more specific message
|
||||
if (funcName.includes('image') && funcName.includes('from')) {
|
||||
// Get current step message from step logs
|
||||
const currentStepLog = stepLogs.find(log => log.stepName === currentPhase);
|
||||
if (currentStepLog?.message) {
|
||||
return currentStepLog.message;
|
||||
}
|
||||
// Fallback to step label
|
||||
const currentStep = steps.find(s => s.phase === currentPhase);
|
||||
return currentStep?.label || 'Generating images...';
|
||||
}
|
||||
// For other functions, use the message prop
|
||||
return message;
|
||||
})()}
|
||||
{message}
|
||||
</p>
|
||||
)}
|
||||
{status === 'completed' && !allStepsVisuallyCompleted && (
|
||||
|
||||
@@ -14,17 +14,6 @@ export interface ProgressState {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ImageQueueItem {
|
||||
image_id: number;
|
||||
index: number;
|
||||
label: string;
|
||||
content_title: string;
|
||||
status: 'pending' | 'processing' | 'completed' | 'failed';
|
||||
progress: number;
|
||||
image_url: string | null;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export interface UseProgressModalReturn {
|
||||
progress: ProgressState;
|
||||
isOpen: boolean;
|
||||
@@ -43,7 +32,6 @@ export interface UseProgressModalReturn {
|
||||
message: string;
|
||||
timestamp?: number;
|
||||
}>; // Step logs for debugging
|
||||
imageQueue?: ImageQueueItem[]; // Image queue for image generation
|
||||
}
|
||||
|
||||
export function useProgressModal(): UseProgressModalReturn {
|
||||
@@ -66,9 +54,6 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
timestamp?: number;
|
||||
}>>([]);
|
||||
|
||||
// Image queue state for image generation
|
||||
const [imageQueue, setImageQueue] = useState<ImageQueueItem[] | undefined>(undefined);
|
||||
|
||||
// Track displayed percentage and current step for step-based progress
|
||||
const displayedPercentageRef = useRef(0);
|
||||
const currentStepRef = useRef<string | null>(null);
|
||||
@@ -473,11 +458,6 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
}
|
||||
}
|
||||
|
||||
// Extract image queue if available (for image generation)
|
||||
if (meta.image_queue && Array.isArray(meta.image_queue)) {
|
||||
setImageQueue(meta.image_queue as ImageQueueItem[]);
|
||||
}
|
||||
|
||||
// Update step logs if available
|
||||
if (meta.request_steps || meta.response_steps) {
|
||||
// Collect all steps for display in modal
|
||||
@@ -756,7 +736,6 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
displayedPercentageRef.current = 0;
|
||||
currentStepRef.current = null;
|
||||
setStepLogs([]); // Clear step logs when closing modal
|
||||
setImageQueue(undefined); // Clear image queue when closing modal
|
||||
setIsOpen(false);
|
||||
// Clear taskId to stop polling when modal closes
|
||||
setTaskId(null);
|
||||
@@ -790,7 +769,6 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
status: 'pending',
|
||||
});
|
||||
setStepLogs([]);
|
||||
setImageQueue(undefined);
|
||||
setTaskId(null);
|
||||
setTitle('');
|
||||
setIsOpen(false);
|
||||
@@ -808,7 +786,6 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
taskId, // Expose taskId for use in ProgressModal
|
||||
functionId, // Expose functionId for use in ProgressModal
|
||||
stepLogs, // Expose step logs for debugging
|
||||
imageQueue, // Expose image queue for image generation
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user