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: saving a preset no longer brings it back on the model it was tuned on (#14603)

Roydon Sequeiraf7769b434904
diff --git a/studio/frontend/src/features/chat/chat-settings-sheet.tsx b/studio/frontend/src/features/chat/chat-settings-sheet.tsx
index 22f1d358f02..a93cdef3876 100644
--- a/studio/frontend/src/features/chat/chat-settings-sheet.tsx
+++ b/studio/frontend/src/features/chat/chat-settings-sheet.tsx
@@ -954,15 +954,20 @@ export function ChatSettingsPanel({
: trimmed;
const next = customPresets.filter((p) => p.name !== saveName);
const loadConfig = capturePresetLoadConfig();
+ // Live, as set() does: a number box this click blurred is not in this render's `params` yet.
+ const live = useChatRuntimeStore.getState().params;
+ const saved = seedDraft === null ? live : { ...live, seed: committedSeed };
const merged = [
...next,
{
name: saveName,
- params: toPresetParams(paramsWithCommittedSeed),
+ params: toPresetParams(saved),
...(loadConfig ? { loadConfig } : {}),
},
];
setCustomPresets(merged);
+ // As a pick does: drop the hand edits filed under the loaded model, or Default replays them.
+ setParams(saved, { fromPreset: true });
setActivePreset(saveName);
setActivePresetSource("custom");
setPresetNameInput(saveName);
diff --git a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
index fb5602d414b..5ddb76e0490 100644
--- a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
+++ b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
@@ -2614,7 +2614,7 @@ type ChatRuntimeStore = {
fromModelDefaults?: boolean;
maxTokensCap?: number;
migrateOwnedGlobalQwenDefaults?: boolean;
- /** A preset pick: not an edit of the loaded model, so its remembered params are dropped
+ /** A preset pick or save: not an edit of the loaded model, so its remembered params are dropped
* instead of overwritten, and its recommendation applies again on the next load. */
fromPreset?: boolean;
},
diff --git a/studio/frontend/tests/chat-sampling-seed.test.ts b/studio/frontend/tests/chat-sampling-seed.test.ts
index 4f7270b103d..5931d8cffe6 100644
--- a/studio/frontend/tests/chat-sampling-seed.test.ts
+++ b/studio/frontend/tests/chat-sampling-seed.test.ts
@@ -312,7 +312,8 @@ test("a models[] row states every flag the seed gate reads", () => {
test("saving a preset takes the seed being typed, not the one before it", () => {
const panel = readText("../src/features/chat/chat-settings-sheet.tsx");
// React has not re-rendered by onClick after blur, so Save must read the committed seed.
- assert.match(panel, /params: toPresetParams\(paramsWithCommittedSeed\)/);
+ assert.match(panel, /const saved = seedDraft === null \? live : \{ \.\.\.live, seed: committedSeed \};/);
+ assert.match(panel, /params: toPresetParams\(saved\)/);
const unsaved = slice(panel, "const hasUnsavedPresetChanges", "const presetSaveState");
assert.match(unsaved, /isSamePresetConfig\(\s*activePresetDefinition\.params,\s*paramsWithCommittedSeed,/);
assert.match(unsaved, /committedSeed !== \(params\.seed \?\? null\)/);
diff --git a/studio/frontend/tests/preset-model-memory.test.ts b/studio/frontend/tests/preset-model-memory.test.ts
index 84e16a2ceeb..6d91e0b5257 100644
--- a/studio/frontend/tests/preset-model-memory.test.ts
+++ b/studio/frontend/tests/preset-model-memory.test.ts
@@ -9,7 +9,7 @@ import assert from "node:assert/strict";
import { register } from "node:module";
import test from "node:test";
-import { installLocalStorageFake } from "./helpers/kit.ts";
+import { installLocalStorageFake, readSrc } from "./helpers/kit.ts";
const { store: localStorageFake } = installLocalStorageFake();
localStorageFake.set("unsloth_chat_settings_imported_to_studio_db", "true");
@@ -76,6 +76,14 @@ function pickPreset(preset: Preset): void {
store.setActivePresetSource(getPresetSource(preset.name));
}
+/** chat-settings-sheet's savePresetWithName: the screen as it is becomes the custom preset. */
+function savePreset(name: string): void {
+ const store = useChatRuntimeStore.getState();
+ store.setParams(store.params, { fromPreset: true });
+ store.setActivePreset(name);
+ store.setActivePresetSource("custom");
+}
+
function sampling() {
const { temperature, topP, topK, systemPrompt } =
useChatRuntimeStore.getState().params;
@@ -340,6 +348,39 @@ test("a preset pick writes the whole preset to the installation defaults", async
assert.equal(written.systemPrompt, "Talk like a pirate.");
});
+test("a preset saved from hand edits does not come back after ejecting and picking Default", async () => {
+ loadOrPoll(GEMMA);
+ const store = useChatRuntimeStore.getState();
+ store.setActivePresetSource("modified");
+ store.setParams({
+ ...store.params,
+ temperature: 0.3,
+ topP: 0.7,
+ topK: 10,
+ systemPrompt: "Talk like a pirate.",
+ });
+ savePreset("Pirate");
+ useChatRuntimeStore.getState().clearCheckpoint();
+ pickPreset(DEFAULT);
+ loadOrPoll(GEMMA);
+ assert.deepEqual(sampling(), AUTOMATIC);
+ await settled();
+ const byModel = stored().inferenceParamsByModel as Record<string, Record<string, unknown>>;
+ assert.deepEqual(presetOwnedKeys(byModel[GEMMA]), [], "nothing comes back on the next launch");
+});
+
+// Source-level (the sheet needs a DOM); savePreset above stands in for this call.
+test("saving a preset hands the loaded model's sampling to it, as a pick does", () => {
+ const save = readSrc("features/chat/chat-settings-sheet.tsx").match(
+ /function savePresetWithName\([^)]*\) \{[\s\S]*?\n {2}\}\n/,
+ )?.[0];
+ assert.ok(save, "savePresetWithName");
+ assert.match(save, /const live = useChatRuntimeStore\.getState\(\)\.params;/);
+ assert.match(save, /params: toPresetParams\(saved\),/);
+ assert.match(save, /setParams\(saved, \{ fromPreset: true \}\);/);
+ assert.doesNotMatch(save, /paramsWithCommittedSeed/);
+});
+
// Last: the open chat's pairing stays for the rest of the module.
// With a saved chat open the preset's sampling belongs to that chat, so the model's own stays.
test("a preset picked inside a chat leaves the model's remembered sampling alone", () => {