drop unused diffusion status 'loading' field; cap session gallery

This commit is contained in:
oobabooga 2026-06-24 16:18:14 -03:00
commit 453efa7ae7
5 changed files with 20 additions and 20 deletions

View file

@ -352,11 +352,9 @@ class DiffusionBackend:
def status(self) -> dict[str, Any]:
state = self._state
loading = self._loading is not None and (self._loading.error is None)
if state is None:
return {
"loaded": False,
"loading": loading,
"repo_id": None,
"family": None,
"base_repo": None,
@ -366,7 +364,6 @@ class DiffusionBackend:
}
return {
"loaded": True,
"loading": loading,
"repo_id": state.repo_id,
"family": state.family.name,
"base_repo": state.base_repo,

View file

@ -1748,7 +1748,6 @@ class DiffusionStatusResponse(BaseModel):
"""Current diffusion backend state."""
loaded: bool = Field(False, description = "Whether a diffusion model is loaded")
loading: bool = Field(False, description = "Whether a load is currently in progress")
repo_id: Optional[str] = Field(None, description = "Loaded repo id or local path")
family: Optional[str] = Field(None, description = "Detected diffusion family")
base_repo: Optional[str] = Field(None, description = "Companion diffusers base repo")

View file

@ -33,7 +33,6 @@ class _FakeBackend:
self.loaded = True
return {
"loaded": True,
"loading": False,
"repo_id": model_path,
"family": "z-image",
"base_repo": kwargs.get("base_repo") or "base/repo",
@ -67,7 +66,6 @@ class _FakeBackend:
def _unloaded_status():
return {
"loaded": False,
"loading": False,
"repo_id": None,
"family": None,
"base_repo": None,

View file

@ -6,7 +6,6 @@ import { readFastApiError } from "@/lib/format-fastapi-error";
export interface DiffusionStatus {
loaded: boolean;
loading: boolean;
repo_id: string | null;
family: string | null;
base_repo: string | null;

View file

@ -52,6 +52,9 @@ const MODELS: ModelOption[] = [
{ id: MODEL.repo_id, name: MODEL.label, description: "Text-to-image · GGUF", isGguf: true },
];
// Keep at most this many generated images in the session gallery.
const MAX_GALLERY = 50;
const RESOLUTIONS: Array<{ label: string; w: number; h: number }> = [
{ label: "Square 1024", w: 1024, h: 1024 },
{ label: "Square 768", w: 768, h: 768 },
@ -316,19 +319,23 @@ export function ImagesPage() {
seed: parsedSeed,
});
const id = nextResultId.current++;
setResults((prev) => [
{
id,
src: `data:${res.mime};base64,${res.image_b64}`,
prompt: prompt.trim(),
width: resolution.w,
height: resolution.h,
steps,
guidance,
seed: res.seed,
},
...prev,
]);
setResults((prev) =>
// Cap the gallery so the base64 PNGs (held in module scope across tab
// switches) can't grow without bound over a long session.
[
{
id,
src: `data:${res.mime};base64,${res.image_b64}`,
prompt: prompt.trim(),
width: resolution.w,
height: resolution.h,
steps,
guidance,
seed: res.seed,
},
...prev,
].slice(0, MAX_GALLERY),
);
setSelectedId(id);
} catch (err) {
toast.error(err instanceof Error ? err.message : "Image generation failed");