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: one run settings dropdown per model, and the last setting used is what loads (#15247)
Michael Hanc9ddc5ab5e3a
diff --git a/studio/frontend/scripts/check-bundle-budget.ts b/studio/frontend/scripts/check-bundle-budget.tsindex 5ec280cc237..47f091e5178 100644--- a/studio/frontend/scripts/check-bundle-budget.ts+++ b/studio/frontend/scripts/check-bundle-budget.ts@@ -433,8 +433,11 @@ export const BUDGET = {// The control heights and API page round (#15232) adds 2,639 B raw / 717 B transfer, mostly its token table,// regenerate and tooltip strings in the eager locales (6,945,181 -> 6,947,820 B raw, 2,095,616 -> 2,096,333 B// transfer against 6eeb690f8d, one machine and build, 105 chunks). Raised by that growth.- transferBytes: 2_097_044,- rawBytes: 6_961_352,+ // The run settings dropdown per model (#15247: saved settings store, dropdown, pencil and Reset to Default)+ // adds 9.9 KB raw / 3.2 KB transfer inside the eager model config page: 6,787.4 -> 6,797.3 KB raw, 2,047.9 ->+ // 2,051.1 KB transfer against d4be247222, one machine and build, Node 26, 105 chunks. Raised by that growth.+ transferBytes: 2_100_321,+ rawBytes: 6_971_490,};// The chunk count is reported but not budgeted. Splitting a page out of the entry raises it while lowering thediff --git a/studio/frontend/src/features/chat/components/sampling-footer.tsx b/studio/frontend/src/features/chat/components/sampling-footer.tsxindex 48ce902aaaf..cde43e850e1 100644--- a/studio/frontend/src/features/chat/components/sampling-footer.tsx+++ b/studio/frontend/src/features/chat/components/sampling-footer.tsx@@ -224,12 +224,12 @@ export default function SamplingFooter({</p></div><div className="flex flex-wrap items-center gap-2">- {(remember || saved !== null) && (+ {(remember ? !unchanged : saved !== null) && (<Buttontype="button"variant={remember ? "dark" : "outline"}size="sm"- disabled={!loaded || busy || (remember && unchanged)}+ disabled={!loaded || busy}onClick={remember ? save : forget}>{remember ? "Save settings" : "Forget settings"}diff --git a/studio/frontend/src/features/model-picker/components/model-config-page.tsx b/studio/frontend/src/features/model-picker/components/model-config-page.tsxindex 917da93f507..5b030b5158a 100644--- a/studio/frontend/src/features/model-picker/components/model-config-page.tsx+++ b/studio/frontend/src/features/model-picker/components/model-config-page.tsx@@ -3,6 +3,23 @@import { HugeiconsIcon } from "@hugeicons/react";import { InferenceEnginePicker } from "./inference-engines";+import { modelDisplayName } from "../model-config/model-identity";+import { type RunSettingsNaming, RunSettingsPicker } from "./saved-run-settings-row";+import {+ adoptRememberedRunSettings,+ deleteSavedRunSettings,+ findSavedRunSettings,+ hasLegacyRunSettings,+ newRunSettingsName,+ normalizeSavedRunSettingsName,+ quantsSelectingRunSettings,+ renameLegacyRunSettings,+ renameSavedRunSettings,+ saveRunSettings,+ setSelectedRunSettings,+ useSavedRunSettings,+ useSelectedRunSettings,+} from "../model-config/saved-run-settings";import {AlertDialog,AlertDialogAction,@@ -16,7 +33,6 @@ import {import { useLlamaCppBackend } from "@/hooks/use-llama-backend";import { useSliderDraft } from "@/hooks/use-slider-draft";import { Button } from "@/components/ui/button";-import { Checkbox } from "@/components/ui/checkbox";import { InfoHint } from "@/components/ui/info-hint";import {Select,@@ -2548,7 +2564,6 @@ export function ModelConfigPage({showHeader = true,focusField,}: ModelConfigPageProps) {- const rememberId = useId();const saveStatusId = useId();const platformDeviceType = usePlatformStore((s) => s.deviceType);// Apple Silicon specifically, and used ONLY for wording: "Unified" is what Apple calls its@@ -3658,16 +3673,58 @@ export function ModelConfigPage({normalizePerModelConfig(storedSpeculativeAuto(runtimeConfig, targetIsMlx)),storedRecord.config,);+ const modelName = modelDisplayName(configId);+ const savedSets = useSavedRunSettings(configId);+ const persistedSet = useSelectedRunSettings(configId, target.ggufVariant);+ // undefined: follow what is stored.+ const [pickedSet, setPickedSet] = useState<string | null | undefined>(undefined);+ const [naming, setNaming] = useState<RunSettingsNaming | null>(null);+ useEffect(() => {+ if (storedRecord.remembered && persistedSet === undefined) {+ adoptRememberedRunSettings(configId, target.ggufVariant, storedRecord.config, modelName);+ }+ }, [storedRecord, persistedSet, configId, target.ggufVariant, modelName]);+ useEffect(() => {+ if (hasLegacyRunSettings(savedSets, modelName)) {+ renameLegacyRunSettings(configId, modelName);+ }+ }, [savedSets, configId, modelName]);+ const wantedSet = pickedSet !== undefined ? pickedSet : (persistedSet ?? null);+ const selectedEntry =+ wantedSet === null ? null : findSavedRunSettings(savedSets, wantedSet);+ const selectedSet = selectedEntry?.name ?? null;+ const forSetStore = (next: PerModelConfig) =>+ normalizePerModelConfig(storedSpeculativeAuto(next, targetIsMlx));+ const setUnsaved =+ selectedEntry !== null &&+ (!perModelConfigsEqual(forSetStore(runtimeConfig), forSetStore(selectedEntry.config)) ||+ (persistedSet ?? null) !== selectedSet ||+ (!matchesStored && !atDefault));+ // Arguments a load would refuse, or not read yet: saving them would store what cannot load.+ const extraArgsBlocked =+ (!extraArgsLoadable && !sharedExtraArgsCleared) ||+ sharedExtraArgsRefused ||+ extraArgsHydrating;+ // Editing Default turns it into a new set, saved under this name on Save or Load.+ const customName =+ selectedSet === null && !atDefault ? newRunSettingsName(savedSets, modelName) : null;+ const canSave = naming+ ? normalizeSavedRunSettingsName(naming.name) !== ""+ : selectedSet === null+ ? !atDefault || savedRemember+ : setUnsaved;// Always mounted: a status appearing on save would move Load.- const saveStatus = savedRemember- ? remember- ? matchesStored- ? "Saved for this model"- : "Unsaved changes"- : "Saved settings will be forgotten"- : !remember && atDefault- ? "Using default settings"- : "";+ const saveStatus = naming+ ? ""+ : selectedSet === null+ ? savedRemember+ ? "Saved settings will be forgotten"+ : atDefault+ ? "Using the default settings"+ : "Unsaved changes"+ : setUnsaved+ ? "Unsaved changes"+ : "Saved for this model";const persistenceOnly = isActiveModel && atBaseline && rememberChanged;const primaryActionLabel = persistenceOnly? remember@@ -3756,13 +3813,13 @@ export function ModelConfigPage({return { effectiveConfig, effectiveRuntimeConfig, effectiveMaxSeqLengthValue };};- const persistConfig = (next: PerModelConfig) => {+ const persistConfig = (next: PerModelConfig, keep = selectedSet !== null) => {// Judge what storage keeps: savePerModelConfig normalizes first, so the raw object over-reports.const normalized = normalizePerModelConfig(storedSpeculativeAuto(next, targetIsMlx));const evicted: { modelId: string; ggufVariant: string | null }[] = [];- // Only a Remember that was on can be forgotten: an unticked seeded/failed-read box deleted unseen rows.- const forgets = !remember && savedRemember;- const saved = remember+ // Only remembered settings can be forgotten: a seeded or failed read must not delete unseen rows.+ const forgets = !keep && savedRemember;+ const saved = keep? savePerModelConfig(configId, target.ggufVariant, normalized, evicted): forgets? deletePerModelConfig(configId, target.ggufVariant)@@ -3774,15 +3831,15 @@ export function ModelConfigPage({// A forget also drops the local records for every other spelling the server reports clearing.if (saved &&- (remember || forgets) &&+ (keep || forgets) &&(target.apiLoadable ?? target.isGguf) &&!nativePathToken) {syncModelOverride(configId,target.ggufVariant,- remember ? normalized : null,- remember+ keep ? normalized : null,+ keep? {resetReasoningBudget:baseline.reasoningBudget !== -1 &&@@ -3809,34 +3866,98 @@ export function ModelConfigPage({return { saved, defaultConfig: isDefaultConfig(normalized) };};- const finishPersist = (defaultConfig: boolean) => {- const nextRemember = remember && !defaultConfig;+ const finishPersist = (+ defaultConfig: boolean,+ keep = selectedSet !== null,+ message?: string,+ ) => {+ const nextRemember = keep && !defaultConfig;setSavedRemember(nextRemember);setRemember(nextRemember);toast.success(- nextRemember- ? "Settings saved."- : remember- ? "Default settings kept."- : "Settings forgotten.",+ message ??+ (nextRemember+ ? "Settings saved."+ : keep+ ? "Default settings kept."+ : "Settings forgotten."),);};- const handleSave = () => {+ const keepSelection = (into: string | null) => {+ setSelectedRunSettings(configId, target.ggufVariant, into);+ setPickedSet(undefined);+ };++ // Each quant loads from its own record and override, so the others sharing a set follow its saves+ // and deletes, or a Load there writes their stale values back over it.+ const syncOtherQuants = (quants: readonly string[], stored: PerModelConfig | null) => {+ const own = (target.ggufVariant ?? "").trim().toLowerCase();+ const mirrors = (target.apiLoadable ?? target.isGguf) && !nativePathToken;+ const evicted: { modelId: string; ggufVariant: string | null }[] = [];+ for (const quant of quants) {+ if (quant.toLowerCase() === own) {+ continue;+ }+ const variant = quant || null;+ const saved = stored+ ? savePerModelConfig(configId, variant, stored, evicted)+ : deletePerModelConfig(configId, variant);+ if (saved && mirrors) {+ syncModelOverride(configId, variant, stored);+ }+ }+ // As persistConfig: a model dropped to fit the budget must not keep applying from the server.+ for (const dropped of evicted) {+ syncModelOverride(dropped.modelId, dropped.ggufVariant, null, {+ keepLaunchFlags: true,+ });+ }+ };+ const saveSharedSet = (name: string, committed: PerModelConfig): boolean => {+ const stored = forSetStore(committed);+ if (!saveRunSettings(configId, name, stored)) {+ return false;+ }+ syncOtherQuants(quantsSelectingRunSettings(configId, name), stored);+ return true;+ };++ // From the committed config: a number blurred by this very click is not in customName yet.+ const committedCustomName = (committed: PerModelConfig) =>+ isDefaultConfig(forSetStore(committed)) ? null : newRunSettingsName(savedSets, modelName);++ /** Saves without loading; ``into`` null saves an edited Default as its custom set, else forgets. */+ const handleSave = (into: string | null = selectedSet, message?: string): boolean => {if (sharedVariantUnresolved) {- return;+ return false;+ }+ // As the Save button: the name box's Save and Enter must not persist before these settle.+ if (stagedMetadataPending || budgetSettling) {+ return false;}const { effectiveRuntimeConfig } = commitDraft();- const { saved, defaultConfig } = persistConfig(effectiveRuntimeConfig);+ const target = into ?? committedCustomName(effectiveRuntimeConfig);+ const keep = target !== null;+ if (keep && extraArgsBlocked) {+ toast.error("Fix the extra arguments before saving.");+ return false;+ }+ if (keep && !saveSharedSet(target, effectiveRuntimeConfig)) {+ toast.error("Couldn't save these settings.");+ return false;+ }+ const { saved, defaultConfig } = persistConfig(effectiveRuntimeConfig, keep);if (!saved) {toast.error("Couldn't save settings for this model.");- return;+ return false;}+ keepSelection(target);// The page stays mounted, so show a context pinFixedLayerContext stored (else it reads "Auto").// Not on a forget: that stored nothing, and pinning here would change the next load.// setConfig, not update: this mirrors what was just saved, so the draft must stay unedited.if (- remember &&+ keep &&effectiveRuntimeConfig.customContextLength !== config.customContextLength) {setConfig((current) => ({@@ -3844,7 +3965,106 @@ export function ModelConfigPage({customContextLength: effectiveRuntimeConfig.customContextLength,}));}- finishPersist(defaultConfig);+ finishPersist(defaultConfig, keep, message ?? (keep ? `Saved "${target}".` : undefined));+ return true;+ };++ const applyToPanel = (next: PerModelConfig) => {+ // As Reset: an edit that drops the raw arguments text.+ handleSharedConfigEdit();+ markModelConfigDraftEdited(draftKey);+ clearExtraArgsEditForDraft(draftKey);+ const applied: PerModelConfig = {+ ...DEFAULT_PER_MODEL_CONFIG,+ ...next,+ // null, not absent: absent makes a reload inherit the running process's arguments.+ llamaExtraArgs: next.llamaExtraArgs ?? null,+ };+ setConfig(applied);+ // Stored tokens replace the text an objection was about; the collapsed check only ever tightens.+ setExtraArgsLoadable(true);+ return applied;+ };++ // The model loads with whatever was picked last: picking takes effect without a Save.+ const pickSet = (name: string | null) => {+ // A load settling its budget already captured its config; a pick now would disagree with it.+ if (budgetSettling) {+ return;+ }+ setNaming(null);+ const entry = name === null ? null : findSavedRunSettings(savedSets, name);+ const next = entry?.config ?? DEFAULT_PER_MODEL_CONFIG;+ // What the panel shows, explicit argument clear included: an omitted field keeps the server's old flags.+ const { saved, defaultConfig } = persistConfig(applyToPanel(next), entry !== null);+ if (!saved) {+ setPickedSet(entry?.name ?? null);+ toast.error("Couldn't save settings for this model.");+ return;+ }+ keepSelection(entry?.name ?? null);+ setSavedRemember(entry !== null && !defaultConfig);+ setRemember(entry !== null && !defaultConfig);+ };++ const deleteSet = (name: string) => {+ const wasSelected = name === selectedSet;+ const otherQuants = quantsSelectingRunSettings(configId, name);+ if (!deleteSavedRunSettings(configId, name)) {+ toast.error("Couldn't delete these settings.");+ return;+ }+ syncOtherQuants(otherQuants, null);+ if (wasSelected) {+ pickSet(null);+ }+ toast.success(`Deleted "${name}".`);+ };++ // Renames the selected set; an edited Default not saved yet gets named before it is created.+ const editName =+ selectedSet !== null+ ? () => setNaming({ mode: "rename", name: selectedSet, target: selectedSet })+ : customName !== null+ ? () => setNaming({ mode: "new", name: customName })+ : null;++ const submitNaming = () => {+ if (!naming) {+ return;+ }+ const name = normalizeSavedRunSettingsName(naming.name);+ if (!name) {+ return;+ }+ if (naming.mode === "rename") {+ if (name !== naming.target && !renameSavedRunSettings(configId, naming.target, name)) {+ toast.error("Another saved setting already has that name.");+ return;+ }+ if (pickedSet === naming.target) {+ setPickedSet(name);+ }+ setNaming(null);+ return;+ }+ if (findSavedRunSettings(savedSets, name)) {+ toast.error("Another saved setting already has that name.");+ return;+ }+ if (handleSave(name)) {+ setNaming(null);+ }+ };++ const onSaveClick = () => {+ if (naming) {+ submitNaming();+ } else if (selectedSet !== null) {+ handleSave(selectedSet);+ } else {+ handleSave(customName);+ }};const handleRun = () => {@@ -3863,13 +4083,25 @@ export function ModelConfigPage({followGlobal: true,}) &&rememberChanged;- const { saved, defaultConfig } = persistConfig(effectiveRuntimeConfig);+ // Load saves into the set too (an edited Default becomes one), so the two never drift apart.+ let loadSet = selectedSet ?? committedCustomName(effectiveRuntimeConfig);+ if (loadSet !== null && !saveSharedSet(loadSet, effectiveRuntimeConfig)) {+ toast.error("Couldn't save these settings, loading with them anyway.");+ // Never select a set that was not created.+ if (loadSet !== selectedSet) {+ loadSet = null;+ }+ }+ const { saved, defaultConfig } = persistConfig(effectiveRuntimeConfig, loadSet !== null);+ if (saved) {+ keepSelection(loadSet);+ }if (effectivePersistenceOnly) {if (!saved) {toast.error("Couldn't save settings for this model.");return;}- finishPersist(defaultConfig);+ finishPersist(defaultConfig, loadSet !== null);return;}if (!saved) {@@ -4157,36 +4389,36 @@ export function ModelConfigPage({"sticky -bottom-4.5 z-10 -mb-4.5 -ml-7 -mr-[calc(var(--spacing)*5+min(var(--overlay-scrollbar-gutter,0px),var(--spacing)*2))] bg-popover pb-4.5 pl-7 pr-[calc(var(--spacing)*5+min(var(--overlay-scrollbar-gutter,0px),var(--spacing)*2))] dark:bg-sidebar",)}>- {/* pt-3.25: Remember's cap top 18px under the rule, as under the buttons. */}- <div className="flex flex-col gap-3.5 border-t border-border pt-3.25">- <div className="flex min-w-0 items-center gap-2">- <Checkbox- id={rememberId}- aria-describedby={saveStatusId}- checked={remember}- onCheckedChange={(checked) => {- // Not in setRemember, which the save path calls again to settle the box. An- // unticked Remember is a pending Forget the next read would otherwise re-tick.- markModelConfigDraftEdited(draftKey);- setRemember(checked === true);- }}- />- <label- htmlFor={rememberId}- className="cursor-pointer select-none truncate text-ui-13 text-foreground"- >- Remember for this model- </label>- {/* On this row so a status change never moves the buttons. */}- <p- id={saveStatusId}- aria-live="polite"- data-state={saveStatus === "Unsaved changes" ? "dirty" : undefined}- className="ml-auto min-w-0 truncate text-ui-11 leading-snug text-muted-foreground data-[state=dirty]:text-amber-600 dark:data-[state=dirty]:text-amber-400"- >- {saveStatus}- </p>- </div>+ {/* pt-4.25 plus the 1px rule: 18px above the picker, as below the buttons. */}+ <div className="flex flex-col gap-3.5 border-t border-border pt-4.25">+ <RunSettingsPicker+ modelName={modelName}+ sets={savedSets}+ selected={selectedSet}+ customName={naming ? null : customName}+ onEditName={editName}+ compact={variant === "sidebar"}+ naming={naming}+ // Until the server copy is read: a pick before then could not forget a row it has not seen.+ disabled={sharedVariantUnresolved || extraArgsHydrating || budgetSettling}+ onPick={pickSet}+ onNamingChange={setNaming}+ onNamingSubmit={submitNaming}+ onDelete={deleteSet}+ />+ <p+ id={saveStatusId}+ aria-live="polite"+ data-state={saveStatus === "Unsaved changes" ? "dirty" : undefined}+ // min-h keeps the empty line's height, so the buttons never move. Not while naming in the+ // sidebar: the name box's own button row already moved them, and the blank line only adds a gap.+ className={cn(+ "-mt-2 -mb-1.5 min-h-[calc(1.375em+0.25rem)] min-w-0 truncate pl-3.5 text-ui-11 leading-snug text-muted-foreground data-[state=dirty]:text-amber-600 dark:data-[state=dirty]:text-amber-400",+ naming && variant === "sidebar" && "hidden",+ )}+ >+ {saveStatus}+ </p><div className="flex flex-wrap items-center gap-2">{/* Primary action first, like the Preset row's Save/Delete. */}<Button@@ -4210,27 +4442,24 @@ export function ModelConfigPage({>{primaryActionLabel}</Button>- {/* Hidden with nothing to save or forget, else never-remembered models show a dead Forget. */}- {!persistenceOnly && (remember || savedRemember) && (+ {/* Saves without loading; an edited Default becomes its custom setting. */}+ {!persistenceOnly && (<Buttontype="button"variant="outline"size="sm"// Same gates as Load: an unclassified model or an in-flight budget PUT would persist- // settings the load path strips or has already captured. Forget stores nothing, so- // broken saved arguments must not lock it.+ // settings the load path strips or has already captured.disabled={sharedVariantUnresolved ||+ !canSave ||stagedMetadataPending ||budgetSettling ||- (remember &&- ((!extraArgsLoadable && !sharedExtraArgsCleared) ||- sharedExtraArgsRefused ||- extraArgsHydrating))+ ((selectedSet !== null || customName !== null) && extraArgsBlocked)}- onClick={handleSave}+ onClick={onSaveClick}>- {remember ? "Save settings" : "Forget settings"}+ Save</Button>)}<Button@@ -4238,21 +4467,8 @@ export function ModelConfigPage({variant="outline"size="sm"className="text-muted-foreground"- disabled={atDefault}- onClick={() => {- handleSharedConfigEdit();- // Reset writes through setConfig, not update, so it marks the draft itself.- markModelConfigDraftEdited(draftKey);- // And drops the raw edit: token equality alone would make the discarded text- // current again the moment a later value formatted to the same tokens.- clearExtraArgsEditForDraft(draftKey);- setConfig({- // null, not the default's absent: absent omits the field, and the load then INHERITS the- // running process's arguments, so a reload after Reset kept the flags the box says are gone.- ...DEFAULT_PER_MODEL_CONFIG,- llamaExtraArgs: null,- });- }}+ disabled={(atDefault && selectedSet === null) || extraArgsHydrating || budgetSettling}+ onClick={() => pickSet(null)}>Reset</Button>diff --git a/studio/frontend/src/features/model-picker/components/saved-run-settings-row.tsx b/studio/frontend/src/features/model-picker/components/saved-run-settings-row.tsxnew file mode 100644index 00000000000..8a203f03679--- /dev/null+++ b/studio/frontend/src/features/model-picker/components/saved-run-settings-row.tsx@@ -0,0 +1,259 @@+// 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 {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";+import { Input } from "@/components/ui/input";+import { ChevronDownStandardIcon } from "@/lib/chevron-icons";+import { cn } from "@/lib/utils";+import {+ Delete02Icon,+ Edit03Icon,+ Tick02Icon,+} from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import type { MouseEvent, PointerEvent } from "react";+import {+ SAVED_RUN_SETTINGS_NAME_MAX,+ type SavedRunSettings,+ normalizeSavedRunSettingsName,+} from "../model-config/saved-run-settings";++/** ``target`` is the set being renamed. */+export type RunSettingsNaming =+ | { mode: "new"; name: string }+ | { mode: "rename"; name: string; target: string };++interface RunSettingsPickerProps {+ modelName: string;+ sets: readonly SavedRunSettings[];+ /** The set the model loads with, or null for the default (recommended) settings. */+ selected: string | null;+ /** Default with edits: the name they will be saved under. */+ customName: string | null;+ /** Null on Default settings, which cannot be renamed. */+ onEditName: (() => void) | null;+ /** The narrow sidebar: a smaller pencil, and the name box's buttons below it. */+ compact?: boolean;+ naming: RunSettingsNaming | null;+ disabled?: boolean;+ onPick: (name: string | null) => void;+ onNamingChange: (naming: RunSettingsNaming | null) => void;+ onNamingSubmit: () => void;+ onDelete: (name: string) => void;+}++const ITEM = "flex min-h-9 items-center gap-2 px-3 py-0 text-ui-13 font-medium";+// The default bg-border/50 vanishes on the dark menu surface.+const SEPARATOR =+ "mx-3 bg-[rgb(0_0_0_/_calc(0.1*var(--contrast-wash-gain,1)))] dark:bg-[rgb(255_255_255_/_calc(0.16*var(--contrast-wash-gain,1)))]";+const SECTION = "pb-1 pt-2 text-ui-11 font-medium";+const ROW_ICON =+ "flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[rgb(0_0_0_/_calc(0.06*var(--contrast-wash-gain,1)))] dark:hover:bg-[rgb(255_255_255_/_calc(0.1*var(--contrast-wash-gain,1)))]";++function Check({ on }: { on: boolean }) {+ return (+ <HugeiconsIcon+ icon={Tick02Icon}+ strokeWidth={2}+ className={cn("size-3.5 shrink-0", !on && "invisible")}+ />+ );+}++// Clicking an icon must not also pick its row: Radix selects on pointerup when it missed the pointerdown.+const keepRow = (event: MouseEvent | PointerEvent) => {+ event.preventDefault();+ event.stopPropagation();+};++export function RunSettingsPicker({+ modelName,+ sets,+ selected,+ customName,+ onEditName,+ compact = false,+ naming,+ disabled = false,+ onPick,+ onNamingChange,+ onNamingSubmit,+ onDelete,+}: RunSettingsPickerProps) {+ if (naming) {+ return (+ // The sidebar is too narrow for a readable name beside the buttons, so they go below it.+ <div+ className={cn(+ "flex min-w-0 gap-2",+ compact ? "flex-col" : "items-center",+ )}+ >+ <Input+ autoFocus={true}+ value={naming.name}+ onFocus={(event) => event.currentTarget.select()}+ onChange={(event) =>+ onNamingChange({ ...naming, name: event.target.value })+ }+ onKeyDown={(event) => {+ if (event.key === "Enter") {+ event.preventDefault();+ onNamingSubmit();+ } else if (event.key === "Escape") {+ event.preventDefault();+ event.stopPropagation();+ onNamingChange(null);+ }+ }}+ maxLength={SAVED_RUN_SETTINGS_NAME_MAX}+ autoComplete="off"+ aria-label={+ naming.mode === "new"+ ? "Name for the new settings"+ : `New name for ${naming.target}`+ }+ className={cn(+ "h-9 min-w-0 rounded-full text-ui-13",+ compact ? "w-full" : "flex-1",+ )}+ />+ <div className="flex shrink-0 items-center gap-2">+ <Button+ type="button"+ variant="outline"+ size="sm"+ disabled={normalizeSavedRunSettingsName(naming.name) === ""}+ onClick={onNamingSubmit}+ >+ Save+ </Button>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ className="text-muted-foreground"+ onClick={() => onNamingChange(null)}+ >+ Cancel+ </Button>+ </div>+ </div>+ );+ }+ return (+ <div className="flex min-w-0 items-center gap-1.5">+ <DropdownMenu>+ <DropdownMenuTrigger asChild={true} disabled={disabled}>+ <button+ type="button"+ aria-label="Run settings for this model"+ className="flex h-9 w-full min-w-0 items-center justify-between gap-1.5 rounded-full border border-border bg-transparent px-3.5 text-left text-ui-13 font-medium text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50"+ >+ <span className="min-w-0 truncate">+ {selected ?? customName ?? "Default settings"}+ </span>+ <HugeiconsIcon+ icon={ChevronDownStandardIcon}+ strokeWidth={2}+ className="size-4 shrink-0 text-muted-foreground"+ />+ </button>+ </DropdownMenuTrigger>+ <DropdownMenuContent+ align="start"+ sideOffset={4}+ className="menu-soft-surface max-h-[min(20rem,var(--radix-dropdown-menu-content-available-height))] w-max min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[min(36rem,calc(100vw-2rem))] rounded-lg border-0 p-1 ring-0"+ >+ <DropdownMenuLabel className={SECTION}>Default</DropdownMenuLabel>+ <DropdownMenuItem className={ITEM} onSelect={() => onPick(null)}>+ <Check on={selected === null && customName === null} />+ <span className="min-w-0 truncate">+ Default settings for {modelName}+ </span>+ </DropdownMenuItem>+ {sets.length > 0 && (+ <>+ <DropdownMenuSeparator className={SEPARATOR} />+ <DropdownMenuLabel className={SECTION}>+ Custom settings+ </DropdownMenuLabel>+ </>+ )}+ {sets.map((entry) => (+ <DropdownMenuItem+ key={entry.name}+ className={cn(ITEM, "pr-1.5")}+ onSelect={() => onPick(entry.name)}+ >+ <Check on={entry.name === selected} />+ <span className="min-w-0 flex-1 truncate">{entry.name}</span>+ <button+ type="button"+ aria-label={`Rename ${entry.name}`}+ className={ROW_ICON}+ onPointerDown={keepRow}+ onPointerUp={keepRow}+ onClick={(event) => {+ keepRow(event);+ onNamingChange({+ mode: "rename",+ name: entry.name,+ target: entry.name,+ });+ }}+ >+ <HugeiconsIcon+ icon={Edit03Icon}+ strokeWidth={1.75}+ className="size-3.5"+ />+ </button>+ <button+ type="button"+ aria-label={`Delete ${entry.name}`}+ className={ROW_ICON}+ onPointerDown={keepRow}+ onPointerUp={keepRow}+ onClick={(event) => {+ keepRow(event);+ onDelete(entry.name);+ }}+ >+ <HugeiconsIcon+ icon={Delete02Icon}+ strokeWidth={1.75}+ className="size-3.5"+ />+ </button>+ </DropdownMenuItem>+ ))}+ </DropdownMenuContent>+ </DropdownMenu>+ {onEditName && (+ <button+ type="button"+ aria-label="Rename this setting"+ title="Rename"+ disabled={disabled}+ onClick={onEditName}+ className={cn(ROW_ICON, "size-9 rounded-full disabled:opacity-50")}+ >+ <HugeiconsIcon+ icon={Edit03Icon}+ strokeWidth={1.75}+ className={compact ? "size-3.5" : "size-4"}+ />+ </button>+ )}+ </div>+ );+}diff --git a/studio/frontend/src/features/model-picker/model-config/per-model-config.ts b/studio/frontend/src/features/model-picker/model-config/per-model-config.tsindex ad4d4818d13..736ad5367b5 100644--- a/studio/frontend/src/features/model-picker/model-config/per-model-config.ts+++ b/studio/frontend/src/features/model-picker/model-config/per-model-config.ts@@ -1746,3 +1746,13 @@ export function resolveResidentInitialConfig(}return resolveInitialConfig(alias, ggufVariant);}++/** For another store to keep a config, schema version included. */+export function toStoredPerModelConfig(config: PerModelConfig): PerModelConfig & { version: number } {+ return toStoredConfig(config);+}++/** Null for a schema this client cannot read. */+export function fromStoredPerModelConfig(raw: unknown): PerModelConfig | null {+ return storedConfigVersion(raw) > STORAGE_SCHEMA_VERSION ? null : normalize(raw);+}diff --git a/studio/frontend/src/features/model-picker/model-config/saved-run-settings.ts b/studio/frontend/src/features/model-picker/model-config/saved-run-settings.tsnew file mode 100644index 00000000000..e83bfeade84--- /dev/null+++ b/studio/frontend/src/features/model-picker/model-config/saved-run-settings.ts@@ -0,0 +1,435 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// Named run settings per model, across quants, and which one each model + quant loads with. The selected set is+// mirrored into the per-model record, which is what a load (and the API) applies.++import { useSyncExternalStore } from "react";+import { normalizeModelIdentity } from "./model-identity";+import {+ type PerModelConfig,+ fromStoredPerModelConfig,+ isChatTemplateWithinLimit,+ toStoredPerModelConfig,+} from "./per-model-config";++export const SAVED_RUN_SETTINGS_STORAGE_KEY =+ "unsloth_model_saved_run_settings";+export const SELECTED_RUN_SETTINGS_STORAGE_KEY =+ "unsloth_model_selected_run_settings";+export const SAVED_RUN_SETTINGS_UPDATED_EVENT =+ "unsloth-saved-run-settings-updated";+export const SAVED_RUN_SETTINGS_NAME_MAX = 80;+export const SAVED_RUN_SETTINGS_PER_MODEL_MAX = 24;++export interface SavedRunSettings {+ name: string;+ savedAt: number;+ config: PerModelConfig;+}++type StoredEntry = { name: string; savedAt: number; config: unknown };+type StoredMap = Record<string, StoredEntry[]>;+/** model + quant key -> set name, or null for Default. Absent = never chosen. */+type SelectionMap = Record<string, string | null>;++function storage(): Storage | null {+ try {+ return typeof localStorage === "undefined" ? null : localStorage;+ } catch {+ return null;+ }+}++function modelKey(modelId: string): string {+ return normalizeModelIdentity(modelId.trim());+}++function selectionKey(modelId: string, ggufVariant: string | null | undefined) {+ return JSON.stringify([+ modelKey(modelId),+ (ggufVariant ?? "").trim().toLowerCase(),+ ]);+}++function selectionPrefix(modelId: string): string {+ return `${JSON.stringify([modelKey(modelId)]).slice(0, -1)},`;+}++export function normalizeSavedRunSettingsName(name: string): string {+ return name.trim().replace(/\s+/g, " ").slice(0, SAVED_RUN_SETTINGS_NAME_MAX);+}++function sameName(a: string, b: string): boolean {+ return a.localeCompare(b, undefined, { sensitivity: "accent" }) === 0;+}++function readJson<T extends object>(key: string): T {+ const raw = storage()?.getItem(key);+ if (!raw) {+ return {} as T;+ }+ try {+ const parsed: unknown = JSON.parse(raw);+ return parsed && typeof parsed === "object" && !Array.isArray(parsed)+ ? (parsed as T)+ : ({} as T);+ } catch {+ return {} as T;+ }+}++function writeJson(key: string, value: object): boolean {+ const store = storage();+ if (!store) {+ return false;+ }+ try {+ store.setItem(key, JSON.stringify(value));+ } catch {+ return false;+ }+ cache.clear();+ // Best-effort: the write already landed.+ if (typeof window?.dispatchEvent === "function") {+ window.dispatchEvent(new Event(SAVED_RUN_SETTINGS_UPDATED_EVENT));+ }+ return true;+}++const readMap = () => readJson<StoredMap>(SAVED_RUN_SETTINGS_STORAGE_KEY);+const writeMap = (map: StoredMap) =>+ writeJson(SAVED_RUN_SETTINGS_STORAGE_KEY, map);+const readSelections = () =>+ readJson<SelectionMap>(SELECTED_RUN_SETTINGS_STORAGE_KEY);+const writeSelections = (map: SelectionMap) =>+ writeJson(SELECTED_RUN_SETTINGS_STORAGE_KEY, map);+// The quant as the picker spells it, by selection key: a server override key keeps that case, and+// an exact key wins over a folded one, so a lower-cased write would lose to a stale entry.+const SELECTED_VARIANTS_STORAGE_KEY =+ "unsloth_model_selected_run_settings_variants";+const readSelectedVariants = () =>+ readJson<Record<string, string>>(SELECTED_VARIANTS_STORAGE_KEY);++function decode(entries: unknown): SavedRunSettings[] {+ if (!Array.isArray(entries)) {+ return [];+ }+ const out: SavedRunSettings[] = [];+ for (const entry of entries as StoredEntry[]) {+ const name =+ entry && typeof entry.name === "string"+ ? normalizeSavedRunSettingsName(entry.name)+ : "";+ // Future-schema records stay stored but are not offered.+ const config = name ? fromStoredPerModelConfig(entry.config) : null;+ if (config) {+ out.push({ name, savedAt: Number(entry.savedAt) || 0, config });+ }+ }+ return out.sort((a, b) => a.name.localeCompare(b.name));+}++// Stable per key between writes, as useSyncExternalStore needs.+const cache = new Map<string, SavedRunSettings[]>();++export function listSavedRunSettings(modelId: string): SavedRunSettings[] {+ const key = modelKey(modelId);+ let list = cache.get(key);+ if (!list) {+ list = decode(readMap()[key]);+ cache.set(key, list);+ }+ return list;+}++function entriesFor(map: StoredMap, key: string): StoredEntry[] {+ return Array.isArray(map[key]) ? map[key] : [];+}++function named(entry: StoredEntry | null | undefined, name: string): boolean {+ return Boolean(+ entry && typeof entry.name === "string" && sameName(entry.name, name),+ );+}++export function saveRunSettings(+ modelId: string,+ name: string,+ config: PerModelConfig,+): boolean {+ const cleanName = normalizeSavedRunSettingsName(name);+ if (+ !cleanName ||+ (typeof config.chatTemplateOverride === "string" &&+ !isChatTemplateWithinLimit(config.chatTemplateOverride))+ ) {+ return false;+ }+ const map = readMap();+ const key = modelKey(modelId);+ const kept = entriesFor(map, key).filter((entry) => !named(entry, cleanName));+ if (kept.length >= SAVED_RUN_SETTINGS_PER_MODEL_MAX) {+ return false;+ }+ map[key] = [+ ...kept,+ {+ name: cleanName,+ savedAt: Date.now(),+ config: toStoredPerModelConfig(config),+ },+ ];+ return writeMap(map);+}++function selectionsNaming(+ selections: SelectionMap,+ modelId: string,+ name: string,+): string[] {+ const prefix = selectionPrefix(modelId);+ return Object.keys(selections).filter((key) => {+ const value = selections[key];+ return (+ key.startsWith(prefix) &&+ typeof value === "string" &&+ sameName(value, name)+ );+ });+}++/** False when ``to`` is blank or another set already has that name. */+export function renameSavedRunSettings(+ modelId: string,+ from: string,+ to: string,+): boolean {+ const cleanName = normalizeSavedRunSettingsName(to);+ const map = readMap();+ const key = modelKey(modelId);+ const entries = entriesFor(map, key);+ const entry = entries.find((candidate) => named(candidate, from));+ if (+ !(cleanName && entry) ||+ entries.some((other) => other !== entry && named(other, cleanName))+ ) {+ return false;+ }+ entry.name = cleanName;+ if (!writeMap(map)) {+ return false;+ }+ const selections = readSelections();+ const renamed = selectionsNaming(selections, modelId, from);+ for (const selected of renamed) {+ selections[selected] = cleanName;+ }+ return renamed.length === 0 || writeSelections(selections);+}++/** Drops the set; quants that loaded with it go to Default. */+export function deleteSavedRunSettings(modelId: string, name: string): boolean {+ const map = readMap();+ const key = modelKey(modelId);+ const entries = entriesFor(map, key);+ const kept = entries.filter((entry) => !named(entry, name));+ if (kept.length !== entries.length) {+ if (kept.length > 0) {+ map[key] = kept;+ } else {+ delete map[key];+ }+ if (!writeMap(map)) {+ return false;+ }+ }+ const selections = readSelections();+ const dropped = selectionsNaming(selections, modelId, name);+ // Default, not unchosen: an unchosen quant would adopt its remembered record back into a set.+ for (const selected of dropped) {+ selections[selected] = null;+ }+ return dropped.length === 0 || writeSelections(selections);+}++/** The quants of this model that load with the set ("" is a model without quants). */+export function quantsSelectingRunSettings(+ modelId: string,+ name: string,+): string[] {+ const variants = readSelectedVariants();+ return selectionsNaming(readSelections(), modelId, name).map((key) => {+ if (typeof variants[key] === "string") {+ return variants[key];+ }+ const parsed: unknown = JSON.parse(key);+ return Array.isArray(parsed) && typeof parsed[1] === "string"+ ? parsed[1]+ : "";+ });+}++export function findSavedRunSettings(+ list: readonly SavedRunSettings[],+ name: string,+): SavedRunSettings | null {+ const cleanName = normalizeSavedRunSettingsName(name);+ return cleanName+ ? (list.find((entry) => sameName(entry.name, cleanName)) ?? null)+ : null;+}++/** The set this model + quant loads with, null for Default, undefined when never chosen. */+export function getSelectedRunSettings(+ modelId: string,+ ggufVariant: string | null | undefined,+): string | null | undefined {+ const value = readSelections()[selectionKey(modelId, ggufVariant)];+ return typeof value === "string" || value === null ? value : undefined;+}++export function setSelectedRunSettings(+ modelId: string,+ ggufVariant: string | null | undefined,+ name: string | null,+): boolean {+ const key = selectionKey(modelId, ggufVariant);+ const variants = readSelectedVariants();+ const spelled = (ggufVariant ?? "").trim();+ if (variants[key] !== spelled) {+ variants[key] = spelled;+ writeJson(SELECTED_VARIANTS_STORAGE_KEY, variants);+ }+ const selections = readSelections();+ if (selections[key] === name) {+ return true;+ }+ selections[key] = name;+ return writeSelections(selections);+}++/** "<model> custom settings", numbered past the names already taken. */+export function newRunSettingsName(+ list: readonly SavedRunSettings[],+ modelName: string,+): string {+ const base = `${modelName} custom settings`;+ let name = withSuffix(base, "");+ for (let n = 2; findSavedRunSettings(list, name); n++) {+ name = withSuffix(base, ` ${n}`);+ }+ return name;+}++// Trims the base, not the suffix: a cut suffix would name the same set forever.+function withSuffix(base: string, suffix: string): string {+ return normalizeSavedRunSettingsName(+ `${normalizeSavedRunSettingsName(base).slice(0, SAVED_RUN_SETTINGS_NAME_MAX - suffix.length)}${suffix}`,+ );+}++// Names earlier builds gave sets: an adopted record, then "Custom setting for <model>[ N]".+const LEGACY_ADOPTED_NAME = "Saved settings";++function legacyRename(+ name: string,+ list: readonly SavedRunSettings[],+ modelName: string,+): string | null {+ if (sameName(name, LEGACY_ADOPTED_NAME)) {+ return newRunSettingsName(list, modelName);+ }+ const old = `Custom setting for ${modelName}`;+ const suffix = name.slice(old.length);+ if (!sameName(name.slice(0, old.length), old) || !/^( \d+)?$/.test(suffix)) {+ return null;+ }+ return withSuffix(`${modelName} custom settings`, suffix);+}++export function hasLegacyRunSettings(+ list: readonly SavedRunSettings[],+ modelName: string,+): boolean {+ return list.some(+ (entry) => legacyRename(entry.name, list, modelName) !== null,+ );+}++export function renameLegacyRunSettings(+ modelId: string,+ modelName: string,+): string[] {+ const renamed: string[] = [];+ for (const { name } of listSavedRunSettings(modelId)) {+ const to = legacyRename(name, listSavedRunSettings(modelId), modelName);+ if (to !== null && renameSavedRunSettings(modelId, name, to)) {+ renamed.push(to);+ }+ }+ return renamed;+}++/** Remembered settings saved before named sets existed: list them as a set and select it. Returns its name. */+export function adoptRememberedRunSettings(+ modelId: string,+ ggufVariant: string | null | undefined,+ config: PerModelConfig,+ modelName: string,+): string | null {+ const stored = JSON.stringify(toStoredPerModelConfig(config));+ const list = listSavedRunSettings(modelId);+ let name = list.find(+ (entry) => JSON.stringify(toStoredPerModelConfig(entry.config)) === stored,+ )?.name;+ if (!name) {+ name = newRunSettingsName(list, modelName);+ if (!saveRunSettings(modelId, name, config)) {+ return null;+ }+ }+ return setSelectedRunSettings(modelId, ggufVariant, name) ? name : null;+}++export function subscribeSavedRunSettings(onChange: () => void): () => void {+ // No listener ran while unsubscribed: another tab may have written.+ cache.clear();+ const onStorage = (event: StorageEvent) => {+ if (+ event.key === null ||+ event.key === SAVED_RUN_SETTINGS_STORAGE_KEY ||+ event.key === SELECTED_RUN_SETTINGS_STORAGE_KEY+ ) {+ cache.clear();+ onChange();+ }+ };+ window.addEventListener(SAVED_RUN_SETTINGS_UPDATED_EVENT, onChange);+ window.addEventListener("storage", onStorage);+ return () => {+ window.removeEventListener(SAVED_RUN_SETTINGS_UPDATED_EVENT, onChange);+ window.removeEventListener("storage", onStorage);+ };+}++const EMPTY: SavedRunSettings[] = [];++export function useSavedRunSettings(modelId: string): SavedRunSettings[] {+ return useSyncExternalStore(+ subscribeSavedRunSettings,+ () => listSavedRunSettings(modelId),+ () => EMPTY,+ );+}++export function useSelectedRunSettings(+ modelId: string,+ ggufVariant: string | null | undefined,+): string | null | undefined {+ return useSyncExternalStore(+ subscribeSavedRunSettings,+ () => getSelectedRunSettings(modelId, ggufVariant),+ () => undefined,+ );+}diff --git a/studio/frontend/tests/run-settings-save-state.test.ts b/studio/frontend/tests/run-settings-save-state.test.tsindex 6f6781d74a6..b2cc7b05157 100644--- a/studio/frontend/tests/run-settings-save-state.test.ts+++ b/studio/frontend/tests/run-settings-save-state.test.ts@@ -1,7 +1,6 @@// 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 path from "node:path";@@ -30,12 +29,15 @@ test("the save status covers every Remember state and is always rendered", () =>"Saved for this model","Unsaved changes","Saved settings will be forgotten",- "Using default settings",+ "Using the default settings",]) {assert.ok(CONFIG_PAGE.includes(`"${label}"`), `missing status: ${label}`);}for (const label of ["Not saved yet", "Not remembered for this model"]) {- assert.ok(!CONFIG_PAGE.includes(`"${label}"`), `redundant status: ${label}`);+ assert.ok(+ !CONFIG_PAGE.includes(`"${label}"`),+ `redundant status: ${label}`,+ );}// Mounted on demand it would push Load down under the cursor on the click that saves.assert.match(CONFIG_PAGE, /\{saveStatus\}/);@@ -53,17 +55,18 @@ test("the status compares what Save would store against the stored record", () =);});-test("an unticked Load forgets only a Remember that was on", () => {+test("a Load on Default forgets only settings that were remembered", () => {const persist = CONFIG_PAGE.slice(CONFIG_PAGE.indexOf("const persistConfig = "),CONFIG_PAGE.indexOf("const finishPersist = "),);- assert.match(persist, /const forgets = !remember && savedRemember;/);+ assert.match(persist, /keep = selectedSet !== null\) =>/);+ assert.match(persist, /const forgets = !keep && savedRemember;/);assert.match(persist,/: forgets\s*\?\s*deletePerModelConfig\(configId, target\.ggufVariant\)\s*:\s*true;/,);- assert.match(persist, /saved &&\s*\(remember \|\| forgets\) &&/);+ assert.match(persist, /saved &&\s*\(keep \|\| forgets\) &&/);});test("a fresh editor adopts the server row when nothing changed in flight", () => {diff --git a/studio/frontend/tests/sampling-memory.test.ts b/studio/frontend/tests/sampling-memory.test.tsindex 72599e779e3..24236cce5b3 100644--- a/studio/frontend/tests/sampling-memory.test.ts+++ b/studio/frontend/tests/sampling-memory.test.ts@@ -177,8 +177,6 @@ test("Remember and Save wait for the first read, so its older result cannot over/\.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\)\}/,- );+ assert.match(footer, /disabled=\{!loaded \|\| busy\}/);+ assert.match(footer, /\(remember \? !unchanged : saved !== null\) &&/);});diff --git a/studio/frontend/tests/saved-run-settings.test.ts b/studio/frontend/tests/saved-run-settings.test.tsnew file mode 100644index 00000000000..40866830853--- /dev/null+++ b/studio/frontend/tests/saved-run-settings.test.ts@@ -0,0 +1,361 @@+// 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 {+ installLocalStorageFake,+ registerBundlerResolver,+} from "./helpers/kit.ts";++registerBundlerResolver();+const { store } = installLocalStorageFake();++const saved = await import(+ "../src/features/model-picker/model-config/saved-run-settings.ts"+);+const { DEFAULT_PER_MODEL_CONFIG, resolveInitialConfig } = await import(+ "../src/features/model-picker/model-config/per-model-config.ts"+);++const MODEL = "unsloth/Repo-GGUF";+const config = (customContextLength: number | null) => ({+ ...DEFAULT_PER_MODEL_CONFIG,+ customContextLength,+});++test.beforeEach(() => store.clear());++test("one model keeps several named settings, listed by name", () => {+ assert.ok(saved.saveRunSettings(MODEL, "Long context", config(32768)));+ assert.ok(saved.saveRunSettings(MODEL, " Fast ", config(4096)));+ const list = saved.listSavedRunSettings(MODEL);+ assert.deepEqual(+ list.map((entry: { name: string }) => entry.name),+ ["Fast", "Long context"],+ );+ assert.equal(list[1].config.customContextLength, 32768);+ // Keyed per model, case-insensitively.+ assert.equal(saved.listSavedRunSettings("UNSLOTH/repo-gguf").length, 2);+ assert.equal(saved.listSavedRunSettings("unsloth/Other-GGUF").length, 0);+});++test("saving under an existing name replaces it, and delete drops only that one", () => {+ saved.saveRunSettings(MODEL, "Fast", config(4096));+ saved.saveRunSettings(MODEL, "Long", config(32768));+ assert.ok(saved.saveRunSettings(MODEL, "fast", config(2048)));+ let list = saved.listSavedRunSettings(MODEL);+ assert.equal(list.length, 2);+ assert.equal(+ saved.findSavedRunSettings(list, "FAST")?.config.customContextLength,+ 2048,+ );+ assert.ok(saved.deleteSavedRunSettings(MODEL, "Fast"));+ list = saved.listSavedRunSettings(MODEL);+ assert.deepEqual(+ list.map((entry: { name: string }) => entry.name),+ ["Long"],+ );+});++test("blank names and a full list are refused", () => {+ assert.equal(saved.saveRunSettings(MODEL, " ", config(4096)), false);+ for (let i = 0; i < saved.SAVED_RUN_SETTINGS_PER_MODEL_MAX; i++) {+ assert.ok(saved.saveRunSettings(MODEL, `Set ${i}`, config(4096 + i)));+ }+ assert.equal(saved.saveRunSettings(MODEL, "One more", config(4096)), false);+ assert.ok(saved.saveRunSettings(MODEL, "Set 0", config(8192)));+});++test("a future-schema entry is kept but not offered", () => {+ store.set(+ saved.SAVED_RUN_SETTINGS_STORAGE_KEY,+ JSON.stringify({+ [MODEL.toLowerCase()]: [+ {+ name: "From the future",+ savedAt: 1,+ config: { version: 999, customContextLength: 1 },+ },+ ],+ }),+ );+ assert.equal(saved.listSavedRunSettings(MODEL).length, 0);+});++test("a panel opened again reads what another tab saved while none was open", () => {+ saved.saveRunSettings(MODEL, "Fast", config(4096));+ assert.equal(saved.listSavedRunSettings(MODEL).length, 1);+ // Another tab's write, with nothing here listening.+ const map = JSON.parse(+ store.get(saved.SAVED_RUN_SETTINGS_STORAGE_KEY) ?? "{}",+ );+ const [key] = Object.keys(map);+ map[key] = [];+ store.set(saved.SAVED_RUN_SETTINGS_STORAGE_KEY, JSON.stringify(map));+ const unsubscribe = saved.subscribeSavedRunSettings(() => undefined);+ assert.equal(saved.listSavedRunSettings(MODEL).length, 0);+ unsubscribe();+});++test("saving a set alone never changes what a load applies", () => {+ saved.saveRunSettings(MODEL, "Long", config(32768));+ assert.equal(resolveInitialConfig(MODEL, null).remembered, false);+});++test("each quant remembers its selection; unchosen, Default and a set read apart", () => {+ assert.equal(saved.getSelectedRunSettings(MODEL, "Q4_K_M"), undefined);+ assert.ok(saved.setSelectedRunSettings(MODEL, "Q4_K_M", "Long"));+ assert.ok(saved.setSelectedRunSettings(MODEL, "Q8_0", null));+ assert.equal(saved.getSelectedRunSettings(MODEL, "q4_k_m"), "Long");+ assert.equal(saved.getSelectedRunSettings(MODEL, "Q8_0"), null);+ assert.equal(+ saved.getSelectedRunSettings("unsloth/Other-GGUF", "Q4_K_M"),+ undefined,+ );+});++test("rename carries the selection; a taken name is refused", () => {+ saved.saveRunSettings(MODEL, "Long", config(32768));+ saved.saveRunSettings(MODEL, "Fast", config(4096));+ saved.setSelectedRunSettings(MODEL, "Q4_K_M", "Long");+ assert.equal(saved.renameSavedRunSettings(MODEL, "Long", "fast"), false);+ assert.ok(saved.renameSavedRunSettings(MODEL, "Long", "Very long"));+ assert.equal(saved.getSelectedRunSettings(MODEL, "Q4_K_M"), "Very long");+ assert.equal(+ saved.findSavedRunSettings(saved.listSavedRunSettings(MODEL), "Very long")+ ?.config.customContextLength,+ 32768,+ );+});++test("the quants that load with a set keep the picker's spelling", () => {+ saved.saveRunSettings(MODEL, "Long", config(32768));+ saved.setSelectedRunSettings(MODEL, "Q4_K_M", "Long");+ saved.setSelectedRunSettings(MODEL, "UD-Q8_K_XL", "Long");+ saved.setSelectedRunSettings(MODEL, "BF16", null);+ saved.setSelectedRunSettings("unsloth/Other-GGUF", "Q4_K_M", "Long");+ assert.deepEqual(saved.quantsSelectingRunSettings(MODEL, "long").sort(), [+ "Q4_K_M",+ "UD-Q8_K_XL",+ ]);+});++test("deleting a set moves every quant that loaded with it to Default", () => {+ saved.saveRunSettings(MODEL, "Long", config(32768));+ saved.setSelectedRunSettings(MODEL, "Q4_K_M", "Long");+ saved.setSelectedRunSettings(MODEL, "Q8_0", "Long");+ saved.setSelectedRunSettings("unsloth/Other-GGUF", "Q4_K_M", "Long");+ assert.ok(saved.deleteSavedRunSettings(MODEL, "Long"));+ // Default, not unchosen: an unchosen quant would adopt its remembered record back into a set.+ assert.equal(saved.getSelectedRunSettings(MODEL, "Q4_K_M"), null);+ assert.equal(saved.getSelectedRunSettings(MODEL, "Q8_0"), null);+ assert.equal(+ saved.getSelectedRunSettings("unsloth/Other-GGUF", "Q4_K_M"),+ "Long",+ );+});++test("new settings are named after the model and numbered past taken names", () => {+ assert.equal(+ saved.newRunSettingsName([], "SmolLM"),+ "SmolLM custom settings",+ );+ const other = "unsloth/Named-GGUF";+ saved.saveRunSettings(other, "SmolLM custom settings", config(2048));+ assert.equal(+ saved.newRunSettingsName(saved.listSavedRunSettings(other), "SmolLM"),+ "SmolLM custom settings 2",+ );+});++test("a model name at the length limit still gets a unique numbered name", () => {+ const longName = "x".repeat(90);+ const first = saved.newRunSettingsName([], longName);+ assert.equal(first.length, saved.SAVED_RUN_SETTINGS_NAME_MAX);+ const other = "unsloth/Long-GGUF";+ saved.saveRunSettings(other, first, config(2048));+ const second = saved.newRunSettingsName(+ saved.listSavedRunSettings(other),+ longName,+ );+ assert.ok(second.endsWith(" 2"));+ assert.ok(second.length <= saved.SAVED_RUN_SETTINGS_NAME_MAX);+ assert.ok(saved.saveRunSettings(other, second, config(4096)));+ assert.ok(+ saved+ .newRunSettingsName(saved.listSavedRunSettings(other), longName)+ .endsWith(" 3"),+ );+});++test("settings remembered before named sets show up as one, and are not duplicated", () => {+ assert.equal(+ saved.adoptRememberedRunSettings(MODEL, "Q4_K_M", config(16384), "SmolLM"),+ "SmolLM custom settings",+ );+ assert.equal(+ saved.getSelectedRunSettings(MODEL, "Q4_K_M"),+ "SmolLM custom settings",+ );+ // Another quant with the same record reuses the set; a different one gets its own name.+ assert.equal(+ saved.adoptRememberedRunSettings(MODEL, "Q8_0", config(16384), "SmolLM"),+ "SmolLM custom settings",+ );+ assert.equal(+ saved.adoptRememberedRunSettings(MODEL, "BF16", config(2048), "SmolLM"),+ "SmolLM custom settings 2",+ );+ assert.equal(saved.listSavedRunSettings(MODEL).length, 2);+});++test("sets named by earlier builds take the model's custom settings name", () => {+ const legacy = "unsloth/Legacy-GGUF";+ saved.saveRunSettings(legacy, "Saved settings", config(4096));+ saved.saveRunSettings(legacy, "Custom setting for SmolLM 2", config(2048));+ saved.saveRunSettings(+ legacy,+ "Custom setting for SmolLM tuned",+ config(1024),+ );+ saved.setSelectedRunSettings(legacy, "Q4_K_M", "Saved settings");+ assert.ok(+ saved.hasLegacyRunSettings(saved.listSavedRunSettings(legacy), "SmolLM"),+ );+ saved.renameLegacyRunSettings(legacy, "SmolLM");+ // A name the user typed that only starts the same way is theirs, not an old default.+ assert.deepEqual(+ saved+ .listSavedRunSettings(legacy)+ .map((entry: { name: string }) => entry.name)+ .sort(),+ [+ "Custom setting for SmolLM tuned",+ "SmolLM custom settings",+ "SmolLM custom settings 2",+ ],+ );+ assert.equal(+ saved.getSelectedRunSettings(legacy, "Q4_K_M"),+ "SmolLM custom settings",+ );+ assert.ok(+ !saved.hasLegacyRunSettings(saved.listSavedRunSettings(legacy), "SmolLM"),+ );+});++test("run settings use one dropdown and one Save, with no Remember checkbox", () => {+ const page = readFileSync(+ new URL(+ "../src/features/model-picker/components/model-config-page.tsx",+ import.meta.url,+ ),+ "utf8",+ );+ assert.match(page, /<RunSettingsPicker\s/);+ assert.match(page, /onClick=\{onSaveClick\}/);+ assert.doesNotMatch(page, /Remember for this model/);+ assert.doesNotMatch(page, /Save without loading|Forget without loading/);+ // Picking a set (or the recommended settings) is what the model loads with next.+ assert.match(+ page,+ /const pickSet = [\s\S]*?persistConfig\(applyToPanel\(next\), entry !== null\)[\s\S]*?keepSelection\(/,+ );+ // Load saves into the selected set (an edited Default becomes one), so the set and what loads+ // never drift apart.+ assert.match(+ page,+ /let loadSet =\s*selectedSet \?\?[\s\S]*?!saveSharedSet\(loadSet, effectiveRuntimeConfig\)[\s\S]*?if \(loadSet !== selectedSet\) \{\s*loadSet = null;[\s\S]*?persistConfig\(effectiveRuntimeConfig, loadSet !== null\)/,+ );+ // Saving an edited Default creates a set, so it takes the same extra-argument gate as a set.+ assert.match(+ page,+ /\(\(selectedSet !== null \|\| customName !== null\) && extraArgsBlocked\)/,+ );+ assert.match(page, /if \(keep && extraArgsBlocked\) \{/);+ // The name box's Save and Enter reach handleSave, so it holds the Save button's readiness gates.+ assert.match(+ page,+ /const handleSave = [\s\S]{0,400}if \(stagedMetadataPending \|\| budgetSettling\) \{\s*return false;/,+ );+ // No pick or Reset before the server copy is read: it could not forget a row it has not seen.+ assert.match(+ page,+ /disabled=\{sharedVariantUnresolved \|\| extraArgsHydrating \|\| budgetSettling\}/,+ );+ // Editing Default shows the name it will be saved under; Save uses it without asking.+ assert.match(+ page,+ /selectedSet === null && !atDefault \? newRunSettingsName\(savedSets, modelName\)/,+ );+ assert.match(page, /\} else \{\s*handleSave\(customName\);/);+ // Reset goes back to Default settings at once, not just the panel values.+ assert.match(+ page,+ /disabled=\{\(atDefault && selectedSet === null\) \|\| extraArgsHydrating \|\| budgetSettling\}[\s\S]{0,160}onClick=\{\(\) => pickSet\(null\)\}/,+ );+ // A number the Save or Load click itself committed is not in customName yet, so both name the+ // new set from the committed config.+ assert.match(+ page,+ /const target = into \?\? committedCustomName\(effectiveRuntimeConfig\);/,+ );+ assert.match(+ page,+ /let loadSet = selectedSet \?\? committedCustomName\(effectiveRuntimeConfig\);/,+ );+ // A load settling its budget captured its config already; a pick then would disagree with it.+ assert.match(+ page,+ /const pickSet = [\s\S]{0,200}if \(budgetSettling\) \{\s*return;/,+ );+ // A shared set: every save into it reaches the other quants that load with it, and a delete+ // forgets their records too.+ assert.match(+ page,+ /if \(keep && !saveSharedSet\(target, effectiveRuntimeConfig\)\)/,+ );+ assert.match(+ page,+ /if \(loadSet !== null && !saveSharedSet\(loadSet, effectiveRuntimeConfig\)\)/,+ );+ assert.match(+ page,+ /const otherQuants = quantsSelectingRunSettings\(configId, name\);[\s\S]*?syncOtherQuants\(otherQuants, null\);/,+ );+ // Syncing other quants can evict another model to fit the budget; its server override goes too.+ assert.match(+ page,+ /savePerModelConfig\(configId, variant, stored, evicted\)[\s\S]{0,400}for \(const dropped of evicted\) \{\s*syncModelOverride\(dropped\.modelId, dropped\.ggufVariant, null/,+ );+ // A pick persists what the panel shows, so a set without arguments clears the server's old flags,+ // and it lifts a stale objection to arguments the pick replaced.+ assert.match(page, /persistConfig\(applyToPanel\(next\), entry !== null\)/);+ assert.match(+ page,+ /setConfig\(applied\);[\s\S]{0,300}setExtraArgsLoadable\(true\);\s*return applied;/,+ );+ // The pencil beside the dropdown renames a set, or names an edited Default before it exists.+ assert.match(+ page,+ /const editName =\s*selectedSet !== null[\s\S]*?mode: "rename"[\s\S]*?customName !== null[\s\S]*?mode: "new", name: customName[\s\S]*?: null;/,+ );+});++test("row icons never pick their row", () => {+ const row = readFileSync(+ new URL(+ "../src/features/model-picker/components/saved-run-settings-row.tsx",+ import.meta.url,+ ),+ "utf8",+ );+ // Radix clicks the item on pointerup when it missed the pointerdown.+ assert.equal(row.match(/onPointerDown=\{keepRow\}/g)?.length, 2);+ assert.equal(row.match(/onPointerUp=\{keepRow\}/g)?.length, 2);+ // New settings come from editing Default, so the menu has no create entry.+ assert.doesNotMatch(row, /Save as new/);+});diff --git a/studio/frontend/tests/share-run-configs.editor.test.ts b/studio/frontend/tests/share-run-configs.editor.test.tsindex 3179dfe3c98..2dcd663ac28 100644--- a/studio/frontend/tests/share-run-configs.editor.test.ts+++ b/studio/frontend/tests/share-run-configs.editor.test.ts@@ -360,9 +360,16 @@ test("local sharing keeps the recipient's quant unless the sender includes it",test("share dialog defaults to Web only on loopback addresses", () => {const previous = window.location;try {- for (const address of ["http://localhost:8888", "http://192.168.1.20:8888"]) {+ for (const address of [+ "http://localhost:8888",+ "http://192.168.1.20:8888",+ ]) {Object.assign(window, { location: new URL(`${address}/chat`) });- assert.equal(new URL(shareDialog(D)().link).protocol, "unsloth:", address);+ assert.equal(+ new URL(shareDialog(D)().link).protocol,+ "unsloth:",+ address,+ );}for (const [address, destination] of [["http://localhost:8888", "browser"],@@ -756,13 +763,23 @@ test("Load and Save refuse while a shared GGUF variant is unresolved", () => {const page = readSrc("features/model-picker/components/model-config-page.tsx",).replace(/\s+/g, " ");- for (const handler of ["handleRun", "handleSave"]) {- const body = page.slice(page.indexOf(`const ${handler} = () => {`));- assert.match(- body.slice(0, 80),- /^const \w+ = \(\) => \{ if \(sharedVariantUnresolved\) \{ return; \}/,- );- const button = page.slice(0, page.indexOf(`onClick={${handler}}`));+ const save = page.slice(page.indexOf("const handleSave = ("));+ assert.match(+ save.slice(0, 200),+ /=> \{ if \(sharedVariantUnresolved\) \{ return false; \}/,+ );+ for (const [handler, onClick] of [+ ["handleRun", "handleRun"],+ ["handleSave", "onSaveClick"],+ ]) {+ if (handler === "handleRun") {+ const body = page.slice(page.indexOf("const handleRun = () => {"));+ assert.match(+ body.slice(0, 80),+ /^const \w+ = \(\) => \{ if \(sharedVariantUnresolved\) \{ return; \}/,+ );+ }+ const button = page.slice(0, page.indexOf(`onClick={${onClick}}`));assert.match(button.slice(button.lastIndexOf("disabled={")),/^disabled=\{ sharedVariantUnresolved \|\|/,diff --git a/tests/studio/playwright_model_config.py b/tests/studio/playwright_model_config.pyindex 9a5603ec664..5d09cc85519 100644--- a/tests/studio/playwright_model_config.py+++ b/tests/studio/playwright_model_config.py@@ -758,23 +758,16 @@ with sync_playwright() as p:else:default_ctx = ctx_in.input_value()info(f"default Context Length shown: {default_ctx!r}")- remember = popover.get_by_label("Remember for this model").first- if _count(remember):- try:- remember.check()- except Exception:- remember.click()- else:- fail("'Remember for this model' checkbox not found")ctx_in.click()ctx_in.fill(str(DISTINCT_CTX))expect(ctx_in).to_have_value(str(DISTINCT_CTX), timeout = 5_000)+ # Enter commits the draft: an uncommitted value leaves Reload disabled on a loaded model.+ ctx_in.press("Enter")shoot("05-ctx-set")btn = primary_button(popover)if btn is None:fail("primary Load/Save button not found in run-settings")else:- # Keep the input focused: the click must commit the draft into the same load request.click_and_wait_for_commit(btn, "context length Load")shoot("06-after-load")@@ -898,12 +891,6 @@ with sync_playwright() as p:# A skip is not a pass: this step is the only guard on the phantom-pin regression.soft_fail("re-type-shown did not run: Context Length input has no numeric default")else:- remember = popover.get_by_label("Remember for this model").first- if _count(remember):- try:- remember.check()- except Exception:- remember.click()ctx_in.click()ctx_in.fill(str(native_default))expect(ctx_in).to_have_value(str(native_default), timeout = 5_000)@@ -966,12 +953,6 @@ with sync_playwright() as p:toggled = Trueexcept Exception:pass- remember = popover.get_by_label("Remember for this model").first- if _count(remember):- try:- remember.check()- except Exception:- remember.click()btn = primary_button(popover)if btn is not None and btn.is_enabled():click_and_wait_for_commit(btn, "advanced settings Load")diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.pyindex 24e0c97ce44..580fac50ef9 100644--- a/tests/studio/test_model_picker_contracts.py+++ b/tests/studio/test_model_picker_contracts.py@@ -1391,7 +1391,7 @@ def test_diffusion_picker_hides_and_clears_unsupported_memory_modes():def _save_button_gate():page = _read("features/model-picker/components/model-config-page.tsx")- save_button = page.split("onClick={handleSave}", 1)[0].rsplit("<Button", 1)[1]+ save_button = page.split("onClick={onSaveClick}", 1)[0].rsplit("<Button", 1)[1]assert "disabled={" in save_button, "the Save button no longer has a disabled gate"return save_button.split("disabled={", 1)[1].split("}", 1)[0]@@ -1411,19 +1411,23 @@ def test_save_settings_waits_for_the_vram_budget_to_settle():def test_forget_settings_is_not_locked_by_unloadable_extra_args():- """Forget only deletes, so invalid saved llama args must not lock it: the args gates- apply to a save only."""+ """Saving Default only forgets, so invalid saved llama args must not lock it: the args gates+ apply to a save into a set (a selected one, or the custom one an edited Default becomes)."""gate = " ".join(_save_button_gate().split())- assert "(remember && ((!extraArgsLoadable && !sharedExtraArgsCleared) ||" in gate, gate- assert "sharedExtraArgsRefused || extraArgsHydrating))" in gate, gate+ assert "((selectedSet !== null || customName !== null) && extraArgsBlocked)" in gate, gate+ page = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())+ assert (+ "const extraArgsBlocked = (!extraArgsLoadable && !sharedExtraArgsCleared) || "+ "sharedExtraArgsRefused || extraArgsHydrating;" in page+ )def test_the_run_settings_footer_does_not_reflow_under_the_pointer():"""A footer that wraps on demand moved Load ~30px between mousedown and mouseup when theblur-committed draft mounted Save, so the click was never dispatched (#10216)."""src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())- before = src.split("<Checkbox id={rememberId}", 1)[0]- # Opening tags of the divs enclosing Remember, nearest first. The footer column is the one+ before = src.split("<RunSettingsPicker ", 1)[0]+ # Opening tags of the divs enclosing the settings dropdown, nearest first. The footer column is the one# under the rule. A wrapper just outside it (the picker's sticky pin) may vary by variant, but# only in placement: it must not make the footer wrap either.attr = r"""(?:[^>"'{]|"[^"]*"|'[^']*'|\{(?:[^{}]|\{[^{}]*\})*\})*"""@@ -1442,20 +1446,20 @@ def test_the_run_settings_footer_does_not_reflow_under_the_pointer():def test_save_settings_is_not_rendered_when_it_could_do_nothing():- """A never-configured model must not show a dead "Forget settings" (#10216)."""- src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())- before = src.split("onClick={handleSave}", 1)[0].rsplit("<Button", 1)[0]- guard = "!persistenceOnly && (remember || savedRemember) && ("- assert guard in before, before[-160:]- assert "</Button>" not in before.rsplit(guard, 1)[1]+ """A never-configured model must not offer a Save that does nothing (#10216): the one Save+ stays in place, so the footer does not move, but is disabled until there is something to keep."""+ gate = " ".join(_save_button_gate().split())+ assert "!canSave" in gate, gate+ page = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())+ assert "? !atDefault || savedRemember" in pagedef test_save_settings_reflects_the_context_it_pinned():"""Save stays on the page, so a pinned context must show; a forget must not pin one."""src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())- handler = src.split("const handleSave = () => {", 1)[1].split("const handleRun", 1)[0]+ handler = src.split("const handleSave = (", 1)[1].split("const handleRun", 1)[0]assert (- "if ( remember && effectiveRuntimeConfig.customContextLength !== config.customContextLength"+ "if ( keep && effectiveRuntimeConfig.customContextLength !== config.customContextLength"in handler)assert (@@ -2568,10 +2572,10 @@ def test_only_gguf_configs_are_mirrored_to_the_server():resolver indexes GGUFs only."""src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())assert (- "if ( saved && (remember || forgets) && (target.apiLoadable ?? target.isGguf) && "+ "if ( saved && (keep || forgets) && (target.apiLoadable ?? target.isGguf) && ""!nativePathToken ) { syncModelOverride(" in src)- assert "const saved = remember ? savePerModelConfig(" in src+ assert "const saved = keep ? savePerModelConfig(" in srcdef test_a_native_leased_gguf_is_not_mirrored_to_the_server():@@ -2867,7 +2871,7 @@ def test_the_settings_page_judges_the_config_storage_actually_keeps():assert "storedSpeculativeAuto(rememberedConfig, !target.isGguf)" in srcassert "defaultConfig: isDefaultConfig(normalized)" in srcassert "savePerModelConfig(configId, target.ggufVariant, normalized, evicted)" in src- assert "remember ? normalized : null," in src+ assert "keep ? normalized : null," in srcassert "isDefaultConfig(effectiveRuntimeConfig)" not in srcassert "isDefaultConfig(next)" not in src@@ -2979,8 +2983,11 @@ def test_the_sidebar_settings_editor_reseeds_when_the_live_config_lands():assert "markModelConfigDraftEdited(draftKey)" in page# Only once the write landed, or the next read replaces values still on screen.assert re.search(r"if \(saved\) \{.*?clearModelConfigDraftEdited\(draftKey\);", page)- # An unticked Remember is a pending Forget the read's guard would otherwise re-tick.- assert "markModelConfigDraftEdited(draftKey); setRemember(checked === true);" in page+ # Picking a saved setting fills the panel as an edit, so the read's guard does not overwrite it.+ assert (+ "const applyToPanel = (next: PerModelConfig) => { // As Reset: an edit that drops the raw "+ "arguments text. handleSharedConfigEdit(); markModelConfigDraftEdited(draftKey);" in page+ )assert "(!extraArgsLoadable && !sharedExtraArgsCleared) ||" in page# Run reads the draft, not the render closure: the peer's input blurs during this click.assert "const liveDraftConfig = readModelConfigDraft(draftKey)?.config;" in page@@ -3157,14 +3164,14 @@ def test_run_settings_page_keeps_its_identifying_controls():assert 'aria-label="Back to model list"' in pageassert 'ariaLabel="Context Length"' in pageassert 'aria-label="Context Length"' in page- # The button element, not the word: "Reset" also appears in comments.+ # The button element, not the word: "Reset" also appears in comments. Reset picks Default+ # settings, which fills the panel with DEFAULT_PER_MODEL_CONFIG.reset = any(- "DEFAULT_PER_MODEL_CONFIG" in el.group(0)- and ">\n Reset\n <" in el.group(0)- or ("DEFAULT_PER_MODEL_CONFIG" in el.group(0) and re.search(r">\s*Reset\s*<", el.group(0)))+ "onClick={() => pickSet(null)}" in el.group(0) and re.search(r">\s*Reset\s*<", el.group(0))for el in re.finditer(r"<Button\b.*?</Button>", page, re.S))assert reset, "the Reset button's JSX is gone or no longer named Reset"+ assert "const next = entry?.config ?? DEFAULT_PER_MODEL_CONFIG;" in pagedef test_the_primary_action_keeps_its_four_labels():