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
Studio: show a toast as soon as an image or video model is picked (#11626)
oobabooga318fcc97c9b6
diff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.tsindex 042c63aa75e..d63ace3453b 100644--- a/studio/frontend/src/features/chat/index.ts+++ b/studio/frontend/src/features/chat/index.ts@@ -235,6 +235,7 @@ export {resyncInferenceStatusAfterServerModelChange,} from "./hooks/use-chat-model-runtime";export { compareModelDisplayName } from "./lib/external-model-label";+export { ModelLoadDescription } from "./components/model-load-status";export { chatModelLoaded } from "./lib/chat-model-loaded";export type { ChatModelLoadedInput } from "./lib/chat-model-loaded";export {diff --git a/studio/frontend/src/features/hub/download-manager/download-manager-types.ts b/studio/frontend/src/features/hub/download-manager/download-manager-types.tsindex 7dc820ef044..c537c4058ea 100644--- a/studio/frontend/src/features/hub/download-manager/download-manager-types.ts+++ b/studio/frontend/src/features/hub/download-manager/download-manager-types.ts@@ -54,6 +54,8 @@ export interface DownloadRequest {files?: string[];checkpoint?: boolean;callerToast?: CallerToast;+ /** Skip repeat Xet notices for later entries in a staged plan. */+ skipXetNotice?: boolean;}export interface DownloadPresentation {diff --git a/studio/frontend/src/features/hub/download-manager/index.ts b/studio/frontend/src/features/hub/download-manager/index.tsindex 32eee34ab9c..9319046eb5f 100644--- a/studio/frontend/src/features/hub/download-manager/index.ts+++ b/studio/frontend/src/features/hub/download-manager/index.ts@@ -48,6 +48,7 @@ export {export {useStagedDownload,type StagedDownloadEntry,+ type StagedDownloadProgress,} from "./use-staged-download";export {downloadInventoryHintKind,diff --git a/studio/frontend/src/features/hub/download-manager/poll-loop.ts b/studio/frontend/src/features/hub/download-manager/poll-loop.tsindex 79c60115634..1c93a3740c4 100644--- a/studio/frontend/src/features/hub/download-manager/poll-loop.ts+++ b/studio/frontend/src/features/hub/download-manager/poll-loop.ts@@ -811,6 +811,7 @@ export async function startJob(if (onOriginRoute &&onOriginSelection &&+ req.skipXetNotice !== true &&shouldShowXetNotice({kind: req.kind,transport: started,diff --git a/studio/frontend/src/features/hub/download-manager/use-staged-download.ts b/studio/frontend/src/features/hub/download-manager/use-staged-download.tsindex f2ccdf3f067..a36f1e7c348 100644--- a/studio/frontend/src/features/hub/download-manager/use-staged-download.ts+++ b/studio/frontend/src/features/hub/download-manager/use-staged-download.ts@@ -1,7 +1,7 @@// 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 { useCallback, useEffect, useMemo, useRef, useState } from "react";import { toast } from "@/lib/toast";@@ -13,6 +13,13 @@ import {} from "./download-manager-types";import { useRepoDownload } from "./use-repo-download";+/** Total progress for the plan ID returned by `stage()`. */+export interface StagedDownloadProgress {+ downloadedBytes: number;+ totalBytes: number;+ plan: number;+}+export interface StagedDownloadEntry {repoId: string;files: string[];@@ -37,6 +44,8 @@ export function useStagedDownload({onCancelled?: () => void;}) {const [queue, setQueue] = useState<StagedDownloadEntry[] | null>(null);+ // Keep the original total as completed entries leave the queue.+ const [staged, setStaged] = useState({ bytes: 0, plan: 0 });const current = queue?.[0] ?? null;// Every entry is scoped, including a GGUF checkpoint: the Hub's snapshot ignore list drops *.gguf, so a plain snapshot job would finish having fetched everything EXCEPT the weights.@@ -53,6 +62,8 @@ export function useStagedDownload({// Keyed by entry AND staging generation: every scoped pick in a repo shares the "@scope" variant, so restaging would let the first job's completion pass for the new pick.const inFlight = useRef<{ key: string; generation: number } | null>(null);const generation = useRef(0);+ // Only the first entry in each plan may reserve a Xet notice.+ const noticedGeneration = useRef<number | null>(null);const isOurs = (variant: string | null | undefined) =>(variant ?? null) === activeVariant &¤t !== null &&@@ -60,7 +71,7 @@ export function useStagedDownload({inFlight.current.key === entryKey(current) &&inFlight.current.generation === generation.current;- useRepoDownload({+ const job = useRepoDownload({kind: DOWNLOAD_KIND.MODEL,repoId: current?.repoId ?? "__staged_download_idle__",activeVariant,@@ -94,6 +105,8 @@ export function useStagedDownload({const started = { key: entryKey(current), generation: generation.current };// Register ownership before the start request: the panel can expose the job before this await resumes, and a very fast cancel in that window must still belong to this plan.inFlight.current = started;+ const laterEntry = noticedGeneration.current === generation.current;+ noticedGeneration.current = generation.current;void (async () => {const outcome = await downloadManager.requestStart({kind: DOWNLOAD_KIND.MODEL,@@ -104,6 +117,7 @@ export function useStagedDownload({scopeId,files: current.files,checkpoint: current.checkpoint,+ skipXetNotice: laterEntry,});if (!active) return;if (outcome === "started") return;@@ -132,11 +146,28 @@ export function useStagedDownload({};}, [current, activeVariant, scopeId]);- const stage = useCallback((entries: StagedDownloadEntry[]) => {+ const stage = useCallback((entries: StagedDownloadEntry[]): number => {generation.current += 1;inFlight.current = null;setQueue(entries.length > 0 ? entries : null);+ setStaged({+ bytes: entries.reduce((sum, entry) => sum + Math.max(0, entry.bytes), 0),+ plan: generation.current,+ });+ return generation.current;}, []);- return { stage, staging: queue !== null };+ const remainingBytes = (queue ?? []).reduce((sum, entry) => sum + Math.max(0, entry.bytes), 0);+ const currentBytes = current+ ? Math.min(Math.max(0, current.bytes), job.progress?.downloadedBytes ?? 0)+ : 0;+ const downloadedBytes = queue ? Math.max(0, staged.bytes - remainingBytes) + currentBytes : 0;+ const totalBytes = queue ? staged.bytes : 0;+ const plan = staged.plan;+ const progress = useMemo<StagedDownloadProgress | null>(+ () => (totalBytes > 0 ? { downloadedBytes, totalBytes, plan } : null),+ [downloadedBytes, totalBytes, plan],+ );++ return { stage, staging: queue !== null, progress };}diff --git a/studio/frontend/src/features/hub/index.ts b/studio/frontend/src/features/hub/index.tsindex 4ec2baa496f..2222214e447 100644--- a/studio/frontend/src/features/hub/index.ts+++ b/studio/frontend/src/features/hub/index.ts@@ -7,6 +7,7 @@ export {finishExternalJob,jobKeyOf,pendingDrafterPresentation,+ type StagedDownloadProgress,startExternalJob,subscribeJobListeners,type TransportMode,diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsxindex 4cacb798f20..36d18f5f16f 100644--- a/studio/frontend/src/features/images/images-page.tsx+++ b/studio/frontend/src/features/images/images-page.tsx@@ -119,6 +119,7 @@ import {import { resolveDiffusionGgufFilename } from "@/lib/diffusion-gguf-filename";import { createPickGuard, runGgufRepoPick } from "@/lib/diffusion-gguf-pick";import { diffusionRoutePick } from "@/lib/diffusion-route-pick";+import { useDiffusionPickToast, usePickToastProgress } from "@/lib/use-diffusion-pick-toast";import {PRECISION_REFUSAL_TITLE,denseTextEncoderBuildLabel,@@ -1535,6 +1536,7 @@ export function ImagesPage({if (loadToastId.current != null) toast.dismiss(loadToastId.current);loadToastId.current = null;}, []);+ const pickToast = useDiffusionPickToast();// The load toast is built by handleLoad and the progress poll, both defined above// handleCancelLoad, so the action goes through a ref to keep a stable onClick.@@ -1563,6 +1565,8 @@ export function ImagesPage({// need was inert anyway, since the marker was cleared when the PLAN resolved rather than when// the download finished.pickGuard.cancel();+ // That pick can no longer load, so its toast must not keep promising it will.+ pickToast.dismissAll();// Everything in flight is now stale. Clearing the timer stops the NEXT poll tick but not a// request awaiting its response, and those still apply terminal state; the counter is what// they compare against.@@ -1583,7 +1587,7 @@ export function ImagesPage({revertPick(quantRevert.current);quantRevert.current = null;}- }, [dismissLoadToast, pickGuard, revertPick]);+ }, [dismissLoadToast, pickGuard, pickToast, revertPick]);// Mirror to the module cache so a tab switch re-renders instantly.useEffect(() => {@@ -2547,6 +2551,8 @@ export function ImagesPage({// The Advanced values this load must use when pinned earlier: a staged download plans its file// set at pick time and loads minutes later, so live state could outrun the staged files.pinned?: LoadAdvanced,+ // Reuse the pick toast when loading starts.+ pickToastId?: string,): Promise<boolean> => {// Cancel any prior poll loop so two cannot run at once.if (pollTimer.current) clearTimeout(pollTimer.current);@@ -2570,7 +2576,8 @@ export function ImagesPage({// Show the chat-style toast immediately; the poll updates it by id.dismissLoadToast();lastLoadSig.current = null;- loadToastId.current = toast(null, loadToastArgs(IDLE_PROGRESS, undefined, cancelLoadFromToast));+ const handedOver = pickToast.take(pickToastId);+ loadToastId.current = toast(null, loadToastArgs(IDLE_PROGRESS, handedOver, cancelLoadFromToast));// Remember what was loaded so "Reapply" can reload it. Snapshot the prior target first: a load// that fails to START leaves the previous model resident.const prevLastLoad = lastLoad.current;@@ -2636,7 +2643,7 @@ export function ImagesPage({void pollLoadProgress();return settle(true);},- [pollLoadProgress, refreshStatus, dismissLoadToast, currentLoadAdvanced, cancelLoadFromToast],+ [pollLoadProgress, refreshStatus, dismissLoadToast, currentLoadAdvanced, cancelLoadFromToast, pickToast],);// Set or clear the Transform/Inpaint source image; always drop the painted mask, which is@@ -2657,6 +2664,7 @@ export function ImagesPage({advanced: LoadAdvanced;// The pick that staged it: a download outlives its pick, so it must not evict a newer one when it lands.token: number;+ toastId?: string;} | null>(null);const handleLoadRef = useRef(handleLoad);handleLoadRef.current = handleLoad;@@ -2669,9 +2677,12 @@ export function ImagesPage({const runStagedLoad = useCallback((pending: NonNullable<typeof pendingStagedLoad.current>) => {if (pendingStagedLoad.current === pending) pendingStagedLoad.current = null;- if (!pickGuard.isLatest(pending.token)) return;+ if (!pickGuard.isLatest(pending.token)) {+ pickToast.dismiss(pending.toastId);+ return;+ }const owned = stagedQuantRevert.current;- void handleLoadRef.current(pending.repoId, pending.opts, pending.advanced).then((started) => {+ void handleLoadRef.current(pending.repoId, pending.opts, pending.advanced, pending.toastId).then((started) => {if (started) return;if (quantRevert.current && quantRevert.current === owned) {revertPick(quantRevert.current);@@ -2680,25 +2691,33 @@ export function ImagesPage({if (stagedQuantRevert.current === owned) stagedQuantRevert.current = null;});},- [pickGuard, revertPick],+ [pickGuard, revertPick, pickToast],);// Each download-only selection keeps its complete plan until it finishes or is cancelled.const downloadOnlyPlans = useRef<StagedDownloadEntry[][]>([]);const pendingLoadEntries = useRef<StagedDownloadEntry[] | null>(null);const stagedPlan = useRef<"download" | { token: number } | null>(null);- const { stage } = useStagedDownload({+ const { stage, progress: stagedProgress } = useStagedDownload({scopeId: "diffusion",onReady: () => {if (stagedPlan.current === "download") {finishDownloadOnlyPlan();return;}- if (pendingStagedLoad.current?.token === stagedPlan.current?.token) {+ const finished =+ pendingStagedLoad.current?.token === stagedPlan.current?.token+ ? pendingStagedLoad.current+ : null;+ if (finished) {pendingLoadEntries.current = null;}stagedPlan.current = null;- if (startQueuedDownload()) return;+ if (startQueuedDownload()) {+ // Loading waits for queued download-only plans.+ pickToast.setPhase(finished?.toastId, "waiting");+ return;+ }resumePendingLoad();},onCancelled: () => {@@ -2713,6 +2732,7 @@ export function ImagesPage({return;}pendingLoadEntries.current = null;+ pickToast.dismiss(pendingStagedLoad.current?.toastId);// The selected model is only an intent until every dependency is ready: a cancelled companion// must not leave that intent behind for a late completion to load.pendingStagedLoad.current = null;@@ -2727,6 +2747,7 @@ export function ImagesPage({startQueuedDownload();},});+ usePickToastProgress(pickToast, stagedProgress);/** A staged file set, as the identity two picks of the same model share. */function planKey(entries: StagedDownloadEntry[]) {@@ -2760,13 +2781,15 @@ export function ImagesPage({const pending = pendingStagedLoad.current;if (!pending || !pickGuard.isLatest(pending.token)) {pendingLoadEntries.current = null;+ pickToast.dismiss(pending?.toastId);return;}if (entries) {stagedPlan.current = { token: pending.token };- stage(entries);+ pickToast.setPhase(pending.toastId, "downloading", stage(entries));} else if (!active) {stagedLoadDeferred.current = true;+ pickToast.setPhase(pending.toastId, "ready");} else {runStagedLoad(pending);}@@ -2840,9 +2863,12 @@ export function ImagesPage({pendingLoadEntries.current = null;stagedLoadDeferred.current = false;stagedQuantRevert.current = null;+ pickToast.dismissAll();if (!owns()) return true;}if (source !== "hub" && !downloadOnly) return handleLoadRef.current(repoId, opts);+ // Show feedback before the potentially slow Hub metadata request.+ const pickToastId = downloadOnly ? undefined : pickToast.show();// ONE snapshot for the plan and the load it fires: the download runs for minutes without setting `busy`.const advanced = downloadSnapshot ?? currentLoadAdvanced(repoId);// Read before the await: a pick made while the plan resolves replaces quantRevert, and this@@ -2857,7 +2883,10 @@ export function ImagesPage({try {const plan = await requestDownloadPlan(repoId, opts, advanced);// Only load intents are superseded; accepted downloads keep their own plans.- if (!downloadOnly && (pick !== pickSeq.current || !owns())) return true;+ if (!downloadOnly && (pick !== pickSeq.current || !owns())) {+ pickToast.dismiss(pickToastId);+ return true;+ }if (downloadOnly && plan.plan_failed) {throw new Error("Required asset metadata is incomplete. Retry when it is available.");}@@ -2869,6 +2898,7 @@ export function ImagesPage({opts,advanced,token: token ?? pickGuard.claim(),+ toastId: pickToastId,};stagedQuantRevert.current = ownRevert;}@@ -2899,7 +2929,9 @@ export function ImagesPage({const pending = pendingStagedLoad.current;if (downloadOnlyPlans.current.length === 0 && pending) {stagedPlan.current = { token: pending.token };- stage(entries);+ pickToast.setPhase(pickToastId, "downloading", stage(entries));+ } else {+ pickToast.setPhase(pickToastId, "queued");}}return true;@@ -2914,8 +2946,12 @@ export function ImagesPage({// No plan (older backend, metadata hiccup): fall back to the load's own download.}// Re-checked: a plan that REJECTED after a newer pick would otherwise reach the fallback load.- if (!downloadOnly && (pick !== pickSeq.current || !owns())) return true;+ if (!downloadOnly && (pick !== pickSeq.current || !owns())) {+ pickToast.dismiss(pickToastId);+ return true;+ }if (incompatible) {+ pickToast.dismiss(pickToastId);toast.error(incompatible);return downloadOnly;}@@ -2923,9 +2959,9 @@ export function ImagesPage({toast.info("No downloads were planned for this selection");return true;}- return handleLoadRef.current(repoId, opts, advanced);+ return handleLoadRef.current(repoId, opts, advanced, pickToastId);},- [stage, currentLoadAdvanced, requestDownloadPlan, modelSelectionAction, pickGuard, revertPick],+ [stage, currentLoadAdvanced, requestDownloadPlan, modelSelectionAction, pickGuard, revertPick, pickToast],);const resolveDownloadFootprint = useCallback(@@ -2954,7 +2990,8 @@ export function ImagesPage({pendingLoadEntries.current = null;stagedLoadDeferred.current = false;stagedQuantRevert.current = null;- }, []);+ pickToast.dismissAll();+ }, [pickToast]);// A GGUF pick can arrive with only a repo id. The backend rejects a gguf load with no filename// and a pipeline load of a GGUF repo, so name the file from the listing first.@@ -3327,6 +3364,7 @@ export function ImagesPage({}// The deploy owns the page now: a resolving pick or a staged download would load over the base it is about to.pickGuard.cancel();+ pickToast.dismissAll();pendingDeploy.current = { loraId: stem, family: args.family };if (args.trigger.trim()) setPrompt(args.trigger.trim());setPageMode("create");@@ -3344,7 +3382,7 @@ export function ImagesPage({}});},- [applyImageModelDefaults, busy, handleLoad, pickGuard, quant, revertPick, setPageMode],+ [applyImageModelDefaults, busy, handleLoad, pickGuard, pickToast, quant, revertPick, setPageMode],);// Resolves true when the backend accepted the unload; handleCancelLoad reports the cancel only then.diff --git a/studio/frontend/src/features/video/video-page.tsx b/studio/frontend/src/features/video/video-page.tsxindex 7b14bcefe8b..3da76cd6833 100644--- a/studio/frontend/src/features/video/video-page.tsx+++ b/studio/frontend/src/features/video/video-page.tsx@@ -121,6 +121,7 @@ import { useIsMobileShell } from "@/hooks/use-mobile";import { resolveDiffusionGgufFilename } from "@/lib/diffusion-gguf-filename";import { createPickGuard, runGgufRepoPick } from "@/lib/diffusion-gguf-pick";import { diffusionRoutePick } from "@/lib/diffusion-route-pick";+import { useDiffusionPickToast, usePickToastProgress } from "@/lib/use-diffusion-pick-toast";import {PRECISION_REFUSAL_TITLE,denseTextEncoderBuildLabel,@@ -1073,6 +1074,7 @@ function VideoGenerator({if (loadToastId.current != null) toast.dismiss(loadToastId.current);loadToastId.current = null;}, []);+ const pickToast = useDiffusionPickToast();// The load toast is built by handleLoad and the progress poll, both defined above// handleCancelLoad, so the action goes through a ref to keep a stable onClick.@@ -1099,6 +1101,8 @@ function VideoGenerator({// Cancel, not release: a resolving pick or a staged download would load back what was just// ejected. Here rather than in handleUnload, so the loaded-models card is covered too.pickGuard.cancel();+ // That pick can no longer load, so its toast must not keep promising it will.+ pickToast.dismissAll();// Everything in flight is now stale. Clearing the timer stops the NEXT poll tick but not a// request awaiting its response; the counter is what those compare against.cancelSeq.current += 1;@@ -1115,7 +1119,7 @@ function VideoGenerator({revertPick(quantRevert.current);quantRevert.current = null;}- }, [dismissLoadToast, pickGuard, revertPick]);+ }, [dismissLoadToast, pickGuard, pickToast, revertPick]);// Mirror to the module cache so a tab switch re-renders instantly.useEffect(() => {@@ -2423,6 +2427,8 @@ function VideoGenerator({opts: VideoLoadOptions,// Staged loads use the controls their preflight validated.pinned?: VideoLoadAdvanced,+ // Reuse the pick toast when loading starts.+ pickToastId?: string,): Promise<boolean> => {if (pollTimer.current) clearTimeout(pollTimer.current);// Read BEFORE the start request goes out: a Cancel pressed while it is in flight sends an@@ -2444,7 +2450,8 @@ function VideoGenerator({setBusy("loading");dismissLoadToast();lastLoadSig.current = null;- loadToastId.current = toast(null, loadToastArgs(IDLE_PROGRESS, undefined, cancelLoadFromToast));+ const handedOver = pickToast.take(pickToastId);+ loadToastId.current = toast(null, loadToastArgs(IDLE_PROGRESS, handedOver, cancelLoadFromToast));// Snapshot the prior Reapply target first: a load that fails to START leaves the previous model resident.const prevLastLoad = lastLoad.current;const prevCanReapply = canReapply;@@ -2509,6 +2516,7 @@ function VideoGenerator({cancelLoadFromToast,canReapply,currentLoadAdvanced,+ pickToast,],);@@ -2520,6 +2528,7 @@ function VideoGenerator({advanced: VideoLoadAdvanced;// The pick that staged it: a download outlives its pick, so it must not evict a newer one when it lands.token: number;+ toastId?: string;} | null>(null);const handleLoadRef = useRef(handleLoad);handleLoadRef.current = handleLoad;@@ -2532,9 +2541,12 @@ function VideoGenerator({const runStagedLoad = useCallback((pending: NonNullable<typeof pendingStagedLoad.current>) => {if (pendingStagedLoad.current === pending) pendingStagedLoad.current = null;- if (!pickGuard.isLatest(pending.token)) return;+ if (!pickGuard.isLatest(pending.token)) {+ pickToast.dismiss(pending.toastId);+ return;+ }const owned = stagedQuantRevert.current;- void handleLoadRef.current(pending.repoId, pending.opts, pending.advanced).then((started) => {+ void handleLoadRef.current(pending.repoId, pending.opts, pending.advanced, pending.toastId).then((started) => {if (started) return;if (quantRevert.current && quantRevert.current === owned) {revertPick(quantRevert.current);@@ -2543,13 +2555,14 @@ function VideoGenerator({if (stagedQuantRevert.current === owned) stagedQuantRevert.current = null;});},- [pickGuard, revertPick],+ [pickGuard, revertPick, pickToast],);- const { stage } = useStagedDownload({+ const { stage, progress: stagedProgress } = useStagedDownload({scopeId: "diffusion",onReady: () => {if (!active) {stagedLoadDeferred.current = true;+ pickToast.setPhase(pendingStagedLoad.current?.toastId, "ready");return;}const pending = pendingStagedLoad.current;@@ -2558,6 +2571,7 @@ function VideoGenerator({onCancelled: () => {// Same rule as the images page: a plan that ends without every dependency on disk must not// leave an intent for a late completion to act on.+ pickToast.dismiss(pendingStagedLoad.current?.toastId);pendingStagedLoad.current = null;stagedLoadDeferred.current = false;// No load started, so the poll that owns the after-start rollback never runs: put the@@ -2570,6 +2584,7 @@ function VideoGenerator({stagedQuantRevert.current = null;},});+ usePickToastProgress(pickToast, stagedProgress);useEffect(() => {if (!active || !stagedLoadDeferred.current) return;@@ -2596,9 +2611,12 @@ function VideoGenerator({pendingStagedLoad.current = null;stagedLoadDeferred.current = false;stagedQuantRevert.current = null;+ pickToast.dismissAll();const owns = () => token === undefined || pickGuard.holds(token);if (!owns()) return true;if (source !== "hub") return handleLoadRef.current(repoId, opts);+ // Show feedback before the potentially slow Hub metadata request.+ const pickToastId = pickToast.show();const advanced = currentLoadAdvanced(opts.kind);// Read before the await: a pick made while the plan resolves replaces quantRevert, and this@@ -2624,7 +2642,10 @@ function VideoGenerator({gpu_ids: advanced.gpu_ids,});// Superseded. Report started so this pick's `.then` leaves the newer label alone.- if (pick !== pickSeq.current || !owns()) return true;+ if (pick !== pickSeq.current || !owns()) {+ pickToast.dismiss(pickToastId);+ return true;+ }// Same selection-time refusal the images page makes: the plan is the last point at which an// incompatible pairing can be caught before the download it would waste. The check is the FLUX.2// GGUF/base size pairing and the video planner has no diffusers base to pair against, so this is@@ -2636,9 +2657,10 @@ function VideoGenerator({opts,advanced,token: token ?? pickGuard.claim(),+ toastId: pickToastId,};stagedQuantRevert.current = ownRevert;- stage(+ const staged = stage(plan.entries.map((e) => ({repoId: e.repo_id,files: e.files,@@ -2655,20 +2677,25 @@ function VideoGenerator({: e.repo_id === repoId),})),);+ pickToast.setPhase(pickToastId, "downloading", staged);return true;}} catch {// No plan (older backend, metadata hiccup): fall back to the load's own download.}// Re-checked: a plan that REJECTED after a newer pick would otherwise reach the fallback load.- if (pick !== pickSeq.current || !owns()) return true;+ if (pick !== pickSeq.current || !owns()) {+ pickToast.dismiss(pickToastId);+ return true;+ }if (incompatible) {+ pickToast.dismiss(pickToastId);toast.error(incompatible);return false;}- return handleLoadRef.current(repoId, opts, advanced);+ return handleLoadRef.current(repoId, opts, advanced, pickToastId);},- [stage, pickGuard, currentLoadAdvanced],+ [stage, pickGuard, currentLoadAdvanced, pickToast],);// A GGUF pick can arrive with only a repo id. The backend rejects a gguf load with no filename@@ -2855,7 +2882,8 @@ function VideoGenerator({setPendingH3Load(null);abandonPick();pickGuard.cancel();- }, [abandonPick, pickGuard]);+ pickToast.dismissAll();+ }, [abandonPick, pickGuard, pickToast]);const handleReapply = useCallback(() => {// Status is authoritative when another client replaced the resident model; the ref remains the@@ -2879,7 +2907,8 @@ function VideoGenerator({pendingStagedLoad.current = null;stagedLoadDeferred.current = false;stagedQuantRevert.current = null;- }, []);+ pickToast.dismissAll();+ }, [pickToast]);const handleModelSelect = useCallback((id: string, meta: ModelSelectorChangeMeta) => {diff --git a/studio/frontend/src/lib/diffusion-pick-toast.ts b/studio/frontend/src/lib/diffusion-pick-toast.tsnew file mode 100644index 00000000000..4b03d387805--- /dev/null+++ b/studio/frontend/src/lib/diffusion-pick-toast.ts@@ -0,0 +1,112 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// One toast per Hub pick, from planning through download to model loading.++import { toast } from "@/lib/toast";++export type PickToastPhase = "preparing" | "queued" | "downloading" | "waiting" | "ready";++export interface PickToastProgress {+ downloadedBytes: number;+ totalBytes: number;+}++/** Progress tagged with the plan ID returned by `stage()`. */+export interface StagedPlanProgress extends PickToastProgress {+ plan: number;+}++export interface PickToastOptions {+ describe: (phase: PickToastPhase, progress: PickToastProgress | null) => unknown;+ classNames?: Record<string, string>;+}++export interface PickToast {+ /** Replace the current toast with a new pick. */+ show: () => string;+ /** Dismiss only if `id` still owns the toast. */+ dismiss: (id: string | undefined) => void;+ /** Dismiss the current pick toast. */+ dismissAll: () => void;+ /** Bind download progress to `plan`; other phases clear that binding. */+ setPhase: (id: string | undefined, phase: PickToastPhase, plan?: number) => void;+ /** Update progress only for the bound download plan. */+ progress: (progress: StagedPlanProgress | null) => void;+ /** Transfer ownership to the load; return undefined if the toast is gone. */+ take: (id: string | undefined) => string | undefined;+}++// Images and Video share Sonner's store, so IDs must be unique across controllers.+let seq = 0;++export function createPickToast({ describe, classNames }: PickToastOptions): PickToast {+ let live: {+ id: string;+ phase: PickToastPhase;+ plan?: number;+ progress: PickToastProgress | null;+ } | null = null;++ const render = () => {+ if (!live) return;+ const id = live.id;+ toast(null, {+ id,+ description: describe(live.phase, live.progress) as never,+ duration: Infinity,+ closeButton: true,+ ...(classNames ? { classNames } : {}),+ // Prevent updates from reopening a user-dismissed toast.+ onDismiss: () => {+ if (live?.id === id) live = null;+ },+ });+ };++ return {+ show: () => {+ if (live) toast.dismiss(live.id);+ seq += 1;+ live = { id: `diffusion-pick:${seq}`, phase: "preparing", progress: null };+ render();+ return live.id;+ },+ dismiss: (id) => {+ if (id === undefined || live?.id !== id) return;+ live = null;+ toast.dismiss(id);+ },+ dismissAll: () => {+ if (!live) return;+ const gone = live.id;+ live = null;+ toast.dismiss(gone);+ },+ setPhase: (id, phase, plan) => {+ if (id === undefined || live?.id !== id) return;+ live = { id, phase, plan: phase === "downloading" ? plan : undefined, progress: null };+ render();+ },+ progress: (progress) => {+ // Ignore progress from unrelated download-only plans.+ if (!progress || live?.phase !== "downloading" || live.plan !== progress.plan) return;+ if (+ live.progress?.downloadedBytes === progress.downloadedBytes &&+ live.progress?.totalBytes === progress.totalBytes+ ) {+ return;+ }+ live = {+ ...live,+ progress: { downloadedBytes: progress.downloadedBytes, totalBytes: progress.totalBytes },+ };+ render();+ },+ take: (id) => {+ if (id === undefined || live?.id !== id) return undefined;+ live = null;+ return id;+ },+ };+}diff --git a/studio/frontend/src/lib/use-diffusion-pick-toast.tsx b/studio/frontend/src/lib/use-diffusion-pick-toast.tsxnew file mode 100644index 00000000000..29ad0b2fd5a--- /dev/null+++ b/studio/frontend/src/lib/use-diffusion-pick-toast.tsx@@ -0,0 +1,89 @@+// 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 { useEffect, useState } from "react";++import { ModelLoadDescription } from "@/features/chat";+import { formatBytes, type StagedDownloadProgress } from "@/features/hub";+import {+ createPickToast,+ type PickToast,+ type PickToastPhase,+ type PickToastProgress,+} from "@/lib/diffusion-pick-toast";++// Match the load toast's styling for a seamless handoff.+const PICK_TOAST_CLASSNAMES = {+ toast: "chat-model-load-toast items-center gap-2.5",+ content: "gap-0.5 flex-1 min-w-0",+ title: "leading-5",+ description: "mt-0 w-full",+};++function describePick(phase: PickToastPhase, progress: PickToastProgress | null) {+ if (phase === "downloading") {+ return (+ <ModelLoadDescription+ title="Downloading model…"+ message="The model loads once its files are downloaded."+ progressPercent={+ progress ? (progress.downloadedBytes / progress.totalBytes) * 100 : null+ }+ progressLabel={+ progress+ ? `${formatBytes(progress.downloadedBytes)} of ${formatBytes(progress.totalBytes)}`+ : null+ }+ />+ );+ }+ if (phase === "queued") {+ return (+ <ModelLoadDescription+ title="Download queued"+ message="It starts once the current download finishes."+ />+ );+ }+ if (phase === "waiting") {+ return (+ <ModelLoadDescription+ title="Model downloaded"+ message="It loads once the other downloads finish."+ />+ );+ }+ if (phase === "ready") {+ return (+ <ModelLoadDescription+ title="Model downloaded"+ message="It loads when you return to this page."+ />+ );+ }+ return (+ <ModelLoadDescription+ title="Preparing download…"+ message="Checking which files this model needs."+ />+ );+}++/** One pick toast per page, dropped with the page. */+export function useDiffusionPickToast(): PickToast {+ const [pickToast] = useState(() =>+ createPickToast({ describe: describePick, classNames: PICK_TOAST_CLASSNAMES }),+ );+ useEffect(() => () => pickToast.dismissAll(), [pickToast]);+ return pickToast;+}++/** Bind progress separately because staging is initialized after the pick toast. */+export function usePickToastProgress(+ pickToast: PickToast,+ progress: StagedDownloadProgress | null,+): void {+ useEffect(() => {+ pickToast.progress(progress);+ }, [pickToast, progress]);+}diff --git a/studio/frontend/tests/diffusion-pick-toast.test.ts b/studio/frontend/tests/diffusion-pick-toast.test.tsnew file mode 100644index 00000000000..95f694d2255--- /dev/null+++ b/studio/frontend/tests/diffusion-pick-toast.test.ts@@ -0,0 +1,162 @@+// 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 assert from "node:assert/strict";+import test from "node:test";+import { register } from "node:module";++register("./helpers/toast-resolver.mjs", import.meta.url);++const { calls } = await import("./helpers/toast-stub.mjs");+const { createPickToast } = await import("../src/lib/diffusion-pick-toast.ts");+const { readSrc } = await import("./helpers/kit.ts");++type Raise = {+ kind: string;+ id?: string;+ options?: { id?: string; description?: unknown; onDismiss?: () => void };+};++function make() {+ calls.length = 0;+ return createPickToast({+ describe: (phase, progress) =>+ progress ? `${phase} ${progress.downloadedBytes}/${progress.totalBytes}` : phase,+ });+}++function shown(): Raise[] {+ return (calls as Raise[]).slice();+}++test("a pick raises its toast at once, before any plan or download", () => {+ const pick = make();+ const id = pick.show();+ assert.deepEqual(+ shown().map((c) => [c.kind, c.options?.id, c.options?.description]),+ [["default", id, "preparing"]],+ );+});++test("a newer pick replaces the older toast, and the stale pick cannot touch it", () => {+ const pick = make();+ const older = pick.show();+ const newer = pick.show();+ assert.notEqual(older, newer);+ assert.deepEqual(shown()[1], { kind: "dismiss", id: older });++ calls.length = 0;+ // The superseded pick's plan resolves late and cleans up after itself.+ pick.dismiss(older);+ pick.setPhase(older, "downloading", 1);+ assert.deepEqual(shown(), []);+ assert.equal(pick.take(older), undefined);+});++test("progress shows only while downloading, and each phase starts from its own plan", () => {+ const pick = make();+ const id = pick.show();+ calls.length = 0;+ pick.progress({ downloadedBytes: 5, totalBytes: 10, plan: 1 });+ assert.deepEqual(shown(), [], "a queued or preparing pick showed another plan's bytes");++ pick.setPhase(id, "downloading", 2);+ pick.progress({ downloadedBytes: 1, totalBytes: 10, plan: 2 });+ pick.progress({ downloadedBytes: 1, totalBytes: 10, plan: 2 });+ pick.progress({ downloadedBytes: 4, totalBytes: 10, plan: 2 });+ assert.deepEqual(+ shown().map((c) => c.options?.description),+ ["downloading", "downloading 1/10", "downloading 4/10"],+ );+});++test("a download-only plan staged after the pick's own never shows in its toast", () => {+ // A queued download-only plan uses the same progress hook after the pick finishes.+ const pick = make();+ const id = pick.show();+ pick.setPhase(id, "downloading", 3);+ pick.progress({ downloadedBytes: 10, totalBytes: 10, plan: 3 });+ calls.length = 0;++ pick.progress({ downloadedBytes: 2, totalBytes: 50, plan: 4 });+ assert.deepEqual(shown(), [], "another plan's bytes reached the pick's toast");++ pick.setPhase(id, "waiting");+ pick.progress({ downloadedBytes: 20, totalBytes: 50, plan: 4 });+ assert.deepEqual(shown().map((c) => c.options?.description), ["waiting"]);+});++test("the Images and Video toasts never share an id", () => {+ // Both pages stay mounted and share Sonner's store.+ const images = make();+ const video = createPickToast({ describe: (phase) => phase });+ const imagesId = images.show();+ const videoId = video.show();+ assert.notEqual(imagesId, videoId);++ calls.length = 0;+ images.dismissAll();+ assert.deepEqual(shown(), [{ kind: "dismiss", id: imagesId }]);+ video.setPhase(videoId, "downloading", 1);+ assert.equal(shown().at(-1)?.options?.id, videoId, "the Video toast went with the Images one");+});++test("the load takes the toast over in place and later ticks leave it alone", () => {+ const pick = make();+ const id = pick.show();+ pick.setPhase(id, "downloading", 1);+ assert.equal(pick.take(id), id);++ calls.length = 0;+ pick.progress({ downloadedBytes: 9, totalBytes: 10, plan: 1 });+ pick.dismissAll();+ assert.deepEqual(shown(), [], "the pick kept writing to the load's toast");+ assert.equal(pick.take(id), undefined, "one toast was handed over twice");+});++test("a toast the user closed is not raised again by the next tick", () => {+ const pick = make();+ const id = pick.show();+ pick.setPhase(id, "downloading", 1);+ const closed = shown().at(-1)?.options?.onDismiss;+ assert.ok(closed);+ closed();++ calls.length = 0;+ pick.progress({ downloadedBytes: 3, totalBytes: 10, plan: 1 });+ assert.deepEqual(shown(), []);+ // The load then raises its own toast rather than reusing the closed id.+ assert.equal(pick.take(id), undefined);+});++test("a cancelled or retired pick drops its toast", () => {+ const pick = make();+ const id = pick.show();+ calls.length = 0;+ pick.dismiss(id);+ assert.deepEqual(shown(), [{ kind: "dismiss", id }]);++ const next = pick.show();+ calls.length = 0;+ pick.dismissAll();+ assert.deepEqual(shown(), [{ kind: "dismiss", id: next }]);+ pick.dismiss(undefined);+ assert.equal(shown().length, 1, "an absent id dropped something");+});++test("every cancelled pick drops its toast on both pages", () => {+ // A cancelled pick can no longer load, so a toast left up would promise a load that never comes.+ for (const page of ["features/images/images-page.tsx", "features/video/video-page.tsx"]) {+ const lines = readSrc(page).split("\n");+ const cancels = lines.flatMap((line, i) => (line.includes("pickGuard.cancel();") ? [i] : []));+ assert.ok(cancels.length > 0, page);+ for (const i of cancels) {+ const after = lines+ .slice(i + 1, i + 4)+ .filter((line) => !line.trim().startsWith("//"))+ .join("\n");+ assert.match(after, /pickToast\.dismissAll\(\);/, `${page}:${i + 1}`);+ }+ }+});+diff --git a/studio/frontend/tests/download-start-lifecycle.test.ts b/studio/frontend/tests/download-start-lifecycle.test.tsindex b73c734c489..1d1673dcc1a 100644--- a/studio/frontend/tests/download-start-lifecycle.test.ts+++ b/studio/frontend/tests/download-start-lifecycle.test.ts@@ -212,3 +212,72 @@ test("a stale model selection does not spend an Xet notice reservation", async (removeJob(key);}});++test("a later entry of a staged plan starts without reserving another Xet notice", async () => {+ calls.length = 0;+ let reservations = 0;++ globalThis.fetch = (async (input: RequestInfo | URL) => {+ const url = String(input);+ if (url.startsWith("/api/hub/active-downloads")) {+ return json({ downloads: [] });+ }+ if (url.startsWith("/api/studio/download-transport-capabilities")) {+ return json({+ http: { available: true, reason: null },+ xet: { available: true, reason: null },+ auto_resolves_to: "xet",+ auto_reason: null,+ });+ }+ if (url.startsWith("/api/hub/transport-status")) {+ return json({ has_partial: false, last_transport: null, resumable: false });+ }+ if (url === "/api/hub/download") {+ return json({+ accepted: true,+ attached: false,+ state: "running",+ generation: 9,+ transport: "xet",+ job_key: "backend-key",+ });+ }+ if (url === "/api/settings/xet-notice/reserve") {+ reservations += 1;+ return json({ granted: true, shown: reservations, limit: 3 });+ }+ throw new Error(`Unexpected request: ${url}`);+ }) as typeof fetch;++ const first = {+ kind: "model" as const,+ repoId: "org/diffusion-checkpoint",+ variant: "@diffusion",+ expectedBytes: 4096,+ };+ const later = {+ kind: "model" as const,+ repoId: "org/diffusion-base",+ variant: "@diffusion",+ expectedBytes: 8192,+ skipXetNotice: true,+ };+ try {+ assert.equal(await requestStart(first), "started");+ await new Promise<void>((resolve) => setImmediate(resolve));+ assert.equal(reservations, 1);+ assert.equal(visibleToastCalls().length, 1);++ assert.equal(await requestStart(later), "started");+ await new Promise<void>((resolve) => setImmediate(resolve));+ assert.equal(reservations, 1, "the later entry reserved a second notice");+ assert.equal(visibleToastCalls().length, 1, "the later entry raised a second toast");+ } finally {+ for (const req of [first, later]) {+ const key = jobKeyOf(req.kind, req.repoId, req.variant);+ finalize(key, "complete");+ removeJob(key);+ }+ }+});diff --git a/studio/frontend/tests/image-model-recall.test.ts b/studio/frontend/tests/image-model-recall.test.tsindex a4bd43ca24d..3707c9ac796 100644--- a/studio/frontend/tests/image-model-recall.test.ts+++ b/studio/frontend/tests/image-model-recall.test.ts@@ -179,8 +179,10 @@ test("a new model pick cancels recalled generation and retires the staged load",pendingLoadEntries: { current: ["previous"] },stagedLoadDeferred: { current: true },stagedQuantRevert: { current: { prev: "Q8_0" } },+ pickToast: { dismissed: 0, dismissAll() { this.dismissed += 1; } },};new Function(...Object.keys(scope), outputText)(...Object.values(scope));+ assert.equal(scope.pickToast.dismissed, 1);assert.equal(scope.pendingRecalledGeneration.current, null);assert.equal(scope.pickSeq.current, 5);assert.equal(scope.pendingStagedLoad.current, null);diff --git a/studio/frontend/tests/video-download-plan-payload.test.ts b/studio/frontend/tests/video-download-plan-payload.test.tsindex 5d6b14a4d40..50da505b13b 100644--- a/studio/frontend/tests/video-download-plan-payload.test.ts+++ b/studio/frontend/tests/video-download-plan-payload.test.ts@@ -48,7 +48,7 @@ test("the staged plan pins its controls through the eventual load", () => {assert.match(flow, /pendingStagedLoad\.current = \{\s*repoId,\s*opts,\s*advanced,/);assert.ok(source.includes("pending.opts, pending.advanced"));- assert.ok(flow.includes("handleLoadRef.current(repoId, opts, advanced)"));+ assert.match(flow, /handleLoadRef\.current\(repoId, opts, advanced[,)]/);});test("the video picker resolves the full GGUF footprint", () => {diff --git a/tests/studio/playwright_image_download_cancel_retry.py b/tests/studio/playwright_image_download_cancel_retry.pyindex 2cc6e4e4400..f39f3accba9 100644--- a/tests/studio/playwright_image_download_cancel_retry.py+++ b/tests/studio/playwright_image_download_cancel_retry.py@@ -499,7 +499,12 @@ def main() -> None:if not CHECKPOINT_CACHED:assert "Model file" in panel_textassert page.get_by_text("Downloading model requirements", exact = False).count() == 0- assert page.get_by_text("Downloading model…", exact = True).count() == 0+ # A load pick's own toast tracks the staged plan; a download-only pick shows none.+ pick_toast = page.locator("[data-sonner-toast]").filter(has_text = "Downloading model…")+ if DOWNLOAD_ONLY:+ assert pick_toast.count() == 0+ else:+ expect(pick_toast).to_contain_text("of 8.2 GB" if CHECKPOINT_CACHED else "of 11 GB")assert page.get_by_text("Loading to GPU…", exact = True).count() == 0assert state["load_calls"] == 0, "missing companion bypassed staging"page.screenshot(path = str(ART_DIR / "image-companion-download.png"), full_page = True)diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.pyindex 0357654da42..3c6fa99558c 100644--- a/tests/studio/test_model_picker_contracts.py+++ b/tests/studio/test_model_picker_contracts.py@@ -1515,7 +1515,7 @@ def test_diffusion_pages_stage_downloads_through_the_manager():# A missing plan must still load rather than dead-end.assert "catch" in body, f"{rel}: no fallback when the plan is unavailable"- assert "handleLoadRef.current(repoId, opts, advanced)" in body, rel+ assert "handleLoadRef.current(repoId, opts, advanced, pickToastId)" in body, reldef test_every_diffusion_planner_filters_the_cache_before_staging():@@ -1675,7 +1675,8 @@ def test_a_plan_that_lands_after_a_newer_pick_is_dropped():'if (source !== "hub"'), f"{rel}: a non-hub pick returns without invalidating an in-flight hub plan"guards = re.findall(- r"if \((?:!downloadOnly && \()?pick !== pickSeq\.current(?: \|\| !owns\(\))?\){1,2} return (\w+);",+ r"if \((?:!downloadOnly && \()?pick !== pickSeq\.current(?: \|\| !owns\(\))?\){1,2} "+ r"(?:\{\s*pickToast\.dismiss\(pickToastId\);\s*)?return (\w+);",text,)assert guards, f"{rel}: a superseded plan is not dropped"@@ -1685,7 +1686,8 @@ def test_a_plan_that_lands_after_a_newer_pick_is_dropped():# The fallback load after a rejected plan is guarded too.tail = text[text.rindex("} catch") :]assert re.search(- r"if \((?:!downloadOnly && \()?pick !== pickSeq\.current(?: \|\| !owns\(\))?\){1,2} return true;.*?return handleLoadRef",+ r"if \((?:!downloadOnly && \()?pick !== pickSeq\.current(?: \|\| !owns\(\))?\){1,2} "+ r"(?:\{\s*pickToast\.dismiss\(pickToastId\);\s*)?return true;.*?return handleLoadRef",tail,re.S,), f"{rel}: a plan that rejected after a newer pick still reaches the fallback load"@@ -1877,7 +1879,7 @@ def test_staged_downloads_use_one_actionable_download_surface():duplicates the same state and gives users another X that only dismisses copy."""staged = _read("features/hub/download-manager/use-staged-download.ts")stage_fn = re.search(- r"const stage = useCallback\(\(entries: StagedDownloadEntry\[\]\) => \{.*?\n \}, \[\]\);",+ r"const stage = useCallback\(\(entries: StagedDownloadEntry\[\]\)(?:: number)? => \{.*?\n \}, \[\]\);",staged,re.S,)