prompt issues fixes

This commit is contained in:
Desktop
2025-11-12 04:41:30 +05:00
parent 28d98a1317
commit b132099e66
2 changed files with 47 additions and 19 deletions

View File

@@ -7,6 +7,7 @@
import React, { useEffect, useState } from 'react';
import { Modal } from '../ui/modal';
import { FileIcon, TimeIcon, CheckCircleIcon, ErrorIcon } from '../../icons';
import { fetchAPI } from '../../services/api';
export interface ImageQueueItem {
imageId: number | null;
@@ -56,12 +57,13 @@ export default function ImageQueueModal({
const pollInterval = setInterval(async () => {
try {
const response = await fetch(`/api/v1/system/settings/task_progress/${taskId}/`);
if (!response.ok) {
console.error('Failed to fetch task status');
const data = await fetchAPI(`/v1/system/settings/task_progress/${taskId}/`);
// Check if data is valid (not HTML error page)
if (!data || typeof data !== 'object') {
console.warn('Invalid task status response:', data);
return;
}
const data = await response.json();
// Check state (task_progress returns 'state', not 'status')
const taskState = data.state || data.status;
@@ -82,8 +84,26 @@ export default function ImageQueueModal({
if (data.meta) {
updateQueueFromTaskMeta(data.meta);
}
} catch (error) {
console.error('Error polling task status:', error);
} catch (error: any) {
// Check if it's a JSON parse error (HTML response) or API error
if (error.message && (error.message.includes('JSON') || error.message.includes('API Error'))) {
console.error('Task status endpoint error:', {
message: error.message,
status: error.status,
taskId: taskId,
endpoint: `/v1/system/settings/task_progress/${taskId}/`,
error: error
});
// If it's a 404, the endpoint might not exist - stop polling after a few attempts
if (error.status === 404) {
console.error('Task progress endpoint not found (404). Stopping polling.');
clearInterval(pollInterval);
return;
}
// Don't stop polling for other errors, but log them
} else {
console.error('Error polling task status:', error);
}
}
}, 1000); // Poll every second