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: Sampling footer waits for the saved-sampling read before Remember and Save (#15177)

Michael Han984d6e5ed657
diff --git a/studio/frontend/src/features/chat/components/sampling-footer.tsx b/studio/frontend/src/features/chat/components/sampling-footer.tsx
index 948ce712c7d..48ce902aaaf 100644
--- a/studio/frontend/src/features/chat/components/sampling-footer.tsx
+++ b/studio/frontend/src/features/chat/components/sampling-footer.tsx
@@ -17,8 +17,8 @@ import {
toApiSampling,
} from "../lib/sampling-memory";
import type { useChatRuntimeStore } from "../stores/chat-runtime-store";
-import type { InferenceParams } from "../types/runtime";
import type { InferenceStatusResponse } from "../types/api";
+import type { InferenceParams } from "../types/runtime";
import type { resolveQwenThinkingParams } from "../utils/qwen-sampling-table";
// Passed in: importing them here splits shared modules out of the startup bundle.
@@ -84,6 +84,8 @@ export default function SamplingFooter({
const [saved, setSaved] = useState<SavedSampling | null>(null);
const [remember, setRemember] = useState(false);
const [busy, setBusy] = useState(false);
+ // Until the first read lands, an edit or save would be overwritten by its older result.
+ const [loaded, setLoaded] = useState(false);
const rememberId = useId();
const statusId = useId();
@@ -91,12 +93,18 @@ export default function SamplingFooter({
const controller = new AbortController();
setSaved(null);
setRemember(false);
+ setLoaded(false);
readSavedSampling(modelId, controller.signal)
.then((value) => {
setSaved(value);
setRemember(value !== null);
})
- .catch(() => undefined);
+ .catch(() => undefined)
+ .finally(() => {
+ if (!controller.signal.aborted) {
+ setLoaded(true);
+ }
+ });
return () => controller.abort();
}, [modelId]);
@@ -196,6 +204,7 @@ export default function SamplingFooter({
id={rememberId}
aria-describedby={statusId}
checked={remember}
+ disabled={!loaded}
onCheckedChange={(checked) => setRemember(checked === true)}
/>
<label
@@ -220,7 +229,7 @@ export default function SamplingFooter({
type="button"
variant={remember ? "dark" : "outline"}
size="sm"
- disabled={busy || (remember && unchanged)}
+ disabled={!loaded || busy || (remember && unchanged)}
onClick={remember ? save : forget}
>
{remember ? "Save settings" : "Forget settings"}
diff --git a/studio/frontend/tests/sampling-memory.test.ts b/studio/frontend/tests/sampling-memory.test.ts
index 83bcfdb9a4b..72599e779e3 100644
--- a/studio/frontend/tests/sampling-memory.test.ts
+++ b/studio/frontend/tests/sampling-memory.test.ts
@@ -159,3 +159,26 @@ test("Reset layers Qwen3's thinking-mode table over the base recommendation", as
/\.\.\.recommendedSampling\([\s\S]*?\),\s*\.\.\.qwen,\s*\}\);/,
);
});
+
+test("Remember and Save wait for the first read, so its older result cannot overwrite them", () => {
+ const footer = readFileSync(
+ new URL(
+ "../src/features/chat/components/sampling-footer.tsx",
+ import.meta.url,
+ ),
+ "utf8",
+ );
+ assert.match(
+ footer,
+ /setLoaded\(false\);\s*readSavedSampling\(modelId, controller\.signal\)/,
+ );
+ assert.match(
+ footer,
+ /\.finally\(\(\) => \{\s*if \(!controller\.signal\.aborted\) \{\s*setLoaded\(true\);/,
+ );
+ assert.match(footer, /checked=\{remember\}\s*disabled=\{!loaded\}/);
+ assert.match(
+ footer,
+ /disabled=\{!loaded \|\| busy \|\| \(remember && unchanged\)\}/,
+ );
+});