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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
remove the unused images train dialog and fix media page responsiveness (#8215)
Maheswar Kumarcf28871fefd0
diff --git a/studio/frontend/src/components/media-page-link.tsx b/studio/frontend/src/components/media-page-link.tsxindex a5ab7a8fc10..07643d250cd 100644--- a/studio/frontend/src/components/media-page-link.tsx+++ b/studio/frontend/src/components/media-page-link.tsx@@ -47,10 +47,10 @@ export function MediaPageLink({onNavigate?.();navigate({ to });}}- className="flex h-[34px] shrink-0 items-center gap-1.5 rounded-full pl-2.5 pr-2 text-ui-13 font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ className="flex h-[34px] min-w-0 items-center gap-1.5 rounded-full pl-2.5 pr-2 text-ui-13 font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><HugeiconsIcon icon={icon} className="size-4 shrink-0" />- <span>{label}</span>+ <span className="min-w-0 truncate">{label}</span><HugeiconsIconicon={ArrowRight02Icon}className="size-3.5 shrink-0 opacity-60"diff --git a/studio/frontend/src/features/images/diffusion-train-dialog.tsx b/studio/frontend/src/features/images/diffusion-train-dialog.tsxdeleted file mode 100644index d7982b67261..00000000000--- a/studio/frontend/src/features/images/diffusion-train-dialog.tsx+++ /dev/null@@ -1,500 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-only-// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0--import { useCallback, useEffect, useRef, useState } from "react";--import { Button } from "@/components/ui/button";-import {- Dialog,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from "@/components/ui/dialog";-import { Input } from "@/components/ui/input";-import { Label } from "@/components/ui/label";-import { getHfToken, hfApiToken } from "@/features/hub/stores/hf-token-store";-import { toast } from "@/lib/toast";--import {- type DiffusionTrainingInfo,- type DiffusionTrainingStatus,- getDiffusionTrainingInfo,- getDiffusionTrainingStatus,- startDiffusionTraining,- stopDiffusionTraining,- uploadDiffusionDataset,-} from "./api";--// The two official SDXL bases the backend allowlists for non-GGUF loads; "custom" is the escape hatch for local SDXL checkpoints.-const SDXL_BASES: Array<{ id: string; label: string }> = [- { id: "stabilityai/stable-diffusion-xl-base-1.0", label: "SDXL Base 1.0 (best quality)" },- { id: "stabilityai/sdxl-turbo", label: "SDXL Turbo (fast, good for quick tests)" },-];-const CUSTOM_BASE = "__custom__";-const UPLOAD_DATASET = "__upload__";-const DATASET_FILE_ACCEPT = ".png,.jpg,.jpeg,.webp,.bmp,.txt,.caption,.jsonl";--const selectClass =- "h-8 w-full rounded-md border border-input bg-background px-2 text-xs";--// A self-contained "Train an SDXL LoRA" dialog: posts to /api/train/diffusion/start and polls /status while open, so it-// never blocks the page. Only SDXL is trainable today, and the dropdown keeps users on picks the backend accepts.-export function DiffusionTrainDialog({- open,- onOpenChange,- defaultBaseModel,- onTrainingComplete,-}: {- open: boolean;- onOpenChange: (open: boolean) => void;- defaultBaseModel?: string;- // Called once when a run finishes so the page can rescan the LoRA picker.- onTrainingComplete?: () => void;-}) {- const [baseChoice, setBaseChoice] = useState(SDXL_BASES[0].id);- const [customBase, setCustomBase] = useState("");- const [info, setInfo] = useState<DiffusionTrainingInfo | null>(null);- const [dataset, setDataset] = useState<string>(UPLOAD_DATASET);- const [uploadName, setUploadName] = useState("my-images");- const [uploading, setUploading] = useState(false);- const fileInputRef = useRef<HTMLInputElement | null>(null);- const [outputDir, setOutputDir] = useState("");- const [instancePrompt, setInstancePrompt] = useState("");- const [showAdvanced, setShowAdvanced] = useState(false);- const [steps, setSteps] = useState(500);- const [learningRate, setLearningRate] = useState(0.0001);- const [rank, setRank] = useState(16);- const [resolution, setResolution] = useState(1024);- const [batchSize, setBatchSize] = useState(1);- const [precision, setPrecision] = useState<"bf16" | "fp16" | "no">("bf16");- const [starting, setStarting] = useState(false);- const [status, setStatus] = useState<DiffusionTrainingStatus | null>(null);-- // The dialog stays mounted (ImagesPage is keep-alive), so seed per-open state here: the base model from the loaded SDXL pipeline, and the dataset list from the backend.- const refreshInfo = useCallback(async (): Promise<DiffusionTrainingInfo | null> => {- try {- const i = await getDiffusionTrainingInfo();- setInfo(i);- return i;- } catch {- return null; // older backends: keep the upload-only flow usable- }- }, []);-- useEffect(() => {- if (!open) return;- if (defaultBaseModel) {- setBaseChoice(defaultBaseModel);- }- void refreshInfo().then((i) => {- // Preselect the only dataset, or the freshest-looking state; with none the picker sits on "Upload new images".- setDataset((cur) => {- if (cur !== UPLOAD_DATASET && i?.datasets.some((d) => d.name === cur)) return cur;- return i && i.datasets.length > 0 ? i.datasets[0].name : UPLOAD_DATASET;- });- });- }, [open, defaultBaseModel, refreshInfo]);-- const poll = useCallback(async () => {- try {- setStatus(await getDiffusionTrainingStatus());- } catch {- // Best-effort; a failed poll should not surface an error while the dialog is open.- }- }, []);-- // Poll status only while the dialog is open.- useEffect(() => {- if (!open) return;- void poll();- const id = window.setInterval(() => void poll(), 1500);- return () => window.clearInterval(id);- }, [open, poll]);-- const active = Boolean(status?.active) || status?.status === "running";- // A stopped run still saves + publishes a deployable adapter (catalog_path set), so it counts as finished-with-adapter; a save=False cancel has none.- const hasSavedAdapter =- status?.status === "completed" ||- (status?.status === "stopped" && Boolean(status?.catalog_path));- const completed = hasSavedAdapter;- const pct =- status && status.total_steps > 0- ? Math.min(100, Math.round((status.step / status.total_steps) * 100))- : 0;-- // Notify the parent exactly once per finished run so it rescans the LoRA picker.- const [notifiedComplete, setNotifiedComplete] = useState(false);- useEffect(() => {- if (hasSavedAdapter && !notifiedComplete) {- setNotifiedComplete(true);- onTrainingComplete?.();- } else if (status?.status === "running" && notifiedComplete) {- setNotifiedComplete(false); // arm again for the next run- }- }, [hasSavedAdapter, status?.status, notifiedComplete, onTrainingComplete]);-- const selectedDataset =- dataset !== UPLOAD_DATASET ? info?.datasets.find((d) => d.name === dataset) : undefined;-- const onUpload = useCallback(async () => {- const files = Array.from(fileInputRef.current?.files ?? []);- if (files.length === 0) {- toast.error("Choose the images to upload first.");- return;- }- const name = uploadName.trim();- if (!name) {- toast.error("Give the dataset a folder name, e.g. my-style-photos.");- return;- }- setUploading(true);- try {- const res = await uploadDiffusionDataset(name, files);- toast.success(- `Uploaded ${res.uploaded} file${res.uploaded === 1 ? "" : "s"} - ` +- `"${res.name}" now has ${res.image_count} images`,- );- if (fileInputRef.current) fileInputRef.current.value = "";- await refreshInfo();- setDataset(res.name);- } catch (e) {- toast.error(e instanceof Error ? e.message : "Upload failed");- } finally {- setUploading(false);- }- }, [uploadName, refreshInfo]);-- const onStart = useCallback(async () => {- const baseModel = (baseChoice === CUSTOM_BASE ? customBase : baseChoice).trim();- if (!baseModel) {- toast.error("Pick a base model (or fill in the custom repo/path).");- return;- }- if (dataset === UPLOAD_DATASET) {- toast.error("Upload your training images first (or pick an existing dataset).");- return;- }- if (!outputDir.trim()) {- toast.error("Name the adapter (this becomes its folder under Studio outputs).");- return;- }- if (selectedDataset && selectedDataset.caption_count === 0 && !instancePrompt.trim()) {- toast.error(- "These images have no captions - add a trigger prompt so the trainer knows " +- "what to learn (it becomes the caption for every image).",- );- return;- }- // Mirror the backend's numeric validation so obvious mistakes are caught before the request, with a clearer message than its 400.- if (steps < 1) return toast.error("Steps must be at least 1.");- if (rank < 1) return toast.error("LoRA rank must be at least 1.");- if (resolution < 64 || resolution % 8 !== 0) {- return toast.error("Resolution must be a multiple of 8 and at least 64.");- }- if (batchSize < 1) return toast.error("Batch size must be at least 1.");- if (learningRate <= 0) return toast.error("Learning rate must be greater than 0.");- setStarting(true);- try {- await startDiffusionTraining({- base_model: baseModel,- data_dir: dataset,- output_dir: outputDir.trim(),- instance_prompt: instancePrompt.trim() || undefined,- resolution,- train_steps: steps,- learning_rate: learningRate,- train_batch_size: batchSize,- lora_rank: rank,- mixed_precision: precision,- // Forward the saved Hub token so a gated/private SDXL base can be trained, exactly as the image load flow does.- hf_token: hfApiToken(getHfToken()) || undefined,- });- toast.success("Training started");- void poll();- } catch (e) {- toast.error(e instanceof Error ? e.message : "Failed to start training");- } finally {- setStarting(false);- }- }, [- baseChoice,- customBase,- dataset,- selectedDataset,- outputDir,- instancePrompt,- resolution,- steps,- learningRate,- batchSize,- rank,- precision,- poll,- ]);-- const onStop = useCallback(async () => {- try {- await stopDiffusionTraining();- toast.success("Stop requested; finishing the current step.");- void poll();- } catch (e) {- toast.error(e instanceof Error ? e.message : "Failed to stop training");- }- }, [poll]);-- return (- <Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent className="flex max-h-[85dvh] max-w-lg flex-col">- <DialogHeader>- <DialogTitle>Train an SDXL LoRA</DialogTitle>- <DialogDescription>- Teach SDXL a style, character, or subject from your own images. The finished- adapter shows up in this page's LoRA picker. Only SDXL can be trained for- now - FLUX, Qwen-Image and Z-Image load LoRAs but can't train them yet.- </DialogDescription>- </DialogHeader>-- <div className="grid gap-3 overflow-y-auto py-2 pr-1">- {/* 1. Base model: a constrained dropdown instead of free text, so the "SDXL only" rule is embodied by the control. Custom stays available for local checkpoints; a known non-SDXL pick is refused instantly. */}- <div className="grid gap-1.5">- <Label className="text-xs">Base model to train on</Label>- <select- value={baseChoice}- onChange={(e) => setBaseChoice(e.target.value)}- className={selectClass}- >- {SDXL_BASES.map((b) => (- <option key={b.id} value={b.id}>- {b.label}- </option>- ))}- {defaultBaseModel && !SDXL_BASES.some((b) => b.id === defaultBaseModel) && (- <option value={defaultBaseModel}>Loaded model: {defaultBaseModel}</option>- )}- <option value={CUSTOM_BASE}>Custom SDXL repo or local path...</option>- </select>- {baseChoice === CUSTOM_BASE && (- <Input- value={customBase}- placeholder="my-org/my-sdxl-finetune or /path/to/sdxl-pipeline"- spellCheck={false}- onChange={(e) => setCustomBase(e.target.value)}- className="h-8 text-xs"- />- )}- </div>-- {/* 2. Training images: pick an existing dataset folder or upload straight from the browser. */}- <div className="grid gap-1.5">- <Label className="text-xs">Training images</Label>- <select- value={dataset}- onChange={(e) => setDataset(e.target.value)}- className={selectClass}- >- {(info?.datasets ?? []).map((d) => (- <option key={d.name} value={d.name}>- {d.name} ({d.image_count} image{d.image_count === 1 ? "" : "s"}- {d.caption_count > 0 ? `, ${d.caption_count} captions` : ""})- </option>- ))}- <option value={UPLOAD_DATASET}>Upload new images...</option>- </select>- {dataset === UPLOAD_DATASET && (- <div className="grid gap-1.5 rounded-md border border-dashed border-border p-2">- <Input- value={uploadName}- placeholder="my-style-photos"- spellCheck={false}- onChange={(e) => setUploadName(e.target.value)}- className="h-8 text-xs"- aria-label="New dataset name"- />- <div className="flex items-center gap-2">- <input- ref={fileInputRef}- type="file"- multiple- accept={DATASET_FILE_ACCEPT}- className="min-w-0 flex-1 text-xs file:mr-2 file:rounded-md file:border-0 file:bg-muted file:px-2 file:py-1 file:text-xs"- aria-label="Training images"- />- <Button- type="button"- size="sm"- variant="secondary"- className="h-8 shrink-0"- onClick={onUpload}- disabled={uploading}- >- {uploading ? "Uploading..." : "Upload"}- </Button>- </div>- <p className="text-ui-11 text-muted-foreground">- 10-50 images work well. Optional captions: a .txt per image (same- filename) or a metadata.jsonl; without them the trigger prompt below- captions every image. You can upload more into the same name later.- </p>- </div>- )}- {selectedDataset && selectedDataset.caption_count === 0 && (- <p className="text-ui-11 text-muted-foreground">- No caption files in this dataset - the trigger prompt below will be used- as the caption for every image.- </p>- )}- </div>-- {/* 3. What to call the result + how to trigger it. */}- <div className="grid gap-1.5">- <Label className="text-xs">Adapter name</Label>- <Input- value={outputDir}- placeholder="my-style-lora"- spellCheck={false}- onChange={(e) => setOutputDir(e.target.value)}- className="h-8 text-xs"- />- </div>- <div className="grid gap-1.5">- <Label className="text-xs">Trigger prompt (how you'll invoke the style later)</Label>- <Input- value={instancePrompt}- placeholder="a photo in SKS style"- onChange={(e) => setInstancePrompt(e.target.value)}- className="h-8 text-xs"- />- </div>-- {/* 4. Hyperparameters, collapsed: the defaults suit a first run, and hiding them keeps the primary flow at three decisions. */}- <button- type="button"- className="w-fit text-xs text-muted-foreground underline-offset-2 hover:underline"- onClick={() => setShowAdvanced((s) => !s)}- aria-expanded={showAdvanced}- >- {showAdvanced ? "Hide training settings" : "Training settings (defaults suit a first run)"}- </button>- {showAdvanced && (- <>- <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">- <div className="grid gap-1.5">- <Label className="text-xs">Steps</Label>- <Input- type="number"- min={1}- value={steps}- onChange={(e) => setSteps(Number(e.target.value) || 1)}- className="h-8 text-xs"- />- </div>- <div className="grid gap-1.5">- <Label className="text-xs">LoRA rank</Label>- <Input- type="number"- min={1}- value={rank}- onChange={(e) => setRank(Number(e.target.value) || 1)}- className="h-8 text-xs"- />- </div>- <div className="grid gap-1.5">- <Label className="text-xs">Resolution</Label>- <Input- type="number"- min={64}- step={64}- value={resolution}- onChange={(e) => setResolution(Number(e.target.value) || 1024)}- className="h-8 text-xs"- />- </div>- <div className="grid gap-1.5">- <Label className="text-xs">Batch</Label>- <Input- type="number"- min={1}- value={batchSize}- onChange={(e) => setBatchSize(Number(e.target.value) || 1)}- className="h-8 text-xs"- />- </div>- </div>- <div className="grid grid-cols-1 gap-3 sm:grid-cols-2">- <div className="grid gap-1.5">- <Label className="text-xs">Learning rate</Label>- <Input- type="number"- step={0.00001}- min={0}- value={learningRate}- onChange={(e) => setLearningRate(Number(e.target.value) || 0.0001)}- className="h-8 text-xs"- />- </div>- <div className="grid gap-1.5">- <Label className="text-xs">Precision</Label>- <select- value={precision}- onChange={(e) => setPrecision(e.target.value as "bf16" | "fp16" | "no")}- className={selectClass}- >- <option value="bf16">bf16 (default)</option>- <option value="fp16">fp16 (older GPUs)</option>- <option value="no">fp32 (no mixed)</option>- </select>- </div>- </div>- </>- )}-- {status && status.status !== "idle" && (- <div className="rounded-lg border border-border bg-muted/30 p-3 text-xs">- <div className="mb-1 flex items-center justify-between">- <span className="font-medium capitalize">{status.status}</span>- <span className="text-muted-foreground">- {status.total_steps > 0 ? `${status.step}/${status.total_steps}` : ""}- </span>- </div>- <div className="mb-2 h-1.5 w-full overflow-hidden rounded-full bg-border">- <div className="h-full bg-primary transition-all" style={{ width: `${pct}%` }} />- </div>- <div className="text-muted-foreground">- {completed- ? "Adapter ready - find it in the LoRA picker on this page."- : status.message}- {status.loss != null && !completed && <> · loss {status.loss.toFixed(4)}</>}- {status.lora_path && (- <div className="mt-1 break-all text-ui-11">Saved: {status.lora_path}</div>- )}- </div>- </div>- )}- </div>-- <DialogFooter>- {active ? (- <Button type="button" variant="destructive" onClick={onStop}>- Stop- </Button>- ) : completed ? (- <>- <Button type="button" variant="secondary" onClick={() => onOpenChange(false)}>- Done - open the LoRA picker- </Button>- <Button type="button" onClick={onStart} disabled={starting || uploading}>- {starting ? "Starting..." : "Train another"}- </Button>- </>- ) : (- <Button type="button" onClick={onStart} disabled={starting || uploading}>- {starting ? "Starting..." : "Start training"}- </Button>- )}- </DialogFooter>- </DialogContent>- </Dialog>- );-}diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsxindex 6021210cf2b..675d8c73f60 100644--- a/studio/frontend/src/features/images/images-page.tsx+++ b/studio/frontend/src/features/images/images-page.tsx@@ -2908,19 +2908,17 @@ export function ImagesPage({ active = true }: { active?: boolean }) {// titlebar here (34px on win/linux, 0 under macOS's native one) as chat does.<div className="diffusion-surface flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden pt-[var(--studio-content-top-inset,0px)]">{/* Top: the model selector, sitting clear of the sidebar and level with the settings column below. Load progress shows in a toast. */}- <div- className={cn(- "pointer-events-none relative z-40 flex h-[48px] shrink-0 items-start justify-between pr-2 pt-[var(--studio-chat-header-padding-top,11px)] md:grid md:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]",- isMobile && "pl-12",- )}- >+ {/* grid at every width, not an overlay below md: the absolute mode switch painted over the model selector and the Video link. */}+ {/* @container, not md:/xl:, because the header is the viewport minus a sidebar the user can drag between 260px and 480px. */}+ <div className="@container pointer-events-none relative z-40 grid h-[48px] shrink-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-start gap-2 pt-[var(--studio-chat-header-padding-top,11px)]"><divclassName={cn("pointer-events-none flex min-w-0 items-center",- !isMobile &&- (!pinned && isTauri+ isMobile+ ? "pl-12"+ : !pinned && isTauri? "pl-[var(--studio-collapsed-chat-controls-inset,0.75rem)]"- : "pl-[var(--studio-media-header-left-inset,1.5rem)]"),+ : "pl-[var(--studio-media-header-left-inset,1.5rem)]",)}><div className="pointer-events-auto flex min-w-0 max-w-full items-center gap-2">@@ -2953,38 +2951,40 @@ export function ImagesPage({ active = true }: { active?: boolean }) {)}</div></div>- {/* Create | Train page-mode switch: desktop grid keeps this centered while the side controls shrink in their columns. */}- <div className="pointer-events-none absolute inset-x-0 top-[var(--studio-chat-header-padding-top,11px)] flex justify-center md:static">- <PillTabs- ariaLabel="Page mode"- value={pageMode}- onValueChange={(v) => setPageMode(v as "create" | "train")}- fit={true}- className="pointer-events-auto h-[34px] [&>button]:h-[34px] [&>button]:px-11 md:[&>button]:px-3 xl:[&>button]:px-11"- tabs={[- {- value: "create",- label: "Create",- icon: (- <HugeiconsIcon icon={SparklesIcon} className="size-3.5" />- ),- },- {- value: "train",- label: "Train",- icon: (- <HugeiconsIcon- icon={TestTubeOutlineIcon}- className="size-3.5"- />- ),- },- ]}- />- </div>- <div className="pointer-events-auto flex items-center gap-2 md:justify-self-end">+ {/* Create | Train page-mode switch, centred on the page rather than tied to the selector width. PillTabs is the app segmented control. */}+ {/* No padding on the grid, so the equal side tracks centre the pill on the header itself; px-11 makes the pair 277px, so it waits for the room. */}+ <PillTabs+ ariaLabel="Page mode"+ value={pageMode}+ onValueChange={(v) => setPageMode(v as "create" | "train")}+ fit={true}+ className="pointer-events-auto h-[34px] justify-self-center [&>button]:h-[34px] [&>button]:px-3 @min-[560px]:[&>button]:px-11"+ tabs={[+ {+ value: "create",+ label: "Create",+ icon: (+ <HugeiconsIcon icon={SparklesIcon} className="size-3.5" />+ ),+ },+ {+ value: "train",+ label: "Train",+ icon: (+ <HugeiconsIcon+ icon={TestTubeOutlineIcon}+ className="size-3.5"+ />+ ),+ },+ ]}+ />+ {/* pr-2 rides the wrapper, not the grid: on the grid it would shift the centred pill by half of it. */}+ <div className="pointer-events-none flex min-w-0 items-center justify-end pr-2">{/* Video is a separate page, so it sits out here rather than in the mode strip. */}- <MediaPageLink to="/video" label="Video" icon={FlimSlateIcon} />+ <div className="pointer-events-auto flex min-w-0 items-center gap-2">+ <MediaPageLink to="/video" label="Video" icon={FlimSlateIcon} />+ </div></div></div>{/* Train mode: the full-page training workspace. Unmounted in Create mode so its polling stops; Create's own state is untouched. */}diff --git a/studio/frontend/src/features/images/train/dataset-labeling-grid.tsx b/studio/frontend/src/features/images/train/dataset-labeling-grid.tsxindex 5c1869ae07e..38c2998d55f 100644--- a/studio/frontend/src/features/images/train/dataset-labeling-grid.tsx+++ b/studio/frontend/src/features/images/train/dataset-labeling-grid.tsx@@ -281,7 +281,8 @@ export function DatasetLabelingGrid({)}</div>{/* Two columns at any width: the column is fixed, so viewport breakpoints do not apply. */}- <div className="hover-scrollbar grid max-h-[420px] grid-cols-2 gap-2.5 overflow-y-auto pb-0.5 pr-1">+ {/* auto-rows-min: past max-h the height is definite and auto rows split it, flattening every tile until its thumbnail collapses. */}+ <div className="hover-scrollbar grid max-h-[420px] auto-rows-min grid-cols-2 gap-2.5 overflow-y-auto pb-0.5 pr-1">{pageRecords.map((r) => (<LabelTilekey={r.filename}diff --git a/studio/frontend/src/features/images/train/diffusion-charts.tsx b/studio/frontend/src/features/images/train/diffusion-charts.tsxindex 5be56f94518..ace0b6246d7 100644--- a/studio/frontend/src/features/images/train/diffusion-charts.tsx+++ b/studio/frontend/src/features/images/train/diffusion-charts.tsx@@ -104,7 +104,7 @@ export function DiffusionCharts({: 0;return (- <div className="grid grid-cols-1 gap-4 lg:grid-cols-2">+ <div className="grid grid-cols-1 gap-4 @min-[720px]:grid-cols-2"><div className="flex flex-col gap-1"><TrainingLossChartCarddata={lossData}diff --git a/studio/frontend/src/features/images/train/diffusion-train-panel.tsx b/studio/frontend/src/features/images/train/diffusion-train-panel.tsxindex cae82c8fc12..c0e5e80e452 100644--- a/studio/frontend/src/features/images/train/diffusion-train-panel.tsx+++ b/studio/frontend/src/features/images/train/diffusion-train-panel.tsx@@ -1786,7 +1786,8 @@ export function DiffusionTrainPanel({{/* Right: the run area. Before a run: training settings + previous-runs history; during/after: the live view. Selecting a previous run re-plots its logs read-only. */}{/* Sections carry no card of their own: spacing and a rule separate them. p-1.5 keeps the chart cards' outer ring from being clipped. */}{/* 40px off the rule, the gutter the settings column has off the page edge. */}- <div className="hover-scrollbar relative flex min-w-0 flex-1 flex-col gap-5 p-1.5 pb-7 pl-8 md:overflow-y-auto md:pl-10">+ {/* @container: this pane is whatever is left beside the 416px rail, so sm: put four stat cells in ~266px against the 396px they need. */}+ <div className="@container hover-scrollbar relative flex min-w-0 flex-1 flex-col gap-5 p-1.5 pb-7 pl-8 md:overflow-y-auto md:pl-10">{viewRun && !hasRun ? (<><div className="flex flex-col gap-3">@@ -1803,7 +1804,7 @@ export function DiffusionTrainPanel({Back</Button></div>- <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">+ <div className="grid grid-cols-2 gap-3 @min-[440px]:grid-cols-4"><Stat label="Status" value={viewRun.status} /><Stat label="Steps" value={`${viewRun.step}/${viewRun.total_steps}`} /><Stat@@ -1959,7 +1960,7 @@ export function DiffusionTrainPanel({style={{ width: `${pct}%` }}/></div>- <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">+ <div className="grid grid-cols-2 gap-3 @min-[440px]:grid-cols-4"><Statlabel="Loss"value={status?.loss != null ? status.loss.toFixed(4) : "-"}diff --git a/studio/frontend/src/features/video/video-page.tsx b/studio/frontend/src/features/video/video-page.tsxindex d536c981c12..b082c70ee73 100644--- a/studio/frontend/src/features/video/video-page.tsx+++ b/studio/frontend/src/features/video/video-page.tsx@@ -1934,8 +1934,9 @@ function VideoGenerator({ active = true }: { active?: boolean }) {// titlebar here (34px on win/linux, 0 under macOS's native one) as chat does.<div className="diffusion-surface flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden pt-[var(--studio-content-top-inset,0px)]">{/* Top: the model selector, sitting clear of the sidebar and level with the controls column below. Load progress shows in a toast. */}- <div className="pointer-events-none relative z-40 flex h-[48px] shrink-0 items-start justify-between pl-[var(--studio-media-header-left-inset,1.5rem)] pr-2 pt-[var(--studio-chat-header-padding-top,11px)]">- <div className="pointer-events-auto flex items-center gap-3">+ <div className="@container pointer-events-none relative z-40 flex h-[48px] shrink-0 items-start justify-between pl-[var(--studio-media-header-left-inset,1.5rem)] pr-2 pt-[var(--studio-chat-header-padding-top,11px)]">+ {/* min-w-0: without it a long resident model name pushes the Images link off a phone screen. */}+ <div className="pointer-events-auto flex min-w-0 items-center gap-3"><ModelSelectormodels={VIDEO_MODELS}value={status?.loaded ? status.repo_id ?? undefined : undefined}@@ -1952,7 +1953,7 @@ function VideoGenerator({ active = true }: { active?: boolean }) {/>{/* Loaded-model status line: family / kind / offload / speed, as the images page surfaces on load. Hidden until a model is resident. */}{status?.loaded && (- <div className="hidden items-center gap-3 text-ui-11 md:flex">+ <div className="hidden min-w-0 items-center gap-3 text-ui-11 @min-[720px]:flex">{status.family && <StatusChip label="Family" value={status.family} />}{status.model_kind && <StatusChip label="Kind" value={status.model_kind} />}{status.offload_policy && (@@ -1962,7 +1963,7 @@ function VideoGenerator({ active = true }: { active?: boolean }) {</div>)}</div>- <div className="pointer-events-auto flex items-center gap-2">+ <div className="pointer-events-auto flex shrink-0 items-center gap-2">{/* Images is a separate page, so it sits out here, not in this page's controls. */}<MediaPageLink to="/images" label="Images" icon={Image03Icon} /></div>diff --git a/tests/studio/test_desktop_reliability_frontend_contract.py b/tests/studio/test_desktop_reliability_frontend_contract.pyindex fae74df5f4c..e8c612d22ea 100644--- a/tests/studio/test_desktop_reliability_frontend_contract.py+++ b/tests/studio/test_desktop_reliability_frontend_contract.py@@ -744,7 +744,9 @@ def test_media_page_headers_out_stack_the_mac_drag_region():for page in (IMAGES_PAGE, VIDEO_PAGE):source = page.read_text(encoding = "utf-8")- before, marker, band = source.partition("h-[48px] shrink-0 items-start justify-between")+ # matched on the band's size alone: Images lays its header out as a grid and Video as a+ # flex row, so the stacking contract below is what this pins, not one layout's utilities.+ before, marker, band = source.partition("h-[48px] shrink-0")assert marker, page.nameopening = before.rsplit('<div className="', 1)[1]for token in ("pointer-events-none", "relative", "z-40"):@@ -760,15 +762,17 @@ def test_media_page_headers_out_stack_the_mac_drag_region():def test_images_header_clears_collapsed_tauri_titlebar_controls():"""Images clears collapsed controls without overlapping its narrow-desktop tabs."""source = IMAGES_PAGE.read_text(encoding = "utf-8")- before, marker, after = source.partition("h-[48px] shrink-0 items-start justify-between")+ before, marker, after = source.partition("h-[48px] shrink-0")assert markeropening = before.rsplit("<div", 1)[1] + marker + after.split(">", 1)[0]header = opening + after.split("{/* Train mode", 1)[0]assert "const { isMobile, pinned } = useSidebar();" in source- assert "isMobile" in opening- assert "pl-12" in opening- assert "md:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]" in opening+ # The tracks carry the insets, so the grid stays unpadded and centres the pill on the header.+ assert "grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]" in opening+ assert not re.search(r"\bp[lrx]-", opening), opening+ assert "isMobile" in header+ assert "pl-12" in headerassert "!pinned && isTauri" in headerassert "pl-[var(--studio-collapsed-chat-controls-inset,0.75rem)]" in headerassert "pl-[var(--studio-media-header-left-inset,1.5rem)]" in header@@ -777,10 +781,12 @@ def test_images_header_clears_collapsed_tauri_titlebar_controls():assert '"pointer-events-auto flex min-w-0 max-w-full items-center gap-2"' in left_controlsassert 'className="!h-[34px] max-w-full overflow-hidden"' in left_controls+ # The pill is a grid item at every width, and its padding keys off the header's own width:+ # md:/xl: are viewport queries, while the header is the viewport minus a resizable sidebar.mode_switch = source.split("Create | Train page-mode switch", 1)[1].split("tabs={[", 1)[0]- assert "md:static" in mode_switch- assert "xl:absolute" not in mode_switch- assert "md:[&>button]:px-3 xl:[&>button]:px-11" in mode_switch+ assert "absolute" not in mode_switch+ assert "justify-self-center" in mode_switch+ assert "[&>button]:px-3 @min-[560px]:[&>button]:px-11" in mode_switchdef test_a_stopped_repair_update_is_recorded_as_canceled_not_failed():