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: API page fonts, Sampling footer in chat settings (#15111)
Michael Han87a76055d776
diff --git a/studio/frontend/src/features/api-monitor/api-monitor-page.tsx b/studio/frontend/src/features/api-monitor/api-monitor-page.tsxindex df92be21bd4..60a79764841 100644--- a/studio/frontend/src/features/api-monitor/api-monitor-page.tsx+++ b/studio/frontend/src/features/api-monitor/api-monitor-page.tsx@@ -46,8 +46,8 @@ import {CodeIcon,ComputerTerminal01Icon,Copy01Icon,- CursorPointer02Icon,Delete02Icon,+ FileSearchIcon,FlashIcon,PauseIcon,PlayIcon,@@ -306,7 +306,7 @@ function Stat({<span className="truncate text-ui-12 text-muted-foreground">{label}</span><spanclassName={cn(- "truncate text-ui-21 font-semibold leading-tight tracking-[-0.02em] tabular-nums text-foreground",+ "truncate font-heading text-ui-21 font-semibold leading-tight tracking-[-0.02em] tabular-nums text-foreground",value === "–" && "text-muted-foreground/70",tone === "error" && "text-red-600 dark:text-red-400",tone === "active" && "text-blue-600 dark:text-blue-400",@@ -1597,7 +1597,7 @@ export function ApiMonitorPage(): ReactElement {aria-current={active ? "page" : undefined}onClick={() => setStatusFilter(option.value)}className={cn(- "flex h-9 shrink-0 items-center gap-1.5 rounded-full px-3.5 text-ui-14 text-foreground/80 transition-colors hover:text-foreground",+ "flex h-9 shrink-0 items-center gap-1.5 rounded-full px-3.5 font-heading text-ui-14 text-foreground/80 transition-colors hover:text-foreground",active &&"bg-white font-medium text-foreground shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] dark:bg-[rgb(255_255_255_/_calc(0.1*var(--contrast-wash-gain,1)))] dark:shadow-none",)}@@ -1791,14 +1791,14 @@ export function ApiMonitorPage(): ReactElement {)}><HugeiconsIcon- icon={CursorPointer02Icon}+ icon={FileSearchIcon}strokeWidth={1.75}className="size-5"/></span><p className="max-w-xs text-sm text-muted-foreground">- Select a request to inspect its prompt, reply, tokens and- errors. Use the arrow keys to step through the list.+ Select a request to see its details. Arrow keys move+ through the list.</p></div>)}diff --git a/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx b/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsxindex f748cb698b6..2514d5fa114 100644--- a/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx+++ b/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx@@ -474,7 +474,10 @@ export function ApiModelLoadControls({open={selectorOpen && !unloading}onOpenChange={setSelectorOpen}className="h-9 max-w-full rounded-full bg-background px-3.5 sm:max-w-[calc(28rem*var(--ui-space-scale,1))] dark:border-transparent dark:bg-[rgb(255_255_255_/_calc(0.06*var(--contrast-wash-gain,1)))] dark:hover:bg-[rgb(255_255_255_/_calc(0.1*var(--contrast-wash-gain,1)))] [&>span:last-child]:ml-1"- triggerLabelClassName="font-sans text-sm leading-none"+ triggerLabelClassName={cn(+ "text-sm leading-none",+ !activeModel && "font-sans",+ )}contentClassName="max-sm:max-w-[calc(100vw-3rem)]"/><ToolbarTooltip label={reloadTitle(lastLoadLabel, Boolean(activeModel))}>diff --git a/studio/frontend/src/features/chat/chat-settings-sheet.tsx b/studio/frontend/src/features/chat/chat-settings-sheet.tsxindex 3f9d7b9c90a..8f0504a5d7e 100644--- a/studio/frontend/src/features/chat/chat-settings-sheet.tsx+++ b/studio/frontend/src/features/chat/chat-settings-sheet.tsx@@ -2,6 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { Button } from "@/components/ui/button";+import { Checkbox } from "@/components/ui/checkbox";import {Dialog,DialogContent,@@ -126,6 +127,7 @@ import {useChatRuntimeStore,} from "./stores/chat-runtime-store";import {+ DEFAULT_INFERENCE_PARAMS,MAX_SAMPLING_SEED,modelReadsSamplingSeed,type InferenceParams,@@ -133,10 +135,9 @@ import {import { effectiveMinPMode, isMinPMode } from "./lib/min-p-policy";import { mlxSpecFallbackMessage } from "./lib/mlx-spec-fallback";+import { resolveQwenThinkingParams } from "./utils/qwen-sampling-table";-const SaveForModelButton = lazy(- () => import("./components/save-for-model-button"),-);+const SamplingFooter = lazy(() => import("./components/sampling-footer"));export { defaultInferenceParams, type Preset } from "./presets/preset-policy";export type { InferenceParams } from "./types/runtime";@@ -345,7 +346,8 @@ function CollapsibleSection({const headerClasses = cn("flex w-full items-center justify-between text-ui-12 font-medium normal-case tracking-[0.04em] text-nav-fg-muted transition-colors focus-visible:outline-none focus-visible:ring-0",- first ? "pt-4 pb-5" : "py-5",+ // pt-2 centers the first label on the sidebar's New chat row.+ first ? "pt-2 pb-5" : "py-5",);return (@@ -1491,7 +1493,8 @@ export function ChatSettingsPanel({<buttontype="button"onClick={openSystemPromptEditor}- className="nav-icon-btn text-nav-icon-idle hover:bg-panel-surface-hover hover:text-black dark:hover:text-white"+ // 28px target laid out at the chevron's 14px.+ className="nav-icon-btn -my-1.75 text-nav-icon-idle hover:bg-panel-surface-hover hover:text-black dark:hover:text-white"aria-label="Edit system prompt"><HugeiconsIcon@@ -1708,6 +1711,17 @@ export function ChatSettingsPanel({/></div>) : null}+ {!isExternalModel && currentCheckpoint ? (+ <Suspense fallback={null}>+ <SamplingFooter+ store={useChatRuntimeStore}+ notify={toast}+ Checkbox={Checkbox}+ defaults={DEFAULT_INFERENCE_PARAMS}+ qwenThinking={resolveQwenThinkingParams}+ />+ </Suspense>+ ) : null}</div></CollapsibleSection>@@ -1739,11 +1753,6 @@ export function ChatSettingsPanel({</CollapsibleSection>)}- {!isExternalModel && currentCheckpoint ? (- <Suspense fallback={null}>- <SaveForModelButton store={useChatRuntimeStore} notify={toast} />- </Suspense>- ) : null}</div></div></div>diff --git a/studio/frontend/src/features/chat/components/sampling-footer.tsx b/studio/frontend/src/features/chat/components/sampling-footer.tsxnew file mode 100644index 00000000000..948ce712c7d--- /dev/null+++ b/studio/frontend/src/features/chat/components/sampling-footer.tsx@@ -0,0 +1,242 @@+// 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 { Button } from "@/components/ui/button";+import type { Checkbox } from "@/components/ui/checkbox";+import { authFetch } from "@/features/auth";+import { readFastApiError } from "@/lib/format-fastapi-error";+import type { toast } from "@/lib/toast";+import { useEffect, useId, useState } from "react";+import {+ type SavedSampling,+ fromApiSampling,+ recommendedSampling,+ sameSampling,+ samplingPayload,+ samplingSaveStatus,+ 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 { resolveQwenThinkingParams } from "../utils/qwen-sampling-table";++// Passed in: importing them here splits shared modules out of the startup bundle.+type Deps = {+ store: typeof useChatRuntimeStore;+ notify: typeof toast;+ Checkbox: typeof Checkbox;+ defaults: InferenceParams;+ qwenThinking: typeof resolveQwenThinkingParams;+};++const DEFAULTS_URL = "/api/settings/model-sampling-defaults";++async function readSavedSampling(+ modelId: string,+ signal: AbortSignal,+): Promise<SavedSampling | null> {+ const query = new URLSearchParams();+ query.set("model_id", modelId);+ const res = await authFetch(`${DEFAULTS_URL}?${query}`, { signal });+ if (!res.ok) {+ throw new Error(+ await readFastApiError(res, "Failed to read saved sampling"),+ );+ }+ const body = (await res.json()) as {+ resolved?: Record<string, unknown> | null;+ };+ return fromApiSampling(body.resolved);+}++async function writeSavedSampling(+ modelId: string,+ /** null forgets the model. */+ sampling: SavedSampling | null,+): Promise<void> {+ const res = await authFetch(DEFAULTS_URL, {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ // biome-ignore lint/style/useNamingConvention: API schema+ model_id: modelId,+ sampling: toApiSampling(sampling),+ }),+ });+ if (!res.ok) {+ throw new Error(+ await readFastApiError(res, "Failed to save sampling for this model"),+ );+ }+}++export default function SamplingFooter({+ store,+ notify,+ Checkbox,+ defaults,+ qwenThinking,+}: Deps) {+ const params = store((state) => state.params);+ const modelId = params.checkpoint;+ const current = samplingPayload(params);+ const [saved, setSaved] = useState<SavedSampling | null>(null);+ const [remember, setRemember] = useState(false);+ const [busy, setBusy] = useState(false);+ const rememberId = useId();+ const statusId = useId();++ useEffect(() => {+ const controller = new AbortController();+ setSaved(null);+ setRemember(false);+ readSavedSampling(modelId, controller.signal)+ .then((value) => {+ setSaved(value);+ setRemember(value !== null);+ })+ .catch(() => undefined);+ return () => controller.abort();+ }, [modelId]);++ const run = (action: () => Promise<void>) => {+ setBusy(true);+ action()+ .catch((error: unknown) => {+ notify.error(error instanceof Error ? error.message : String(error));+ })+ .finally(() => setBusy(false));+ };++ // A reply that lands after a model switch belongs to the previous model.+ const stillOn = () => store.getState().params.checkpoint === modelId;++ const save = () =>+ run(async () => {+ const snapshot = store.getState().params;+ const sampling = samplingPayload(snapshot);+ await writeSavedSampling(modelId, sampling);+ if (stillOn()) {+ setSaved(sampling);+ }+ const remembered = {+ temperature: snapshot.temperature,+ topP: snapshot.topP,+ topK: snapshot.topK,+ minP: snapshot.minP,+ minPMode: snapshot.minPMode,+ repetitionPenalty: snapshot.repetitionPenalty,+ presencePenalty: snapshot.presencePenalty,+ };+ // Writing the memory also sets the live sliders: skip it if one moved during the save.+ const live = store.getState().params;+ if (+ live.checkpoint === modelId &&+ sameSampling(samplingPayload(live), sampling)+ ) {+ store.getState().setRememberedParamsForModel(modelId, remembered);+ }+ notify.success("Sampling saved for this model.");+ });++ const forget = () =>+ run(async () => {+ await writeSavedSampling(modelId, null);+ if (stillOn()) {+ setSaved(null);+ }+ notify.success("Saved sampling forgotten for this model.");+ });++ const reset = () =>+ run(async () => {+ const res = await authFetch(+ `/api/inference/status?${new URLSearchParams({ model: modelId })}`,+ );+ if (!res.ok) {+ throw new Error(+ await readFastApiError(+ res,+ "Failed to read the model's recommended sampling",+ ),+ );+ }+ const status = (await res.json()) as InferenceStatusResponse;+ if (!stillOn()) {+ return;+ }+ const state = store.getState();+ // Qwen3's recommendation depends on the thinking mode, layered on as the load paths do.+ const qwen = status.supports_reasoning+ ? qwenThinking(+ modelId,+ status.reasoning_always_on === true || state.reasoningEnabled,+ )+ : null;+ state.setParams({+ ...state.params,+ ...recommendedSampling(+ status.inference as Record<string, unknown> | undefined,+ defaults,+ ),+ ...qwen,+ });+ });++ const status = samplingSaveStatus(remember, saved, current);+ const unchanged = saved !== null && sameSampling(saved, current);++ return (+ <div className="flex flex-col gap-3.5 border-t border-[rgb(0_0_0_/_calc(0.13*var(--contrast-edge-gain,1)))] pt-4.75 dark:border-[rgb(255_255_255_/_calc(0.09*var(--contrast-edge-gain,1)))]">+ {/* Not inline: the sheet is too narrow. */}+ <div>+ <div className="flex min-w-0 items-center gap-2">+ <Checkbox+ id={rememberId}+ aria-describedby={statusId}+ checked={remember}+ onCheckedChange={(checked) => setRemember(checked === true)}+ />+ <label+ htmlFor={rememberId}+ className="cursor-pointer select-none truncate text-ui-13 text-foreground"+ >+ Remember for this model+ </label>+ </div>+ <p+ id={statusId}+ aria-live="polite"+ data-state={status === "Unsaved changes" ? "dirty" : undefined}+ className="pt-1 pl-6 text-ui-11 leading-snug text-muted-foreground empty:pt-0 data-[state=dirty]:text-amber-600 dark:data-[state=dirty]:text-amber-400"+ >+ {status}+ </p>+ </div>+ <div className="flex flex-wrap items-center gap-2">+ {(remember || saved !== null) && (+ <Button+ type="button"+ variant={remember ? "dark" : "outline"}+ size="sm"+ disabled={busy || (remember && unchanged)}+ onClick={remember ? save : forget}+ >+ {remember ? "Save settings" : "Forget settings"}+ </Button>+ )}+ <Button+ type="button"+ variant="outline"+ size="sm"+ className="text-muted-foreground"+ disabled={busy}+ onClick={reset}+ >+ Reset+ </Button>+ </div>+ </div>+ );+}diff --git a/studio/frontend/src/features/chat/components/save-for-model-button.tsx b/studio/frontend/src/features/chat/components/save-for-model-button.tsxdeleted file mode 100644index 8e826a710ed..00000000000--- a/studio/frontend/src/features/chat/components/save-for-model-button.tsx+++ /dev/null@@ -1,91 +0,0 @@-// 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 { Button } from "@/components/ui/button";-import { authFetch } from "@/features/auth";-import { readFastApiError } from "@/lib/format-fastapi-error";-import type { toast } from "@/lib/toast";-import type { useChatRuntimeStore } from "../stores/chat-runtime-store";--// Passed in, not imported: importing them here splits them out of the startup bundle into extra chunks.-type Deps = { store: typeof useChatRuntimeStore; notify: typeof toast };--/** Store the sampling on screen as the loaded model's defaults: new chats with it start from them, and API- * requests that leave a value out get them. Min P on the server's choice stays unsaved. */-async function saveSamplingForCurrentModel({- store,- notify,-}: Deps): Promise<void> {- const current = store.getState().params;- const modelId = current.checkpoint;- const res = await authFetch("/api/settings/model-sampling-defaults", {- method: "PUT",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({- // biome-ignore lint/style/useNamingConvention: API schema- model_id: modelId,- sampling: {- temperature: current.temperature,- // biome-ignore lint/style/useNamingConvention: API schema- top_p: current.topP,- // biome-ignore lint/style/useNamingConvention: API schema- top_k: current.topK,- // biome-ignore lint/style/useNamingConvention: API schema- repetition_penalty: current.repetitionPenalty,- // biome-ignore lint/style/useNamingConvention: API schema- presence_penalty: current.presencePenalty,- ...(current.minPMode === "custom"- ? // biome-ignore lint/style/useNamingConvention: API schema- { min_p: current.minP }- : {}),- },- }),- });- if (!res.ok) {- throw new Error(- await readFastApiError(res, "Failed to save sampling for this model"),- );- }- const sampling = {- temperature: current.temperature,- topP: current.topP,- topK: current.topK,- minP: current.minP,- minPMode: current.minPMode,- repetitionPenalty: current.repetitionPenalty,- presencePenalty: current.presencePenalty,- };- // Writing the memory also sets the live sliders: skip it if one moved during the save.- const live = store.getState().params;- if (- live.checkpoint === modelId &&- Object.entries(sampling).every(- ([key, value]) => live[key as keyof typeof sampling] === value,- )- ) {- store.getState().setRememberedParamsForModel(modelId, sampling);- }- notify.success("Sampling saved for this model.");-}--export default function SaveForModelButton(deps: Deps) {- return (- <div className="border-t border-[rgb(0_0_0_/_calc(0.13*var(--contrast-edge-gain,1)))] py-5 dark:border-[rgb(255_255_255_/_calc(0.09*var(--contrast-edge-gain,1)))]">- <Button- type="button"- variant="outline"- size="sm"- className="w-full"- onClick={() => {- saveSamplingForCurrentModel(deps).catch((error: unknown) => {- deps.notify.error(- error instanceof Error ? error.message : String(error),- );- });- }}- >- Save for this model- </Button>- </div>- );-}diff --git a/studio/frontend/src/features/chat/lib/sampling-memory.ts b/studio/frontend/src/features/chat/lib/sampling-memory.tsnew file mode 100644index 00000000000..430ba5e58cb--- /dev/null+++ b/studio/frontend/src/features/chat/lib/sampling-memory.ts@@ -0,0 +1,95 @@+// 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 type { InferenceParams } from "../types/runtime";++const API_FIELDS = {+ temperature: "temperature",+ topP: "top_p",+ topK: "top_k",+ minP: "min_p",+ repetitionPenalty: "repetition_penalty",+ presencePenalty: "presence_penalty",+} as const;++type SamplingField = keyof typeof API_FIELDS;++export type SavedSampling = Partial<Record<SamplingField, number>>;++type SamplingParams = Pick<InferenceParams, SamplingField | "minPMode">;++const FIELDS = Object.keys(API_FIELDS) as SamplingField[];++/** Min P on the server's choice stays unsaved. */+export function samplingPayload(params: SamplingParams): SavedSampling {+ const sampling: SavedSampling = {};+ for (const field of FIELDS) {+ if (field !== "minP" || params.minPMode === "custom") {+ sampling[field] = params[field];+ }+ }+ return sampling;+}++/** Null for every field forgets the model. */+export function toApiSampling(+ sampling: SavedSampling | null,+): Record<string, number | null> {+ const body: Record<string, number | null> = {};+ for (const field of FIELDS) {+ body[API_FIELDS[field]] = sampling?.[field] ?? null;+ }+ return body;+}++export function fromApiSampling(+ body: Record<string, unknown> | null | undefined,+): SavedSampling | null {+ const sampling: SavedSampling = {};+ for (const field of FIELDS) {+ const value = body?.[API_FIELDS[field]];+ if (typeof value === "number" && Number.isFinite(value)) {+ sampling[field] = value;+ }+ }+ return Object.keys(sampling).length > 0 ? sampling : null;+}++export function sameSampling(a: SavedSampling, b: SavedSampling): boolean {+ return FIELDS.every((field) => {+ const x = a[field];+ const y = b[field];+ return x === undefined || y === undefined+ ? x === y+ : Math.abs(x - y) <= 1e-9;+ });+}++export function samplingSaveStatus(+ remember: boolean,+ saved: SavedSampling | null,+ current: SavedSampling,+): string | null {+ if (remember) {+ return saved && sameSampling(saved, current)+ ? "Saved for this model"+ : "Unsaved changes";+ }+ return saved ? "Saved settings will be forgotten" : null;+}++export function recommendedSampling(+ inference: Record<string, unknown> | null | undefined,+ d: Pick<InferenceParams, SamplingField>,+): Pick<InferenceParams, SamplingField> {+ const recommended = fromApiSampling(inference) ?? {};+ return {+ temperature: recommended.temperature ?? d.temperature,+ topP: recommended.topP ?? d.topP,+ topK: recommended.topK ?? d.topK,+ minP: recommended.minP ?? d.minP,+ // Not part of a model's recommendation.+ repetitionPenalty: d.repetitionPenalty,+ presencePenalty: recommended.presencePenalty ?? d.presencePenalty,+ };+}diff --git a/studio/frontend/src/features/settings/components/api-example-parts.tsx b/studio/frontend/src/features/settings/components/api-example-parts.tsxindex 83e8bfb25ad..b6458aea03a 100644--- a/studio/frontend/src/features/settings/components/api-example-parts.tsx+++ b/studio/frontend/src/features/settings/components/api-example-parts.tsx@@ -41,6 +41,9 @@ const OS_OPTIONS: { id: ExampleOs; labelKey: TranslationKey }[] = [// The btn-fill grey (index.css), so a selected pill matches a standard filled button.const LIGHT_FILL_PILL ="[html:not(.dark)_&]:bg-[color-mix(in_srgb,var(--foreground)_calc(5%*var(--contrast-wash-gain,1)),transparent)] [html:not(.dark)_&]:shadow-none";+// Dark: the --accent pill nearly matches the example box's 5% white.+const DARK_FILL_PILL =+ "[html.dark_&]:!bg-[rgb(255_255_255_/_calc(0.12*var(--contrast-wash-gain,1)))]";// Lines that fit the example box's starting height (h-46); longer ones start there and scroll.const START_LINES = 8;@@ -151,7 +154,9 @@ export function ExampleToggle<T extends string>({group={pillId}// With no track behind them, the pills take a filled button's grey in light mode, not a// white lifted pill.- className={toggle ? undefined : LIGHT_FILL_PILL}+ className={+ toggle ? undefined : cn(LIGHT_FILL_PILL, DARK_FILL_PILL)+ }/>)}<span className="relative truncate">{option.label}</span>diff --git a/studio/frontend/tests/sampling-memory.test.ts b/studio/frontend/tests/sampling-memory.test.tsnew file mode 100644index 00000000000..83bcfdb9a4b--- /dev/null+++ b/studio/frontend/tests/sampling-memory.test.ts@@ -0,0 +1,161 @@+// 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 assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import test from "node:test";++import { registerBundlerResolver } from "./helpers/kit.ts";++registerBundlerResolver();+const {+ fromApiSampling,+ recommendedSampling,+ sameSampling,+ samplingPayload,+ samplingSaveStatus,+ toApiSampling,+} = await import("../src/features/chat/lib/sampling-memory.ts");+const { DEFAULT_INFERENCE_PARAMS } = await import(+ "../src/features/chat/types/runtime.ts"+);++const params = {+ temperature: 0.7,+ topP: 0.9,+ topK: 40,+ minP: 0.05,+ minPMode: "server-default" as const,+ repetitionPenalty: 1.1,+ presencePenalty: 0.2,+};++test("Save stores Min P only when it is set by hand", () => {+ assert.equal("minP" in samplingPayload(params), false);+ assert.equal(samplingPayload({ ...params, minPMode: "custom" }).minP, 0.05);+});++test("the request uses the API's names and forgets with nulls", () => {+ assert.deepEqual(toApiSampling(samplingPayload(params)), {+ temperature: 0.7,+ top_p: 0.9,+ top_k: 40,+ min_p: null,+ repetition_penalty: 1.1,+ presence_penalty: 0.2,+ });+ assert.ok(Object.values(toApiSampling(null)).every((v) => v === null));+ assert.equal(fromApiSampling({}), null);+ assert.deepEqual(fromApiSampling({ top_p: 0.8, junk: 1 }), { topP: 0.8 });+});++test("the status line follows Remember and whether the values are saved", () => {+ const current = samplingPayload(params);+ assert.equal(samplingSaveStatus(false, null, current), null);+ assert.equal(samplingSaveStatus(true, null, current), "Unsaved changes");+ assert.equal(+ samplingSaveStatus(true, { ...current }, current),+ "Saved for this model",+ );+ assert.equal(+ samplingSaveStatus(true, { ...current, temperature: 1 }, current),+ "Unsaved changes",+ );+ assert.equal(+ samplingSaveStatus(false, current, current),+ "Saved settings will be forgotten",+ );+ assert.equal(sameSampling({ topK: 40 }, { topK: 40, minP: 0.1 }), false);+});++test("Reset takes the model's recommendation, app defaults for the rest", () => {+ assert.deepEqual(+ recommendedSampling(+ { temperature: 1, top_p: 0.95 },+ DEFAULT_INFERENCE_PARAMS,+ ),+ {+ temperature: 1,+ topP: 0.95,+ topK: DEFAULT_INFERENCE_PARAMS.topK,+ minP: DEFAULT_INFERENCE_PARAMS.minP,+ repetitionPenalty: DEFAULT_INFERENCE_PARAMS.repetitionPenalty,+ presencePenalty: DEFAULT_INFERENCE_PARAMS.presencePenalty,+ },+ );+});++test("the Sampling section ends with the footer, not a lone Save button", () => {+ const sheet = readFileSync(+ new URL("../src/features/chat/chat-settings-sheet.tsx", import.meta.url),+ "utf8",+ );+ const sampling = sheet.slice(+ sheet.indexOf('<CollapsibleSection label="Sampling"'),+ sheet.indexOf('<CollapsibleSection label="Tools"'),+ );+ assert.match(+ sampling,+ /<SamplingFooter\s+store=\{useChatRuntimeStore\}\s+notify=\{toast\}\s+Checkbox=\{Checkbox\}\s+defaults=\{DEFAULT_INFERENCE_PARAMS\}\s+qwenThinking=\{resolveQwenThinkingParams\}\s+\/>/,+ );+ assert.doesNotMatch(sheet, /SaveForModelButton|Save for this model/);+});++test("a save or forget that finishes after a model switch leaves the new model's state alone", () => {+ const footer = readFileSync(+ new URL(+ "../src/features/chat/components/sampling-footer.tsx",+ import.meta.url,+ ),+ "utf8",+ );+ assert.match(+ footer,+ /const stillOn = \(\) => store\.getState\(\)\.params\.checkpoint === modelId;/,+ );+ assert.match(+ footer,+ /await writeSavedSampling\(modelId, sampling\);\s*if \(stillOn\(\)\) \{\s*setSaved\(sampling\);/,+ );+ assert.match(+ footer,+ /await writeSavedSampling\(modelId, null\);\s*if \(stillOn\(\)\) \{\s*setSaved\(null\);/,+ );+});++test("Reset layers Qwen3's thinking-mode table over the base recommendation", async () => {+ const { resolveQwenThinkingParams } = await import(+ "../src/features/chat/utils/qwen-sampling-table.ts"+ );+ assert.deepEqual(+ {+ ...recommendedSampling(+ { temperature: 0.6, top_p: 0.95 },+ DEFAULT_INFERENCE_PARAMS,+ ),+ ...resolveQwenThinkingParams("unsloth/Qwen3-8B-GGUF", false),+ },+ {+ ...recommendedSampling({}, DEFAULT_INFERENCE_PARAMS),+ temperature: 0.7,+ topP: 0.8,+ topK: 20,+ minP: 0,+ },+ );+ const footer = readFileSync(+ new URL(+ "../src/features/chat/components/sampling-footer.tsx",+ import.meta.url,+ ),+ "utf8",+ );+ assert.match(+ footer,+ /const qwen = status\.supports_reasoning\s*\?\s*qwenThinking\(\s*modelId,\s*status\.reasoning_always_on === true \|\| state\.reasoningEnabled,?\s*\)\s*:\s*null;/,+ );+ assert.match(+ footer,+ /\.\.\.recommendedSampling\([\s\S]*?\),\s*\.\.\.qwen,\s*\}\);/,+ );+});