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.

studio: add Cancel button to model loading toast popup

Daniel Hana0fdf03340e8
diff --git a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
index 3f8d41d7431..c775ace0844 100644
--- a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
+++ b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
@@ -280,18 +280,37 @@ export function useChatModelRuntime() {
}
}
- const loadPromise = performLoad().finally(() => {
- setLoadingModel(null);
- setLoadAbortController(null);
- });
-
- await toast.promise(loadPromise, {
- loading: "Loading model…",
- success: `${displayName} loaded`,
- error: (err) =>
- err instanceof Error ? err.message : "Failed to load model",
+ const toastId = toast.loading("Loading model…", {
description: loadingDescription,
+ action: {
+ label: "Cancel",
+ onClick: () => {
+ abortCtrl.abort();
+ setLoadingModel(null);
+ setLoadAbortController(null);
+ unloadModel({ model_path: modelId }).catch(() => {});
+ clearCheckpoint();
+ toast.dismiss(toastId);
+ toast.info("Model loading cancelled");
+ },
+ },
});
+
+ try {
+ await performLoad();
+ toast.success(`${displayName} loaded`, { id: toastId });
+ } catch (err) {
+ if (!abortCtrl.signal.aborted) {
+ toast.error(
+ err instanceof Error ? err.message : "Failed to load model",
+ { id: toastId },
+ );
+ }
+ throw err;
+ } finally {
+ setLoadingModel(null);
+ setLoadAbortController(null);
+ }
} catch (error) {
setLoadingModel(null);
const message =