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: ask before Update stops a training run in the desktop app (#12313)
Nilayd4155b7a65e5
diff --git a/studio/frontend/src/hooks/use-tauri-update.ts b/studio/frontend/src/hooks/use-tauri-update.tsindex 11048b92c85..eba4ea2b671 100644--- a/studio/frontend/src/hooks/use-tauri-update.ts+++ b/studio/frontend/src/hooks/use-tauri-update.ts@@ -412,6 +412,7 @@ export function useTauriUpdate(isExternalServer = false) {if (!update) return;const { invoke } = await import("@tauri-apps/api/core");+ if (!(await invoke<boolean>("confirm_backend_update"))) return;setUpdatePhase("backend");updateStatus("updating-backend");replaceLogs([]);diff --git a/studio/frontend/tests/tauri-update-schedule.test.ts b/studio/frontend/tests/tauri-update-schedule.test.tsindex acca3f0e6e3..ebb2d3996e3 100644--- a/studio/frontend/tests/tauri-update-schedule.test.ts+++ b/studio/frontend/tests/tauri-update-schedule.test.ts@@ -30,6 +30,7 @@ interface HookHarnessOptions {tauri?: boolean;/** Whether `start_backend_update` resolves; the shell steps only run if it does. */backendUpdate?: "completes" | "fails";+ updateConfirmed?: boolean;/** One entry per `desktopUpdateBundleStatus` poll; the last one repeats. */bundleStates?: BundleState[];}@@ -239,6 +240,7 @@ function hookHarness(noUpdateAt,tauri = true,backendUpdate = "fails",+ updateConfirmed = true,bundleStates = [{ version: null, downloaded: false, downloading: false }],}: HookHarnessOptions = {},) {@@ -251,6 +253,7 @@ function hookHarness(let checks = 0;let polls = 0;let relaunches = 0;+ let backendUpdates = 0;const events = new Map<string, Set<(event: { payload: unknown }) => void>>();const emit = (name: string, payload?: unknown) => {for (const callback of events.get(name) ?? []) callback({ payload });@@ -322,7 +325,9 @@ function hookHarness(};}if (command === "desktop_update_cleanup_armed") return true;+ if (command === "confirm_backend_update") return updateConfirmed;if (command === "start_backend_update") {+ backendUpdates += 1;// The command itself decides the backend step, rather than a stub that happens to throw.if (backendUpdate === "fails")throw new Error("backend update failed");@@ -365,6 +370,7 @@ function hookHarness(polls: () => polls,progressUpdates: host.progressUpdates,relaunches: () => relaunches,+ backendUpdates: () => backendUpdates,statusUpdates: host.statusUpdates,};}@@ -461,6 +467,17 @@ test("scheduled checks leave a failed install in its error state", async (t) =>assert.equal(hook.statusUpdates.at(-1), "error");});+test("keeping training at the update prompt keeps the update on offer", async (t) => {+ const hook = hookHarness(t, { updateConfirmed: false });+ hook.browser.fireTimeouts(STARTUP_DELAY_MS);+ await settle();++ await hook.controller.installUpdate();+ await settle();+ assert.equal(hook.backendUpdates(), 0);+ assert.deepEqual(hook.statusUpdates, ["checking", "available"]);+});+test("a bundle download the update did not start reports its progress", async (t) => {const hook = hookHarness(t, {backendUpdate: "completes",diff --git a/studio/src-tauri/src/commands.rs b/studio/src-tauri/src/commands.rsindex 4f597f73654..56ffba01415 100644--- a/studio/src-tauri/src/commands.rs+++ b/studio/src-tauri/src/commands.rs@@ -954,6 +954,22 @@ pub fn install_system_packages(Err("Elevated package install is only supported on Linux".to_string())}+fn backend_update_confirmed(training_active: bool, confirm: impl FnOnce() -> bool) -> bool {+ !training_active || confirm()+}++#[tauri::command]+pub async fn confirm_backend_update(app: AppHandle) -> bool {+ // blocking_show parks its thread until the user answers: keep it off the async workers.+ tauri::async_runtime::spawn_blocking(move || {+ backend_update_confirmed(crate::training_is_active(&app), || {+ crate::confirm_update_during_training(&app)+ })+ })+ .await+ .unwrap_or(false)+}+/// Run backend update: stop server, run `unsloth studio update`, emit progress./// Does NOT restart the backend — the frontend handles shell update + relaunch after.#[tauri::command]@@ -1337,6 +1353,26 @@ mod tests {));}+ #[test]+ fn keeping_training_at_the_update_prompt_declines_the_update() {+ assert!(!super::backend_update_confirmed(true, || false));+ }++ #[test]+ fn updating_anyway_during_training_confirms_the_update() {+ assert!(super::backend_update_confirmed(true, || true));+ }++ #[test]+ fn updating_without_training_does_not_ask() {+ let mut asked = false;+ assert!(super::backend_update_confirmed(false, || {+ asked = true;+ false+ }));+ assert!(!asked);+ }+#[tokio::test]async fn mutation_guard_blocks_second_external_backend_when_owned_child_is_ignored() {crate::desktop_backend_owner::install_test_owner(ROOT_ID, OWNER_TOKEN);diff --git a/studio/src-tauri/src/main.rs b/studio/src-tauri/src/main.rsindex 1b510357d8d..0a03dd63bc0 100644--- a/studio/src-tauri/src/main.rs+++ b/studio/src-tauri/src/main.rs@@ -991,6 +991,23 @@ fn confirm_quit_during_training(app: &tauri::AppHandle) -> bool {.blocking_show()}+fn confirm_update_during_training(app: &tauri::AppHandle) -> bool {+ use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind};++ app.dialog()+ .message(+ "Training is starting or still running. Updating now stops the \+ run and loses progress since the last checkpoint.",+ )+ .kind(MessageDialogKind::Warning)+ .title("Training in progress")+ .buttons(MessageDialogButtons::OkCancelCustom(+ "Update anyway".to_string(),+ "Keep training".to_string(),+ ))+ .blocking_show()+}+/// renderer-owned downloads, shell updates and unsaved transcripts must also protect native quit.#[derive(Default)]pub struct RendererActivity {@@ -2160,6 +2177,7 @@ fn main() {commands::get_server_logs,commands::open_logs_dir,commands::open_models_dir,+ commands::confirm_backend_update,commands::start_backend_update,commands::start_managed_repair,commands::native_path_leases_usable,