Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix(studio): clarify image preview loading and allow retry (#12450)

Lee Jackson5d4b7f16bcde
diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsx
index 989ddf51fe4..111f150591d 100644
--- a/studio/frontend/src/features/images/images-page.tsx
+++ b/studio/frontend/src/features/images/images-page.tsx
@@ -1574,6 +1574,7 @@ export function ImagesPage({
const [thumbById, setThumbById] = useState<Record<string, string>>(() =>
galleryCache.thumbById.toRecord(),
);
+ const [srcErrors, setSrcErrors] = useState<Record<string, boolean>>({});
// Guards a "load more" so a fast scroll cannot fire several at once.
const loadingMore = useRef(false);
// Observer root for loading thumbnails near the visible strip.
@@ -1905,6 +1906,12 @@ export function ImagesPage({
const ensureSrc = useCallback(async (image: GalleryImage) => {
if (galleryCache.srcById.has(image.id) || galleryCache.inflight.has(image.id)) return;
galleryCache.inflight.add(image.id);
+ setSrcErrors((prev) => {
+ if (!prev[image.id]) return prev;
+ const next = { ...prev };
+ delete next[image.id];
+ return next;
+ });
try {
const { url, bytes } = await fetchGalleryObjectUrl(image.url);
if (galleryCache.deleted.has(image.id)) {
@@ -1927,7 +1934,9 @@ export function ImagesPage({
return next;
});
} catch {
- // Leave it without a src; the tile shows a placeholder.
+ if (!galleryCache.deleted.has(image.id)) {
+ setSrcErrors((prev) => ({ ...prev, [image.id]: true }));
+ }
} finally {
galleryCache.inflight.delete(image.id);
}
@@ -2077,6 +2086,12 @@ export function ImagesPage({
galleryCache.srcById.delete(id); // revokes the URL with the entry
galleryCache.thumbById.delete(id);
galleryCache.deleted.add(id);
+ setSrcErrors((prev) => {
+ if (!prev[id]) return prev;
+ const next = { ...prev };
+ delete next[id];
+ return next;
+ });
setSrcById((prev) => {
const next = { ...prev };
delete next[id];
@@ -5631,24 +5646,45 @@ export function ImagesPage({
/>
</div>
</>
- ) : selected && selectedThumb ? (
- // Match the original's display size while loading; actions require the original.
- // Leave the box unpainted because object-contain can leave empty space.
+ ) : selected ? (
<>
- <img
- src={selectedThumb}
- alt={selected.prompt}
- style={{ maxWidth: selected.width, maxHeight: selected.height }}
- className="size-full object-contain"
- />
- <Spinner className="absolute size-8 text-muted-foreground" />
+ {selectedThumb && (
+ <img
+ src={selectedThumb}
+ alt={selected.prompt}
+ style={{ maxWidth: selected.width, maxHeight: selected.height }}
+ className="size-full object-contain"
+ />
+ )}
+ <div className="absolute bottom-4 right-4 flex items-center gap-0.5 rounded-xl bg-background/80 p-1 shadow-lg ring-1 ring-border backdrop-blur [&_[data-slot=button]]:border-0 [&_[data-slot=button]:focus-visible]:bg-muted">
+ {srcErrors[selected.id] ? (
+ <>
+ <span role="alert" className="sr-only">Full-resolution download failed.</span>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="gap-1.5"
+ title="Full-resolution download failed. Retry downloading."
+ onClick={() => void ensureSrc(selected)}
+ >
+ <HugeiconsIcon icon={Refresh01Icon} className="size-4" />
+ Retry download
+ </Button>
+ </>
+ ) : (
+ <Button
+ size="sm"
+ variant="ghost"
+ className="gap-1.5"
+ disabled
+ title="Loading full-resolution image…"
+ >
+ <Spinner className="size-4" label="Loading full-resolution image" />
+ Loading image…
+ </Button>
+ )}
+ </div>
</>
- ) : selected ? (
- // The selected record's blob is still loading; spin in place.
- <div className="flex flex-col items-center gap-3 text-muted-foreground">
- <Spinner className="size-8" />
- <p className="text-sm">Loading…</p>
- </div>
) : busy === "generating" ? null : (
<div className="flex flex-col items-center gap-3 text-muted-foreground">
{/* Same icon as the Images nav item. */}
diff --git a/studio/frontend/tests/images-gallery-thumbnails.test.ts b/studio/frontend/tests/images-gallery-thumbnails.test.ts
index 38ba2acf830..8964c9cba1e 100644
--- a/studio/frontend/tests/images-gallery-thumbnails.test.ts
+++ b/studio/frontend/tests/images-gallery-thumbnails.test.ts
@@ -50,7 +50,7 @@ test("the canvas, viewer and downloads read only the original", () => {
const preview = between(page, "// The preview is what the user looks at", "// Drop an image from the strip.");
assert.ok(preview.includes("await ensureSrc(selected);"));
- const canvas = between(page, "{selected && selectedSrc ? (", ") : selected && selectedThumb ? (");
+ const canvas = between(page, "{selected && selectedSrc ? (", ") : selected ? (");
assert.ok(canvas.includes("src={selectedSrc}"));
for (const format of ["png", "jpeg", "webp"]) {
assert.ok(canvas.includes(`downloadImage(selectedSrc, selected, "${format}")`));
@@ -65,9 +65,9 @@ test("the canvas, viewer and downloads read only the original", () => {
});
test("the thumbnail placeholder offers no action that needs the original", () => {
- const placeholder = between(page, ") : selected && selectedThumb ? (", ") : selected ? (");
+ const placeholder = between(page, ") : selected ? (", ') : busy === "generating" ? null : (');
assert.ok(placeholder.includes("src={selectedThumb}"));
- for (const action of ["downloadImage", "openViewer", "GalleryItemMenu", "RecipePopover", "onClick"]) {
+ for (const action of ["downloadImage", "openViewer", "GalleryItemMenu", "RecipePopover"]) {
assert.ok(!placeholder.includes(action), action);
}
});