a
This commit is contained in:
@@ -29,6 +29,14 @@ interface ImageQueueModalProps {
|
||||
totalImages: number;
|
||||
taskId?: string | null;
|
||||
onUpdateQueue?: (queue: ImageQueueItem[]) => void;
|
||||
onLog?: (log: {
|
||||
timestamp: string;
|
||||
type: 'request' | 'success' | 'error' | 'step';
|
||||
action: string;
|
||||
data: any;
|
||||
stepName?: string;
|
||||
percentage?: number;
|
||||
}) => void;
|
||||
}
|
||||
|
||||
export default function ImageQueueModal({
|
||||
@@ -38,6 +46,7 @@ export default function ImageQueueModal({
|
||||
totalImages,
|
||||
taskId,
|
||||
onUpdateQueue,
|
||||
onLog,
|
||||
}: ImageQueueModalProps) {
|
||||
const [localQueue, setLocalQueue] = useState<ImageQueueItem[]>(queue);
|
||||
|
||||
@@ -86,6 +95,44 @@ export default function ImageQueueModal({
|
||||
if (taskState === 'SUCCESS' || taskState === 'FAILURE') {
|
||||
console.log(`[ImageQueueModal] Task completed with state:`, taskState);
|
||||
clearInterval(pollInterval);
|
||||
|
||||
// Log completion status
|
||||
if (onLog) {
|
||||
if (taskState === 'SUCCESS') {
|
||||
const result = data.result || (data.meta && data.meta.result);
|
||||
const completed = result?.completed || 0;
|
||||
const failed = result?.failed || 0;
|
||||
const total = result?.total_images || totalImages;
|
||||
|
||||
onLog({
|
||||
timestamp: new Date().toISOString(),
|
||||
type: failed > 0 ? 'error' : 'success',
|
||||
action: 'generate_images',
|
||||
stepName: 'Task Completed',
|
||||
data: {
|
||||
state: 'SUCCESS',
|
||||
completed,
|
||||
failed,
|
||||
total,
|
||||
results: result?.results || []
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// FAILURE
|
||||
onLog({
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'error',
|
||||
action: 'generate_images',
|
||||
stepName: 'Task Failed',
|
||||
data: {
|
||||
state: 'FAILURE',
|
||||
error: data.error || data.meta?.error || 'Task failed',
|
||||
meta: data.meta
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update final state
|
||||
if (taskState === 'SUCCESS' && data.result) {
|
||||
console.log(`[ImageQueueModal] Updating queue from result:`, data.result);
|
||||
|
||||
Reference in New Issue
Block a user