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
// 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 { create } from "zustand";
type Resolver = (confirmed: boolean) => void;
/** What confirming does: reload, leave no model loaded, or unload just this one. */
export type StopRunningChatsEffect = "reload" | "unload" | "unloadOne";
// One at a time: a new request declines any pending one so no promise leaks.
let pendingResolver: Resolver | null = null;
interface StopRunningChatsDialogStore {
open: boolean;
count: number;
titles: string[];
action: string;
hasNonChat: boolean;
effect: StopRunningChatsEffect;
requestConfirm: (args: {
count: number;
titles?: string[];
action?: string;
hasNonChat?: boolean;
effect?: StopRunningChatsEffect;
}) => Promise<boolean>;
resolve: (confirmed: boolean) => void;
}
export const useStopRunningChatsDialogStore =
create<StopRunningChatsDialogStore>()((set) => ({
open: false,
count: 0,
titles: [],
action: "",
hasNonChat: false,
effect: "reload",
requestConfirm: ({
count,
titles = [],
action = "",
hasNonChat = false,
effect = "reload",
}) =>
new Promise<boolean>((resolve) => {
pendingResolver?.(false);
pendingResolver = resolve;
set({ open: true, count, titles, action, hasNonChat, effect });
}),
resolve: (confirmed) => {
const resolver = pendingResolver;
pendingResolver = null;
set({
open: false,
count: 0,
titles: [],
action: "",
hasNonChat: false,
effect: "reload",
});
resolver?.(confirmed);
},
}));