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
Unsloth Desktop: show Stopping… after Stop so a pending cancel doesn't look ignored (#11976)
Leo Borcherding06c60d0f1bd0
diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsxindex cdb7fb7c8c4..fb77e42e146 100644--- a/studio/frontend/src/features/images/images-page.tsx+++ b/studio/frontend/src/features/images/images-page.tsx@@ -235,6 +235,7 @@ import {import {shouldContinueGenerating,shouldReportGenerateError,+ stopButtonLabel,} from "./lib/generation-stop";import {ALLOW_OVERSIZED_HINT,@@ -1470,6 +1471,7 @@ export function ImagesPage({const [busy, setBusy] = useState<Busy>(null);const [genDone, setGenDone] = useState<number | null>(null);+ const [stopping, setStopping] = useState(false);const [genStep, setGenStep] = useState<DiffusionGenerateProgress | null>(null);const genPollTimer = useRef<ReturnType<typeof setInterval> | null>(null);// visibilitychange handler active while a generation poll runs: background tabs clamp@@ -4068,6 +4070,7 @@ export function ImagesPage({setGenStep(null);// Fresh run: a Stop from the PREVIOUS run must not cancel this one.cancelRequested.current = false;+ setStopping(false);cancelAcked.current = false;// Per-run, like the two above: a cancel POST still outstanding from the PREVIOUS run would// leave the guard set and swallow this run's own Stop.@@ -4229,6 +4232,7 @@ export function ImagesPage({setBusy(null);setGenDone(null);setGenStep(null);+ setStopping(false);}}, [allowOversized, prompt, negativePrompt, width, height, steps, guidance, seed, batchSize, count, workflow, initImage, maskImage, strength, extendPct, extendSides, upscaleFactor, upscaleStrength, referenceImages, loras, loraCapable, controlnetCapable, controlnetId, controlImage, controlType, controlStrength, ensureSrc, loadGallery, refreshStatus, unifiedEdit, localizedMode, localizedLayer, maxExtras, referenceResolution, conditioning, editSize, editSizing, sizeLimits]);@@ -4236,6 +4240,7 @@ export function ImagesPage({// races the run that is already finishing.const handleCancelGenerate = useCallback(async () => {cancelRequested.current = true;+ setStopping(true);// One Stop on the wire at a time. The button stays enabled so the click still latches, but a// second POST would target whatever is active when IT arrives.const token = runToken.current;@@ -4246,11 +4251,13 @@ export function ImagesPage({try {const { cancelled } = await cancelDiffusionGeneration(abort.signal);cancelAcked.current = Boolean(cancelled);+ if (!cancelled) setStopping(false);} catch {// An abort means the next run dropped this one on purpose, so there is nothing to report.// Otherwise the request never landed and the denoise runs on, so the click is not handled.if (!abort.signal.aborted) {cancelAcked.current = false;+ setStopping(false);toast.error("Could not reach the server to stop this generation; it is still running");}} finally {@@ -5346,7 +5353,7 @@ export function ImagesPage({onClick={handleCancelGenerate}><Spinner className="mr-2 size-4" />- {genDone != null && count > 1 ? `Stop (${genDone}/${count})` : "Stop"}+ {stopButtonLabel({ stopping, done: genDone, count })}</Button>) : (<Buttondiff --git a/studio/frontend/src/features/images/lib/generation-stop.ts b/studio/frontend/src/features/images/lib/generation-stop.tsindex c50c96257a0..70f09460fc4 100644--- a/studio/frontend/src/features/images/lib/generation-stop.ts+++ b/studio/frontend/src/features/images/lib/generation-stop.ts@@ -30,3 +30,15 @@ export function shouldReportGenerateError(input: {}return !input.message.toLowerCase().includes("cancelled");}++/** A cancel lands only at the end of the current (possibly long) denoise step, so show it was heard. */+export function stopButtonLabel(input: {+ stopping: boolean;+ done: number | null;+ count: number;+ idle?: string;+}): string {+ if (input.stopping) return "Stopping…";+ const idle = input.idle ?? "Stop";+ return input.done != null && input.count > 1 ? `${idle} (${input.done}/${input.count})` : idle;+}diff --git a/studio/frontend/src/features/video/video-page.tsx b/studio/frontend/src/features/video/video-page.tsxindex af4cfeab7c5..73a178b5e81 100644--- a/studio/frontend/src/features/video/video-page.tsx+++ b/studio/frontend/src/features/video/video-page.tsx@@ -213,6 +213,7 @@ import {loadVideoModel,unloadVideoModel,} from "./api";+import { stopButtonLabel } from "@/features/images/lib/generation-stop";import { type Playback, fetchWithFreshLink, playWithMutedFallback, readPlayback } from "./viewer";import { videoThumbnailQueue, withThumbnailRetries } from "./thumbnail-request-queue";@@ -1040,6 +1041,11 @@ function VideoGenerator({const [canReapply, setCanReapply] = useState(false);const [busy, setBusy] = useState<Busy>(null);+ const [stopping, setStopping] = useState(false);+ // A run ends via several paths (poll, refusal, reload): clear on any.+ useEffect(() => {+ if (busy !== "generating") setStopping(false);+ }, [busy]);const [genStep, setGenStep] = useState<VideoGenerateProgress | null>(null);const genPollTimer = useRef<ReturnType<typeof setInterval> | null>(null);// visibilitychange handler active while a generation poll runs: background tabs clamp@@ -3326,9 +3332,12 @@ function VideoGenerator({}, [handleCancelLoad]);const handleCancelGenerate = useCallback(async () => {+ setStopping(true);try {- await cancelVideoGeneration();+ const { cancelled } = await cancelVideoGeneration();+ if (!cancelled) setStopping(false);} catch {+ setStopping(false);// The generation may have already finished; the poll/finally clears the UI.}}, []);@@ -4295,7 +4304,7 @@ function VideoGenerator({onClick={handleCancelGenerate}><Spinner className="mr-2 size-4" />- Cancel+ {stopButtonLabel({ stopping, done: null, count: 1, idle: "Cancel" })}</Button>) : (<Buttondiff --git a/studio/frontend/tests/image-generation-stop.test.ts b/studio/frontend/tests/image-generation-stop.test.tsindex f032c0dcc7e..821b97a6e69 100644--- a/studio/frontend/tests/image-generation-stop.test.ts+++ b/studio/frontend/tests/image-generation-stop.test.ts@@ -8,6 +8,7 @@ import {GENERATION_CANCELLED_SENTINEL,shouldContinueGenerating,shouldReportGenerateError,+ stopButtonLabel,} from "../src/features/images/lib/generation-stop.ts";test("a mounted page with no stop keeps generating", () => {@@ -92,3 +93,11 @@ test("a Stop the backend confirmed still silences the run it stopped", () => {false,);});++test("Stop shows Stopping… once clicked, so a cancel waiting on a long step does not look ignored", () => {+ assert.equal(stopButtonLabel({ stopping: false, done: null, count: 1 }), "Stop");+ assert.equal(stopButtonLabel({ stopping: false, done: 1, count: 4 }), "Stop (1/4)");+ assert.equal(stopButtonLabel({ stopping: true, done: 1, count: 4 }), "Stopping…");+ assert.equal(stopButtonLabel({ stopping: false, done: null, count: 1, idle: "Cancel" }), "Cancel");+ assert.equal(stopButtonLabel({ stopping: true, done: null, count: 1, idle: "Cancel" }), "Stopping…");+});