|
@@ -42,7 +42,7 @@ function Text2ImgForm() {
|
|
|
const [loading, setLoading] = useState(false);
|
|
const [loading, setLoading] = useState(false);
|
|
|
const [jobInfo, setJobInfo] = useState<JobInfo | null>(null);
|
|
const [jobInfo, setJobInfo] = useState<JobInfo | null>(null);
|
|
|
const { images: storedImages, addImages, getLatestImages } = useGeneratedImages('text2img');
|
|
const { images: storedImages, addImages, getLatestImages } = useGeneratedImages('text2img');
|
|
|
- const [generatedImages, setGeneratedImages] = useState<string[]>(() => getLatestImages());
|
|
|
|
|
|
|
+ const [generatedImages, setGeneratedImages] = useState<string[]>(() => storedImages.map(img => img.url));
|
|
|
const [samplers, setSamplers] = useState<
|
|
const [samplers, setSamplers] = useState<
|
|
|
Array<{ name: string; description: string }>
|
|
Array<{ name: string; description: string }>
|
|
|
>([]);
|
|
>([]);
|
|
@@ -118,20 +118,26 @@ function Text2ImgForm() {
|
|
|
const status: JobDetailsResponse = await apiClient.getJobStatus(jobId);
|
|
const status: JobDetailsResponse = await apiClient.getJobStatus(jobId);
|
|
|
setJobInfo(status.job);
|
|
setJobInfo(status.job);
|
|
|
|
|
|
|
|
|
|
+ console.log(`[DEBUG] Job ${jobId} status: ${status.job.status}, progress: ${status.job.progress}, outputs:`, status.job.outputs);
|
|
|
|
|
+
|
|
|
if (status.job.status === "completed") {
|
|
if (status.job.status === "completed") {
|
|
|
let imageUrls: string[] = [];
|
|
let imageUrls: string[] = [];
|
|
|
|
|
|
|
|
// Handle both old format (result.images) and new format (outputs)
|
|
// Handle both old format (result.images) and new format (outputs)
|
|
|
if (status.job.outputs && status.job.outputs.length > 0) {
|
|
if (status.job.outputs && status.job.outputs.length > 0) {
|
|
|
|
|
+ console.log(`[DEBUG] Processing ${status.job.outputs.length} outputs`);
|
|
|
// New format: convert output URLs to authenticated image URLs with cache-busting
|
|
// New format: convert output URLs to authenticated image URLs with cache-busting
|
|
|
imageUrls = status.job.outputs.map((output: { filename: string }) => {
|
|
imageUrls = status.job.outputs.map((output: { filename: string }) => {
|
|
|
const filename = output.filename;
|
|
const filename = output.filename;
|
|
|
- return apiClient.getImageUrl(jobId, filename);
|
|
|
|
|
|
|
+ const imageUrl = apiClient.getImageUrl(jobId, filename);
|
|
|
|
|
+ console.log(`[DEBUG] Generated URL for ${filename}: ${imageUrl}`);
|
|
|
|
|
+ return imageUrl;
|
|
|
});
|
|
});
|
|
|
} else if (
|
|
} else if (
|
|
|
status.job.result?.images &&
|
|
status.job.result?.images &&
|
|
|
status.job.result.images.length > 0
|
|
status.job.result.images.length > 0
|
|
|
) {
|
|
) {
|
|
|
|
|
+ console.log(`[DEBUG] Using old format with ${status.job.result.images.length} images`);
|
|
|
// Old format: convert image URLs to authenticated URLs
|
|
// Old format: convert image URLs to authenticated URLs
|
|
|
imageUrls = status.job.result.images.map((imageUrl: string) => {
|
|
imageUrls = status.job.result.images.map((imageUrl: string) => {
|
|
|
// Extract filename from URL if it's a full URL
|
|
// Extract filename from URL if it's a full URL
|
|
@@ -145,18 +151,24 @@ function Text2ImgForm() {
|
|
|
// If it's just a filename, convert it directly
|
|
// If it's just a filename, convert it directly
|
|
|
return apiClient.getImageUrl(jobId, imageUrl);
|
|
return apiClient.getImageUrl(jobId, imageUrl);
|
|
|
});
|
|
});
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log(`[DEBUG] No outputs or images found in job response`);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ console.log(`[DEBUG] Final image URLs:`, imageUrls);
|
|
|
|
|
+
|
|
|
// Create a new array to trigger React re-render
|
|
// Create a new array to trigger React re-render
|
|
|
setGeneratedImages([...imageUrls]);
|
|
setGeneratedImages([...imageUrls]);
|
|
|
addImages(imageUrls, jobId);
|
|
addImages(imageUrls, jobId);
|
|
|
setLoading(false);
|
|
setLoading(false);
|
|
|
isPolling = false;
|
|
isPolling = false;
|
|
|
} else if (status.job.status === "failed") {
|
|
} else if (status.job.status === "failed") {
|
|
|
|
|
+ console.log(`[DEBUG] Job failed with error: ${status.job.error}`);
|
|
|
setError(status.job.error || "Generation failed");
|
|
setError(status.job.error || "Generation failed");
|
|
|
setLoading(false);
|
|
setLoading(false);
|
|
|
isPolling = false;
|
|
isPolling = false;
|
|
|
} else if (status.job.status === "cancelled") {
|
|
} else if (status.job.status === "cancelled") {
|
|
|
|
|
+ console.log(`[DEBUG] Job was cancelled`);
|
|
|
setError("Generation was cancelled");
|
|
setError("Generation was cancelled");
|
|
|
setLoading(false);
|
|
setLoading(false);
|
|
|
isPolling = false;
|
|
isPolling = false;
|
|
@@ -164,11 +176,13 @@ function Text2ImgForm() {
|
|
|
attempts++;
|
|
attempts++;
|
|
|
timeoutId = setTimeout(poll, 2000);
|
|
timeoutId = setTimeout(poll, 2000);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ console.log(`[DEBUG] Job polling timeout after ${attempts} attempts`);
|
|
|
setError("Job polling timeout");
|
|
setError("Job polling timeout");
|
|
|
setLoading(false);
|
|
setLoading(false);
|
|
|
isPolling = false;
|
|
isPolling = false;
|
|
|
}
|
|
}
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
|
|
+ console.log(`[DEBUG] Error polling job status:`, err);
|
|
|
if (isPolling) {
|
|
if (isPolling) {
|
|
|
setError(
|
|
setError(
|
|
|
err instanceof Error ? err.message : "Failed to check job status",
|
|
err instanceof Error ? err.message : "Failed to check job status",
|