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
Clean up Hub runtime/config coupling (#9886)
Eyera9dfb40780e1f
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsxindex e19d58383b2..f8284711745 100644--- a/studio/frontend/src/features/chat/chat-page.tsx+++ b/studio/frontend/src/features/chat/chat-page.tsx@@ -3,6 +3,7 @@import {applyModelLoadConfigToRuntime,+ clearModelConfigHandoff,currentRuntimePerModelConfig,type DeletedModelRef,type ExternalConnectionRef,@@ -14,9 +15,11 @@ import {type PerModelConfig,isServedByMlx,loadedContextFields,+ modelConfigHandoffForDestination,resolveInitialConfig,SidebarModelConfig,useActiveModelConfig,+ useModelConfigHandoffStore,} from "@/features/model-picker";import { ProjectComposer, Thread } from "@/components/assistant-ui/thread";import { usePlatformStore } from "@/config/env";@@ -2255,6 +2258,24 @@ export function ChatPage({// Controlled, so the chord can open the switcher and not just its trigger.const [projectPickerOpen, setProjectPickerOpen] = useState(false);const [modelSelectorLocked, setModelSelectorLocked] = useState(false);+ const modelConfigRequest = useModelConfigHandoffStore((state) =>+ modelConfigHandoffForDestination(state.request, {+ active,+ newChatId: search.new,+ threadId: search.thread,+ compareId: search.compare,+ projectId: search.project,+ }),+ );+ const handleModelConfigRequestAdopted = useCallback(+ (requestId: string) => {+ setSettingsOpen(false);+ setModelSelectorLocked(false);+ setModelSelectorOpen(true);+ clearModelConfigHandoff(requestId);+ },+ [setSettingsOpen],+ );const viewBeforeCompareRef = useRef<ChatSearch | null>(null);// Latest non-compare view, so exiting compare can restore it even when compare was opened from a// path that does not set viewBeforeCompareRef.@@ -3954,13 +3975,17 @@ export function ChatPage({activeGgufVariant={activeGgufVariant}activeModelConfig={activeModelConfig}activeLoadedContextLength={loadedContextLength}+ configRequest={modelConfigRequest}+ onConfigRequestAdopted={handleModelConfigRequestAdopted}onValueChange={handleCheckpointChange}onEject={handleEject}onFoldersChange={refreshLocalModels}onModelsChange={refreshModelLists}deleteDisabled={modelOperationInProgress}variant="ghost"- open={active && modelSelectorOpen}+ open={+ active && (modelSelectorOpen || modelConfigRequest !== null)+ }onOpenChange={handleModelSelectorOpenChange}triggerDataTour="chat-model-selector"contentDataTour="chat-model-selector-popover"@@ -4250,7 +4275,7 @@ export function ChatPage({</div><ChatSettingsPanel- open={active && settingsOpen}+ open={active && modelConfigRequest === null && settingsOpen}onOpenChange={(open) => {setSettingsOpen(open);}}diff --git a/studio/frontend/src/features/chat/lib/resident-model-match.ts b/studio/frontend/src/features/chat/lib/resident-model-match.tsindex c3a77559e4f..d309c99c012 100644--- a/studio/frontend/src/features/chat/lib/resident-model-match.ts+++ b/studio/frontend/src/features/chat/lib/resident-model-match.ts@@ -36,8 +36,8 @@ export function residentModelMatchesPick(if (!status.active_model) {return false;}- // A standalone file has no quant to choose between, and its row carries no label- // (settingsGgufVariantForRow) while the backend derives one from the filename.+ // A standalone file has no quant to choose between, and its picker entry carries+ // no variant while the backend derives one from the filename.const picksItsOwnVariant = !(!pick.ggufVariant && isStandaloneGgufPath(pick.loadPath ?? pick.id));diff --git a/studio/frontend/src/features/hub/catalog/dataset-download-section.tsx b/studio/frontend/src/features/hub/catalog/dataset-download-section.tsxindex f3268aabda9..fdb74de1dd1 100644--- a/studio/frontend/src/features/hub/catalog/dataset-download-section.tsx+++ b/studio/frontend/src/features/hub/catalog/dataset-download-section.tsx@@ -8,12 +8,8 @@ import {} from "@/components/ui/tooltip";import { useHttpPartialsResumable, useRepoDownload } from "../download-manager";import { deleteCachedDataset } from "../inventory";-import { cn } from "@/lib/utils";-import { TrainIcon } from "../components/train-icon";-import { HUB_POST_DOWNLOAD_ACTIONS_VISIBLE } from "../lib/hub-feature-flags";import { DotTag } from "./dot-tag";import { PathInfoButton } from "./path-info-button";-import { HugeiconsIcon } from "@hugeicons/react";import { useState } from "react";import { useHfTokenStore } from "../stores/hf-token-store";import { formatBytes } from "../lib/format";@@ -36,7 +32,6 @@ export function DatasetDownloadSection({partialResumable = false,cachePath,knownBytes,- onTrain,onChange,}: {repoId: string;@@ -46,7 +41,6 @@ export function DatasetDownloadSection({partialResumable?: boolean;cachePath?: string | null;knownBytes?: number | null;- onTrain?: () => void;onChange?: () => void;}) {const hfToken = useHfTokenStore((s) => s.token);@@ -162,23 +156,8 @@ export function DatasetDownloadSection({)}</div></div>- {/* Train CTA hidden until Hub→train picker ships; divider pairs with it. */}- {(!isDownloaded || downloading || HUB_POST_DOWNLOAD_ACTIONS_VISIBLE) && (- <CardDivider />- )}- {isDownloaded && !downloading ? (- <button- type="button"- onClick={() => onTrain?.()}- className={cn(- "hub-action-btn w-28",- !HUB_POST_DOWNLOAD_ACTIONS_VISIBLE && "hidden",- )}- >- <HugeiconsIcon icon={TrainIcon} strokeWidth={1.75} />- Train- </button>- ) : (+ {(!isDownloaded || downloading) && <CardDivider />}+ {(!isDownloaded || downloading) && (<DownloadActionButtondownloading={downloadAction.downloading}cancelling={downloadAction.cancelling}diff --git a/studio/frontend/src/features/hub/catalog/download-card.tsx b/studio/frontend/src/features/hub/catalog/download-card.tsxindex ab79e98b4a6..4ba98dfac66 100644--- a/studio/frontend/src/features/hub/catalog/download-card.tsx+++ b/studio/frontend/src/features/hub/catalog/download-card.tsx@@ -23,7 +23,7 @@ import {ArrowReloadHorizontalIcon,Delete02Icon,Download01Icon,- Settings02Icon,+ PlayIcon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import {@@ -96,36 +96,36 @@ export function CardDivider() {);}-export function CardSettingsButton({+export function ModelRunActionButton({label,onClick,+ loading = false,}: {label: string;onClick: () => void;+ loading?: boolean;}) {return (- <Tooltip>- <TooltipTrigger asChild>- <button- type="button"- aria-label={label}- onClick={(e) => {- e.stopPropagation();- onClick();- }}- className="inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground opacity-0 transition-[opacity,background-color,color] duration-150 hover:bg-foreground/[0.06] hover:text-foreground focus-visible:opacity-100 group-hover/dl:opacity-100 dark:hover:bg-white/[0.08]"- >- <HugeiconsIcon- icon={Settings02Icon}- strokeWidth={1.75}- className="size-4"- />- </button>- </TooltipTrigger>- <TooltipContent side="top" className="tooltip-compact">- {label}- </TooltipContent>- </Tooltip>+ <button+ type="button"+ aria-label={loading ? `${label}. Opening configuration.` : label}+ aria-busy={loading}+ disabled={loading}+ onClick={onClick}+ className="hub-run-action-btn w-28"+ >+ {loading ? (+ <>+ <Spinner />+ Opening…+ </>+ ) : (+ <>+ <HugeiconsIcon icon={PlayIcon} strokeWidth={1.75} />+ Run+ </>+ )}+ </button>);}diff --git a/studio/frontend/src/features/hub/catalog/download-section.tsx b/studio/frontend/src/features/hub/catalog/download-section.tsxindex 31b32646ea0..dee6adb1d44 100644--- a/studio/frontend/src/features/hub/catalog/download-section.tsx+++ b/studio/frontend/src/features/hub/catalog/download-section.tsx@@ -2,6 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import type { ModelInventoryFormat } from "../inventory";+import type { HubModelRunSelection } from "../lib/model-run-selection";import { GgufDownloadCard } from "./gguf-download-card";import { SafetensorsDownloadCard } from "./safetensors-download-card";@@ -13,7 +14,6 @@ export function DownloadSection({partialTransport = null,partialResumable = false,modelFormat,- canRun = true,isActive,activeQuant,preferredGgufFile = null,@@ -25,10 +25,8 @@ export function DownloadSection({systemRamGb,cachePath,knownBytes,- onLoad,- onUseInChat,- onEject,- onTrain,+ onRun,+ runPending = false,onChange,showMemoryBar = true,mediaRuntime = false,@@ -40,7 +38,6 @@ export function DownloadSection({partialTransport?: string | null;partialResumable?: boolean;modelFormat?: ModelInventoryFormat | null;- canRun?: boolean;isActive: boolean;activeQuant: string | null;preferredGgufFile?: string | null;@@ -52,10 +49,8 @@ export function DownloadSection({systemRamGb?: number;cachePath?: string | null;knownBytes?: number | null;- onLoad: (opts: { ggufVariant?: string; expectedBytes?: number }) => void;- onUseInChat?: () => void;- onEject?: () => void;- onTrain?: () => void;+ onRun?: (selection: HubModelRunSelection) => void;+ runPending?: boolean;onChange?: () => void;/** False for diffusion / audio / video GGUFs, which do not load through* llama.cpp and so have nothing the KV estimator can say about them. */@@ -69,7 +64,6 @@ export function DownloadSection({isActive={isActive}activeQuant={activeQuant}preferredFile={preferredGgufFile}-preferredFileIntent={preferredGgufFileIntent}isLoadingThisModel={isLoadingThisModel}gpuGb={gpuGb}@@ -77,9 +71,8 @@ export function DownloadSection({systemRamGb={systemRamGb}cachePath={cachePath}isPartial={isPartial}- onLoad={onLoad}- onUseInChat={onUseInChat}- onEject={onEject}+ onRun={onRun}+ runPending={runPending}onChange={onChange}showMemoryBar={showMemoryBar}mediaRuntime={mediaRuntime}@@ -94,15 +87,12 @@ export function DownloadSection({partialTransport={partialTransport}partialResumable={partialResumable}modelFormat={modelFormat}- canRun={canRun}isActive={isActive}isLoadingThisModel={isLoadingThisModel}cachePath={cachePath}knownBytes={knownBytes}- onLoad={onLoad}- onUseInChat={onUseInChat}- onEject={onEject}- onTrain={onTrain}+ onRun={onRun ? () => onRun({}) : undefined}+ runPending={runPending}onChange={onChange}/>);diff --git a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsxindex 3bbfca9e990..ffde621fad7 100644--- a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx+++ b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx@@ -39,8 +39,6 @@ import {MoreVerticalIcon,PinIcon,PinOffIcon,- PlayIcon,- RemoveCircleIcon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import {@@ -69,11 +67,11 @@ import {ggufVariantTransferLabel,sortDownloadableGgufVariants,} from "../lib/gguf-variant-sort";-import { HUB_GGUF_RUN_ACTIONS_VISIBLE } from "../lib/hub-feature-flags";import {ggufVariantsMatch,normalizeGgufVariantIdentity,} from "../lib/model-identity";+import type { HubModelRunSelection } from "../lib/model-run-selection";import { useHfTokenStore } from "../stores/hf-token-store";import { DotTag } from "./dot-tag";import { DownloadStopIndicator } from "./download-cancel-indicator";@@ -81,6 +79,7 @@ import {CardDivider,DeleteConfirmDialog,DownloadCard,+ ModelRunActionButton,UpdateConfirmDialog,} from "./download-card";import {@@ -145,21 +144,17 @@ const CHIP_BASE ="inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded-full border px-2 text-ui-11p5 font-medium tabular-nums leading-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]";const CHIP_DEFAULT ="border-foreground/15 bg-muted text-foreground/85 dark:border-border/60 dark:bg-white/[0.04] dark:text-foreground/85";-const CHIP_ACTIVE =- "border-control-accent/40 bg-control-accent/10 text-control-accent";function QuantBadge({quant,fit,showFit = true,- active = false,variant = "trigger",tooltipMode = "eager",}: {quant: string;fit: GgufFitClass;showFit?: boolean;- active?: boolean;variant?: "trigger" | "menu";tooltipMode?: "eager" | "lazy" | "none";}) {@@ -179,7 +174,7 @@ function QuantBadge({// `shrink` overrides CHIP_BASE's shrink-0 so a long file-path quant// label can shrink and truncate instead of overflowing the row."min-w-0 max-w-full shrink gap-1.5 cursor-help",- active ? CHIP_ACTIVE : CHIP_DEFAULT,+ CHIP_DEFAULT,)}>{showFit && (@@ -194,14 +189,9 @@ function QuantBadge({) : (// Trigger quant label is the row's primary identity and is short// (e.g. "Q4_K_M"); keep it `shrink-0` + `whitespace-nowrap` so it never- // collapses to "q…" when the Update/Run actions crowd the row. The info+ // collapses to "q…" when trailing actions crowd the row. The info// group's `overflow-hidden` sacrifices the trailing status tags instead.- <span- className={cn(- "inline-flex shrink-0 cursor-help items-center gap-1.5 whitespace-nowrap text-ui-12p5 font-medium tracking-tight tabular-nums",- active ? "text-control-accent" : "text-foreground",- )}- >+ <span className="inline-flex shrink-0 cursor-help items-center gap-1.5 whitespace-nowrap text-ui-12p5 font-medium tracking-tight tabular-nums text-foreground">{showFit && (<HugeiconsIconicon={InformationCircleIcon}@@ -276,9 +266,9 @@ function createGgufVariantMenuItems(}));}-// Shared options menu: used on every variant row, the run bar, and the-// single-model (non-GGUF) run bar. Omit `quant` for a repo-level model. The-// identifier uses llama.cpp's repo:quant syntax so it pastes into `-hf`.+// Shared options menu for downloaded variant rows and the selected-variant+// action strip. Omit `quant` for a repo-level model. The identifier uses+// llama.cpp's repo:quant syntax so it pastes into `-hf`.export function QuantOptionsMenu({repoId,quant,@@ -296,7 +286,7 @@ export function QuantOptionsMenu({downloaded: boolean;canDelete: boolean;onDelete: (quant?: string) => void;- // Hidden in the run bar; pinning belongs to the On Device list.+ // Hidden in the selected-variant action strip; pinning belongs to On Device.showPin?: boolean;buttonClassName?: string;iconClassName?: string;@@ -449,7 +439,7 @@ const GgufVariantMenuRow = memo(function GgufVariantMenuRow({repoId,item,selected,- loaded,+ mutationBlocked,liveActive,showFitInfo,onSelect,@@ -458,7 +448,7 @@ const GgufVariantMenuRow = memo(function GgufVariantMenuRow({repoId: string;item: GgufVariantMenuItem;selected: boolean;- loaded: boolean;+ mutationBlocked: boolean;liveActive: boolean;showFitInfo: boolean;onSelect: (quant: string) => void;@@ -477,7 +467,8 @@ const GgufVariantMenuRow = memo(function GgufVariantMenuRow({},[selectVariant],);- const canDelete = (item.downloaded || item.partial) && !loaded && !liveActive;+ const canDelete =+ (item.downloaded || item.partial) && !mutationBlocked && !liveActive;return (<div@@ -493,7 +484,7 @@ const GgufVariantMenuRow = memo(function GgufVariantMenuRow({: "hover:bg-foreground/[0.05] dark:hover:bg-foreground/[0.06]",)}>- {/* Status (On device / Loaded / Partial) sits beside the quant on the+ {/* Status (On device / Partial) sits beside the quant on theleft so the model's identity reads as one unit; only the size pinsright. No per-row "GGUF" tag: every row here is a GGUF quant and thetrigger already labels it, so repeating it only stole the room the@@ -503,13 +494,10 @@ const GgufVariantMenuRow = memo(function GgufVariantMenuRow({quant={item.label}fit={item.fit}showFit={showFitInfo}- active={loaded}variant="menu"tooltipMode="lazy"/>- {item.downloaded && (- <DotTag tone="success" label={loaded ? "Loaded" : "On device"} />- )}+ {item.downloaded && <DotTag tone="success" label="On device" />}{!item.downloaded && item.partial && (<Tooltip><TooltipTrigger asChild={true}>@@ -567,8 +555,8 @@ export function GgufDownloadCard({cachePath,preferLocalCache = false,isPartial = false,- onLoad,- onEject,+ onRun,+ runPending = false,onChange,showMemoryBar = true,mediaRuntime = false,@@ -587,10 +575,8 @@ export function GgufDownloadCard({cachePath?: string | null;preferLocalCache?: boolean;isPartial?: boolean;- onLoad: (opts: { ggufVariant?: string; expectedBytes?: number }) => void;- /** Accepted for API parity; the run bar ejects instead of opening chat. */- onUseInChat?: () => void;- onEject?: () => void;+ onRun?: (selection: HubModelRunSelection) => void;+ runPending?: boolean;onChange?: () => void;/** False for diffusion / audio / video GGUFs. They load through a different* planner onto a single torch device rather than the aggregate inference@@ -774,12 +760,6 @@ export function GgufDownloadCard({const ctaDisabled = isLoadingThisModel || !selected;const selectedIsActive =isActive && activeQuant && ggufVariantsMatch(selected?.quant, activeQuant);- const isGgufRunCta =- !!selected?.downloaded &&- !cancelling &&- !downloadingThisVariant &&- !isLoadingThisModel &&- !selectedIsActive;// No verdict beats a wrong one: a media repo's fit is the diffusion planner's question, and// this card only knows how to answer llama.cpp's. The picker still badges those rows.const showFitInfo = !mediaRuntime && (Boolean(gpuGb) || Boolean(systemRamGb));@@ -829,7 +809,7 @@ export function GgufDownloadCard({? true: downloadingThisVariant? false- : ctaDisabled && !selectedIsActive,+ : ctaDisabled,isPartial: Boolean(selected?.partial),partialTransport: selected?.partial_transport ?? null,partialResumable: selected?.partial_resumable === true,@@ -897,6 +877,29 @@ export function GgufDownloadCard({}, [updateTarget, updateTargetVariant, repoId]);const variantListUnavailable = !sortedVariants || sortedVariants.length === 0;const showVariantLoadingState = loading && variantListUnavailable;+ const showUpdateAction =+ selected?.downloaded === true &&+ online &&+ updateAvailable &&+ !selectedIsActive &&+ !isLoadingThisModel &&+ !runPending &&+ !cancelling &&+ !downloadAction.starting &&+ !downloadingThisVariant;+ const showDownloadAction =+ !selected?.downloaded ||+ downloadingThisVariant ||+ cancelling ||+ downloadAction.starting;+ const showRunAction =+ Boolean(onRun) &&+ selected?.downloaded === true &&+ selected.partial !== true &&+ !downloadingThisVariant &&+ !cancelling &&+ !downloadAction.starting &&+ !isLoadingThisModel;// Keep showing download progress while the variant list is unavailable, so a// remount never hides an in-flight download behind the variant status card.@@ -990,15 +993,21 @@ export function GgufDownloadCard({</>}>- <Popover open={open} onOpenChange={setOpen}>+ <Popover+ open={runPending ? false : open}+ onOpenChange={(nextOpen) => {+ if (!runPending) setOpen(nextOpen);+ }}+ ><PopoverTrigger asChild={true}><buttontype="button"+ disabled={runPending}onClick={(e) => {e.preventDefault();setOpen((o) => !o);}}- className="hub-menu-trigger flex h-9 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-full px-3 text-left transition-colors hover:bg-foreground/[0.04] data-[state=open]:bg-foreground/[0.06] dark:hover:bg-white/[0.04] dark:data-[state=open]:bg-white/[0.06]"+ className="hub-menu-trigger flex h-9 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-full px-3 text-left transition-colors hover:bg-foreground/[0.04] data-[state=open]:bg-foreground/[0.06] disabled:cursor-wait disabled:opacity-60 disabled:hover:bg-transparent dark:hover:bg-white/[0.04] dark:data-[state=open]:bg-white/[0.06] dark:disabled:hover:bg-transparent">{/* Quant label + status tags travel together as one left-alignedgroup so the fit-info icon never floats orphaned from its tags.@@ -1011,7 +1020,6 @@ export function GgufDownloadCard({quant={selectedLabel ?? selected.quant}fit={selectedFit ?? "oom"}showFit={showFitInfo}- active={Boolean(selectedIsActive)}/>) : (<span className="text-ui-12p5 text-muted-foreground">@@ -1019,10 +1027,7 @@ export function GgufDownloadCard({</span>)}{selected?.downloaded && (- <DotTag- tone="success"- label={selectedIsActive ? "Loaded" : "On device"}- />+ <DotTag tone="success" label="On device" />)}{selected && !selected.downloaded && selected.partial && (<Tooltip>@@ -1075,7 +1080,11 @@ export function GgufDownloadCard({repoId={repoId}item={item}selected={item.key === selectedVariantKey}- loaded={isActive && item.key === activeVariantKey}+ mutationBlocked={+ runPending ||+ isLoadingThisModel ||+ (isActive && item.key === activeVariantKey)+ }liveActive={liveActive}showFitInfo={showFitInfo}onSelect={handleSelectVariant}@@ -1087,7 +1096,6 @@ export function GgufDownloadCard({</PopoverContent></Popover>- {/* TODO: inference settings gear hidden for now, work on it in a future PR. */}{/* Options only resolve managed HF-cache repos, so skip local paths;they also only apply to quants actually on disk. */}{selected &&@@ -1102,7 +1110,8 @@ export function GgufDownloadCard({Boolean(selected.downloaded || selected.partial) &&!selectedIsActive &&!downloadingThisVariant &&- !isLoadingThisModel+ !isLoadingThisModel &&+ !runPending}onDelete={(q) => q && handleDeleteVariant(q)}showPin={false}@@ -1111,109 +1120,86 @@ export function GgufDownloadCard({/>)}- {!isGgufRunCta && <CardDivider />}+ {(showUpdateAction || showDownloadAction || showRunAction) && (+ <CardDivider />+ )}- {selected?.downloaded &&- online &&- updateAvailable &&- !selectedIsActive &&- !downloadingThisVariant && (- <button- type="button"- onClick={() => selected && setUpdateTarget(selected.quant)}- aria-label={`Update ${repoId}`}- className="hub-action-btn ml-1 text-amber-700 dark:text-amber-300"- >- <HugeiconsIcon- icon={ArrowReloadHorizontalIcon}- strokeWidth={1.75}- />- Update- </button>- )}+ {showUpdateAction && (+ <button+ type="button"+ onClick={() => selected && setUpdateTarget(selected.quant)}+ aria-label={`Update ${repoId}`}+ className="hub-action-btn ml-1 text-amber-700 dark:text-amber-300"+ >+ <HugeiconsIcon+ icon={ArrowReloadHorizontalIcon}+ strokeWidth={1.75}+ />+ Update+ </button>+ )}- <button- type="button"- disabled={downloadAction.disabled}- onClick={() => {- if (downloadingThisVariant) {- downloadAction.onClick();- return;- }- if (selectedIsActive) {- onEject?.();- return;- }- if (!selected) return;- if (selected.downloaded) {- onLoad({+ {showDownloadAction && (+ <button+ type="button"+ disabled={downloadAction.disabled}+ onClick={downloadAction.onClick}+ aria-label={downloadAction.ariaLabel}+ className={cn(+ "hub-action-btn w-24",+ ctaDisabled &&+ !downloadingThisVariant &&+ !cancelling &&+ "opacity-70",+ (cancelling || downloadAction.starting) && "opacity-70",+ downloadingThisVariant &&+ !cancelling &&+ "hover:bg-rose-500/10 hover:text-rose-600 dark:hover:text-rose-400",+ )}+ >+ {cancelling ? (+ <span className="inline-flex items-center gap-2 text-muted-foreground">+ <Spinner />+ Cancelling…+ </span>+ ) : downloadingThisVariant ? (+ <span className="inline-flex items-center gap-2">+ <DownloadStopIndicator mode={downloadAction.stopMode} />+ {downloadAction.progressPercent != null+ ? `${downloadAction.progressPercent}%`+ : null}+ </span>+ ) : downloadAction.starting ? (+ <span className="inline-flex items-center gap-2">+ <Spinner />+ Starting…+ </span>+ ) : (+ <>+ <HugeiconsIcon icon={Download01Icon} strokeWidth={1.75} />+ {downloadAction.downloadLabel}+ </>+ )}+ </button>+ )}++ {showRunAction && onRun && selected && (+ <ModelRunActionButton+ label={`Configure and run ${repoId} ${selectedLabel ?? selected.quant}`}+ loading={runPending}+ onClick={() =>+ onRun({ggufVariant: selected.quant,- expectedBytes: selected.size_bytes,- });- } else {- downloadAction.onClick();+ ggufFilename: selected.filename,+ expectedBytes:+ selected.download_size_bytes &&+ selected.download_size_bytes > 0+ ? selected.download_size_bytes+ : selected.size_bytes,+ })}- }}- aria-label={downloadAction.ariaLabel}- className={cn(- isGgufRunCta ? "hub-run-action-btn w-24" : "hub-action-btn w-24",- isGgufRunCta && "ml-2",- ctaDisabled &&- !selectedIsActive &&- !downloadingThisVariant &&- !cancelling &&- "opacity-70",- (cancelling || downloadAction.starting) && "opacity-70",- downloadingThisVariant &&- !cancelling &&- "hover:bg-rose-500/10 hover:text-rose-600 dark:hover:text-rose-400",- !HUB_GGUF_RUN_ACTIONS_VISIBLE &&- !downloadingThisVariant &&- !cancelling &&- !isLoadingThisModel &&- (selectedIsActive || selected?.downloaded) &&- "hidden",- )}- >- {cancelling ? (- <span className="inline-flex items-center gap-2 text-muted-foreground">- <Spinner />- Cancelling…- </span>- ) : downloadingThisVariant ? (- <span className="inline-flex items-center gap-2">- <DownloadStopIndicator mode={downloadAction.stopMode} />- {downloadAction.progressPercent != null- ? `${downloadAction.progressPercent}%`- : null}- </span>- ) : downloadAction.starting ? (- <span className="inline-flex items-center gap-2">- <Spinner />- Starting…- </span>- ) : isLoadingThisModel ? (- <span className="inline-flex items-center gap-2">- <Spinner />- Loading…- </span>- ) : selectedIsActive ? (- <>- <HugeiconsIcon icon={RemoveCircleIcon} strokeWidth={1.75} />- Eject- </>- ) : selected?.downloaded ? (- <>- <HugeiconsIcon icon={PlayIcon} strokeWidth={1.75} />- Run- </>- ) : (- <>- <HugeiconsIcon icon={Download01Icon} strokeWidth={1.75} />- {downloadAction.downloadLabel}- </>- )}- </button>+ />+ )}</DownloadCard>{/* Only a quant actually on disk gets charted: an undownloaded one has noweights to measure, and the fit badge already tiers those. */}diff --git a/studio/frontend/src/features/hub/catalog/hub-model-settings-view.tsx b/studio/frontend/src/features/hub/catalog/hub-model-settings-view.tsxdeleted file mode 100644index 8802447bef9..00000000000--- a/studio/frontend/src/features/hub/catalog/hub-model-settings-view.tsx+++ /dev/null@@ -1,150 +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--// Full-page settings for one model, opened from the Hub. The same controls exist in the-// chat picker's popover, but a popover is a poor place to work through every knob.--import {- ModelConfigPage,- type ModelPickTarget,- modelConfigInstanceKey,-} from "@/features/model-picker";-import type { PerModelConfig } from "@/features/model-picker";-import { cn } from "@/lib/utils";-import {- Globe02Icon,-} from "@hugeicons/core-free-icons";-import {- ChevronLeftIcon,-} from "lucide-react";-import { HugeiconsIcon } from "@hugeicons/react";-import { useEffect, useRef, useState } from "react";--export function HubModelSettingsView({- target,- loadedConfig = null,- loadedContextLength = null,- onBack,- onRun,- compact = false,-}: {- target: ModelPickTarget;- /** Non-null when this model is loaded, so the page can show live values. */- loadedConfig?: PerModelConfig | null;- loadedContextLength?: number | null;- onBack: () => void;- /** Apply + load with these settings. */- onRun: (config: PerModelConfig) => void;- compact?: boolean;-}) {- const scrollRef = useRef<HTMLDivElement | null>(null);- const [scrolled, setScrolled] = useState(false);- // Mirrors HubDetailView so this view sits at the Hub's measure.- const measure = compact- ? "mx-auto w-full max-w-[var(--hub-measure-compact)] px-5 sm:px-5"- : "mx-auto w-full max-w-[var(--hub-measure)] px-5 sm:px-8";-- useEffect(() => {- const el = scrollRef.current;- if (!el) return;- const onScroll = () => {- const next = el.scrollTop > 0;- setScrolled((current) => (current === next ? current : next));- };- onScroll();- el.addEventListener("scroll", onScroll, { passive: true });- return () => el.removeEventListener("scroll", onScroll);- }, []);-- return (- <div className="relative flex min-h-0 flex-1 flex-col">- <div- aria-hidden="true"- data-scrolled={scrolled || undefined}- className="hub-scroll-fade pointer-events-none absolute inset-x-0 top-0 z-10 h-7"- />- <div- ref={scrollRef}- data-hub-scroll="true"- className={cn(- "min-h-0 flex-1 overflow-x-hidden overflow-y-auto [overflow-anchor:none] [scrollbar-width:thin]",- compact- ? "mr-2 [scrollbar-gutter:stable]"- : "[scrollbar-gutter:stable_both-edges]",- )}- >- <div- className="hub-detail-bar sticky top-0 z-20"- data-scrolled={scrolled || undefined}- >- <div className={`${measure} py-3`}>- <button- type="button"- onClick={onBack}- className="-ml-1.5 inline-flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-full pl-1.5 pr-2.5 text-ui-12p5 font-medium text-muted-foreground transition-colors hover:bg-foreground/[0.05] hover:text-foreground dark:hover:bg-white/[0.06]"- >- <ChevronLeftIcon- strokeWidth={1.75}- className="size-3.5"- />- Back to Hub- </button>- </div>- </div>-- <div className={cn(measure, "pb-20")}>- <header className="flex flex-col gap-1 pb-5">- <h1 className="min-w-0 break-words text-ui-24 font-semibold leading-[1.1] tracking-[-0.022em] text-foreground">- {target.displayName}- </h1>- <p className="min-w-0 break-all text-ui-12 text-muted-foreground">- {target.id}- {target.ggufVariant ? ` · ${target.ggufVariant}` : ""}- </p>- </header>-- <div className="mb-5 flex items-start gap-2.5 rounded-xl border border-border/60 bg-card px-4 py-3">- <span className="mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg border border-border/60 bg-muted/40">- <HugeiconsIcon- icon={Globe02Icon}- strokeWidth={1.75}- className="size-3.5"- />- </span>- <p className="min-w-0 text-ui-12 leading-[1.5] text-muted-foreground">- {/* Only what auto-switch reaches: it indexes GGUFs and skips Ollama. */}- {(target.apiLoadable ?? target.isGguf)- ? "Saved settings apply everywhere this model loads, including when an OpenAI-compatible API request asks for it."- : "Saved settings apply everywhere Unsloth loads this model."}{" "}- Turn on{" "}- <span className="font-medium text-foreground">- Remember for this model- </span>{" "}- below to keep them.- </p>- </div>-- <div className="rounded-xl border border-border/60 bg-card px-4 py-4">- <ModelConfigPage- // Keyed on the live config too, like the sidebar entry: ModelConfigPage- // reads loadedConfig once, so opening before status hydrates would leave- // the editor on saved values that Apply then writes back over.- key={modelConfigInstanceKey(- target.id,- target.ggufVariant,- loadedConfig,- )}- target={target}- onRun={onRun}- loadedConfig={loadedConfig}- loadedContextLength={loadedContextLength}- variant="page"- // The page heading already names the model; "Run settings" would repeat it.- showHeader={false}- />- </div>- </div>- </div>- </div>- );-}diff --git a/studio/frontend/src/features/hub/catalog/local-dataset-card.tsx b/studio/frontend/src/features/hub/catalog/local-dataset-card.tsxindex a4e6e5c9f5a..76f7ef4aef7 100644--- a/studio/frontend/src/features/hub/catalog/local-dataset-card.tsx+++ b/studio/frontend/src/features/hub/catalog/local-dataset-card.tsx@@ -1,9 +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 { TrainIcon } from "@/features/hub/components/train-icon";-import { HUB_POST_DOWNLOAD_ACTIONS_VISIBLE } from "@/features/hub/lib/hub-feature-flags";-import { HugeiconsIcon } from "@hugeicons/react";import type { LocalSource } from "../types";import { DotTag } from "./dot-tag";import { PathInfoButton } from "./path-info-button";@@ -12,14 +9,12 @@ interface LocalDatasetCardProps {sourceLabel: string;source: LocalSource;path: string;- onTrain?: () => void;}export function LocalDatasetCard({sourceLabel,source,path,- onTrain,}: LocalDatasetCardProps) {return (<div className="hub-download-card">@@ -37,23 +32,6 @@ export function LocalDatasetCard({<PathInfoButton path={path} /></div></div>- {HUB_POST_DOWNLOAD_ACTIONS_VISIBLE && (- <div- aria-hidden="true"- className="ml-1 mr-0 h-5 w-px shrink-0 bg-foreground/[0.06] opacity-100 transition-opacity duration-150 group-hover/dl:opacity-0 dark:bg-white/[0.04]"- />- )}- {/* Train CTA hidden until Hub→train picker ships. */}- {onTrain && HUB_POST_DOWNLOAD_ACTIONS_VISIBLE && (- <button- type="button"- onClick={() => onTrain()}- className="hub-action-btn w-28"- >- <HugeiconsIcon icon={TrainIcon} strokeWidth={1.75} />- Train- </button>- )}</div></div>);diff --git a/studio/frontend/src/features/hub/catalog/local-on-device-card.tsx b/studio/frontend/src/features/hub/catalog/local-on-device-card.tsxindex 9a66c9366c5..28da3bd5408 100644--- a/studio/frontend/src/features/hub/catalog/local-on-device-card.tsx+++ b/studio/frontend/src/features/hub/catalog/local-on-device-card.tsx@@ -2,30 +2,22 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { ModelMemoryBarFor } from "@/components/model-memory-bar";-import { useVramBudgetFraction } from "@/hooks/use-vram-budget-fraction";import {Popover,PopoverContent,PopoverTrigger,} from "@/components/ui/popover";-import { Spinner } from "@/components/ui/spinner";import {Tooltip,TooltipContent,TooltipTrigger,} from "@/components/ui/tooltip";+import { useVramBudgetFraction } from "@/hooks/use-vram-budget-fraction";import { ChevronDownStandardIcon } from "@/lib/chevron-icons";import { cn } from "@/lib/utils";-import {- Alert02Icon,- CubeIcon,- PlayIcon,- RemoveCircleIcon,- Share05Icon,-} from "@hugeicons/core-free-icons";+import { Alert02Icon, CubeIcon, Share05Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { useCallback, useMemo, useState } from "react";-import { TrainIcon } from "../components/train-icon";import {downloadManager,jobKeyOf,@@ -40,6 +32,7 @@ import {deleteCachedModel,} from "../inventory";import { formatBytes } from "../lib/format";+import type { HubModelRunSelection } from "../lib/model-run-selection";import {ggufFilenamesMatch,@@ -47,37 +40,30 @@ import {} from "../lib/gguf-filename";import {ggufVariantDisplayLabel,+ resolveLocalGgufVariant,sortLocalGgufVariants,} from "../lib/gguf-variant-sort";-import {- HUB_GGUF_RUN_ACTIONS_VISIBLE,- HUB_NON_GGUF_RUN_ACTIONS_VISIBLE,- HUB_POST_DOWNLOAD_ACTIONS_VISIBLE,-} from "../lib/hub-feature-flags";import { ggufVariantsMatch } from "../lib/model-identity";import { confirmExternalLink } from "../stores/external-link-confirm";import { useHfTokenStore } from "../stores/hf-token-store";+import { DeleteImpactSummary, useDeleteImpact } from "./delete-impact";import { DotTag } from "./dot-tag";import {CardDeleteButton,- CardSettingsButton,+ CardDivider,CardUpdateButton,DeleteConfirmDialog,+ ModelRunActionButton,UpdateConfirmDialog,} from "./download-card";import { PathInfoButton } from "./path-info-button";import { TransportConflictDialog } from "./transport-conflict-dialog";-import { DeleteImpactSummary, useDeleteImpact } from "./delete-impact";import { useCardDelete } from "./use-card-delete";import { useGgufVariantFetchState } from "./use-gguf-variant-fetch-state";-type LocalLoadOptions = {- ggufVariant?: string;- expectedBytes?: number;-};-interface LocalOnDeviceCardProps {modelId: string;+ displayName: string;repoId: string | null;sourceLabel: string;source: LocalModelInfo["source"];@@ -96,11 +82,9 @@ interface LocalOnDeviceCardProps {baseModelSummary?: string | null;adapterType?: string | null;trainingMethod?: string | null;- canRun?: boolean;isActive: boolean;activeGgufVariant?: string | null;isLoading: boolean;- loadingPhase?: "downloading" | "starting";preferredFile?: string | null;preferredFileIntent?: number;@@ -109,21 +93,9 @@ interface LocalOnDeviceCardProps {gpuCount?: number;systemRamGb?: number;unsupportedReason?: string | null;- onLoad: (opts?: LocalLoadOptions) => void;- /** Accepted for API parity; the run bar ejects instead of opening chat. */- onUseInChat: () => void;- onEject?: () => void;- onTrain?: () => void;+ onRun?: (selection: HubModelRunSelection) => void;+ runPending?: boolean;onChange?: () => void;- /**- * Open settings for the quant this card is showing. ``quantIsUserPicked`` says whether- * it came from this card's selector or was derived from the resident model, which- * decides whether a fresher status read may override it.- */- onOpenSettings?: (- ggufVariant: string | null,- quantIsUserPicked: boolean,- ) => void;}function formatAdapterLabel(@@ -217,6 +189,7 @@ function BaseModelReference({export function LocalOnDeviceCard({modelId,+ displayName,repoId,sourceLabel,source,@@ -231,11 +204,9 @@ export function LocalOnDeviceCard({baseModelSummary,adapterType,trainingMethod,- canRun = true,isActive,activeGgufVariant = null,isLoading,- loadingPhase,preferredFile = null,preferredFileIntent = 0,@@ -243,11 +214,9 @@ export function LocalOnDeviceCard({gpuCount,systemRamGb,unsupportedReason,- onLoad,- onEject,- onTrain,+ onRun,+ runPending = false,onChange,- onOpenSettings,}: LocalOnDeviceCardProps) {const [deleteOpen, setDeleteOpen] = useState(false);const [updateOpen, setUpdateOpen] = useState(false);@@ -278,7 +247,10 @@ export function LocalOnDeviceCard({// Update availability is derived from the GGUF variant metadata; offline rows// keep the button hidden because there is no remote revision to fetch.const online = useOnlineStatus();- const deleteImpact = useDeleteImpact(deleteOpen && Boolean(repoId), repoId ?? "");+ const deleteImpact = useDeleteImpact(+ deleteOpen && Boolean(repoId),+ repoId ?? "",+ );const { deleting, runDelete } = useCardDelete({action: async () => {if (!repoId) return;@@ -324,7 +296,11 @@ export function LocalOnDeviceCard({}));const canDelete =- source === "hf_cache" && !!repoId && !isActive && !isLoading;+ source === "hf_cache" &&+ !!repoId &&+ !isActive &&+ !isLoading &&+ !runPending;const variants = useMemo(() => {const localVariants = currentVariantState.variants;const remoteVariants = remoteVariantState.variants;@@ -357,7 +333,6 @@ export function LocalOnDeviceCard({variants? sortLocalGgufVariants(variants, {defaultVariant: currentVariantState.defaultVariant,- activeGgufVariant: isActive ? activeGgufVariant : null,gpuGb,gpuCount,systemRamGb,@@ -367,8 +342,6 @@ export function LocalOnDeviceCard({[variants,currentVariantState.defaultVariant,- isActive,- activeGgufVariant,gpuGb,gpuCount,systemRamGb,@@ -390,32 +363,12 @@ export function LocalOnDeviceCard({)? selectedVariantState.quant: preferredQuant;- const selectedQuant =- selectedVariantOverride &&- sortedVariants?.some((variant) =>- ggufVariantsMatch(variant.quant, selectedVariantOverride),- )- ? selectedVariantOverride- : (sortedVariants?.find(- (variant) =>- isActive && ggufVariantsMatch(variant.quant, activeGgufVariant),- )?.quant ??- sortedVariants?.find((variant) =>- ggufVariantsMatch(variant.quant, currentVariantState.defaultVariant),- )?.quant ??- sortedVariants?.[0]?.quant ??- null);- // Only the first branch is a choice; the rest read the store, which can be stale.- const quantIsUserPicked = Boolean(- selectedVariantOverride &&- sortedVariants?.some((variant) =>- ggufVariantsMatch(variant.quant, selectedVariantOverride),- ),- );- const selectedVariant =- sortedVariants?.find((variant) =>- ggufVariantsMatch(variant.quant, selectedQuant),- ) ?? null;+ const selectedVariant = resolveLocalGgufVariant(sortedVariants, {+ selectedVariant: selectedVariantOverride,+ activeVariant: isActive ? activeGgufVariant : null,+ defaultVariant: currentVariantState.defaultVariant,+ });+ const selectedQuant = selectedVariant?.quant ?? null;// True while a managed download/update for this repo+variant is in flight.const updateJobActive = useDownloadManagerStore((s) =>repoId@@ -442,6 +395,7 @@ export function LocalOnDeviceCard({!!repoId &&!isActive &&!isLoading &&+ !runPending &&!updateJobActive &&updateAvailable;// Update runs as a MANAGED download (same path as a normal download) so it@@ -466,18 +420,6 @@ export function LocalOnDeviceCard({void remoteVariantState.refresh();});};- const selectedVariantIsActive =- needsVariantSelection && selectedQuant- ? isActive && ggufVariantsMatch(activeGgufVariant, selectedQuant)- : isActive;- const variantUnavailable =- needsVariantSelection &&- (currentVariantState.loading ||- currentVariantState.error !== null ||- selectedVariant === null);- const variantActionPending =- needsVariantSelection && currentVariantState.loading;-const formatLabel =modelFormat === "gguf"? "GGUF"@@ -491,9 +433,11 @@ export function LocalOnDeviceCard({const formatTone =modelFormat === "adapter" ? "adapter" : isGguf ? "gguf" : "checkpoint";const showOldCacheHint = source === "hf_cache" && !!unsupportedReason;- const runActionsVisible = isGguf- ? HUB_GGUF_RUN_ACTIONS_VISIBLE- : HUB_NON_GGUF_RUN_ACTIONS_VISIBLE;+ const selectedVariantReady =+ !needsVariantSelection ||+ (selectedVariant?.downloaded === true && selectedVariant.partial !== true);+ const showRunAction =+ Boolean(onRun) && selectedVariantReady && !updateJobActive && !isLoading;return (<div className="flex w-full flex-col gap-2">@@ -515,17 +459,19 @@ export function LocalOnDeviceCard({<div className="group/dl flex items-center"><div className="relative flex h-9 min-w-0 flex-1 items-center pl-3 pr-2"><span className="flex min-w-0 items-center gap-1.5 text-ui-12 text-muted-foreground">- <DotTag- tone="success"- label={selectedVariantIsActive ? "Loaded" : "On device"}- />+ <DotTag tone="success" label="On device" /><DotTag tone={formatTone} label={formatLabel} />{needsVariantSelection && (- <Popover open={variantOpen} onOpenChange={setVariantOpen}>+ <Popover+ open={runPending ? false : variantOpen}+ onOpenChange={(nextOpen) => {+ if (!runPending) setVariantOpen(nextOpen);+ }}+ ><PopoverTrigger asChild={true}><buttontype="button"- disabled={currentVariantState.loading}+ disabled={currentVariantState.loading || runPending}className="inline-flex h-6 max-w-[170px] shrink-0 cursor-pointer items-center gap-1.5 rounded-[8px] border border-format-gguf/35 px-2 font-mono text-ui-10p5 leading-none text-format-gguf transition-colors hover:bg-format-gguf/8 disabled:cursor-not-allowed disabled:opacity-60"><span className="truncate">@@ -562,9 +508,6 @@ export function LocalOnDeviceCard({variant.quant,selectedQuant,);- const isLoaded =- ggufVariantsMatch(variant.quant, activeGgufVariant) &&- isActive;return (<buttonkey={variant.filename}@@ -590,9 +533,6 @@ export function LocalOnDeviceCard({{label}</span><span className="flex shrink-0 items-center gap-1.5">- {isLoaded && (- <DotTag tone="success" label="Loaded" />- )}<span className="text-ui-10 text-muted-foreground tabular-nums">{formatBytes(variant.size_bytes)}</span>@@ -623,15 +563,6 @@ export function LocalOnDeviceCard({)}</span><div className="ml-auto flex items-center gap-0.5">- {onOpenSettings && (- <CardSettingsButton- label={`Settings for ${repoId}`}- // The quant this card resolved, so settings edits what is on screen.- onClick={() =>- onOpenSettings(selectedQuant ?? null, quantIsUserPicked)- }- />- )}{canUpdate && (<CardUpdateButtonlabel={`Update ${repoId}`}@@ -648,103 +579,42 @@ export function LocalOnDeviceCard({<PathInfoButton path={path} /></div></div>- {onTrain && HUB_POST_DOWNLOAD_ACTIONS_VISIBLE && (- <div- aria-hidden="true"- className="ml-1 mr-0 h-5 w-px shrink-0 bg-foreground/[0.06] opacity-100 transition-opacity duration-150 group-hover/dl:opacity-0 dark:bg-white/[0.04]"- />- )}- <div- className={cn(- "group/pair flex h-9 shrink-0 items-stretch gap-1.5",- !runActionsVisible && "hidden",- )}- >- {onTrain && HUB_POST_DOWNLOAD_ACTIONS_VISIBLE && (- <button- type="button"- onClick={() => onTrain()}- className="hub-action-btn w-24"- >- <HugeiconsIcon icon={TrainIcon} strokeWidth={1.75} />- Train- </button>- )}- <button- type="button"- disabled={isLoading || variantUnavailable || !canRun}- onClick={() => {- if (!canRun) return;- if (selectedVariantIsActive) {- onEject?.();- return;- }- if (needsVariantSelection) {- if (!selectedVariant) return;- onLoad({- ggufVariant: selectedVariant.quant,- expectedBytes: selectedVariant.size_bytes,- });- return;+ {showRunAction && onRun && (+ <>+ <CardDivider />+ <ModelRunActionButton+ label={`Configure and run ${displayName.trim() || "this model"}`}+ loading={runPending}+ onClick={() =>+ onRun(+ needsVariantSelection && selectedVariant+ ? {+ ggufVariant: selectedVariant.quant,+ ggufFilename: selectedVariant.filename,+ expectedBytes:+ selectedVariant.download_size_bytes &&+ selectedVariant.download_size_bytes > 0+ ? selectedVariant.download_size_bytes+ : selectedVariant.size_bytes,+ }+ : {},+ )}- onLoad();- }}- className={cn(- isLoading ||- selectedVariantIsActive ||- variantUnavailable ||- !canRun- ? "hub-action-btn w-24"- : "hub-run-action-btn w-24",- (isLoading || variantUnavailable || !canRun) && "opacity-70",- )}- >- {isLoading ? (- <>- <Spinner />- {loadingPhase === "downloading" ? "Preparing…" : "Loading…"}- </>- ) : selectedVariantIsActive ? (- <>- <HugeiconsIcon icon={RemoveCircleIcon} strokeWidth={1.75} />- Eject- </>- ) : variantActionPending ? (- <>- <Spinner />- Loading…- </>- ) : canRun ? (- <>- <HugeiconsIcon icon={PlayIcon} strokeWidth={1.75} />- Run- </>- ) : (- <>- <HugeiconsIcon icon={Alert02Icon} strokeWidth={1.75} />- No run- </>- )}- </button>- </div>+ />+ </>+ )}</div>- {/* Below the action row, not inside it: the row is a horizontal flex- container, so a full-width bar there becomes another flex item and- squeezes the Run/Train buttons. */}- {/* A direct .gguf path skips variant selection entirely, so selectedQuant- is null for exactly the local files this is meant to cover. The path- names the weights on its own there, and the backend resolves a- direct file without needing a quant to match. */}+ {/* Render the full-width memory bar below the horizontal card row so it+ does not compete with row controls for width. */}+ {/* A direct .gguf path skips variant selection, so selectedQuant is null.+ The path itself still supplies the local artifact identity. */}{showMemoryBar &&(repoId || localGgufPath) &&(selectedQuant || localGgufPath.toLowerCase().endsWith(".gguf")) ? (<ModelMemoryBarFor- // The card's own path is what Run opens, so it is the identity the- // estimate has to use: a repo cached under several roots or revisions- // can otherwise resolve a different snapshot and chart weights the- // click does not load. It is also the only identity a custom or local- // GGUF has, where repoId is null and the bar used to be suppressed- // outright despite a perfectly good path being right here.+ // The card's exact path identifies the downloaded artifact across+ // cache roots and revisions. It is also the only identity available+ // for a custom or local GGUF when repoId is null.repoId={repoId || localGgufPath}loadId={localGgufPath}quant={selectedQuant ?? ""}diff --git a/studio/frontend/src/features/hub/catalog/model-download-state.ts b/studio/frontend/src/features/hub/catalog/model-download-state.tsnew file mode 100644index 00000000000..bebfce38a8d--- /dev/null+++ b/studio/frontend/src/features/hub/catalog/model-download-state.ts@@ -0,0 +1,22 @@+// 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 { SelectedModelView } from "../types";++export type ModelDownloadState = {+ isDownloaded: boolean;+ isPartial: boolean;+ partialTransport: string | null;+ partialResumable: boolean;+};++export function modelDownloadState(+ model: SelectedModelView,+): ModelDownloadState {+ return {+ isDownloaded: model.isDownloaded,+ isPartial: model.isPartial ?? false,+ partialTransport: model.partialTransport ?? null,+ partialResumable: model.partialResumable === true,+ };+}diff --git a/studio/frontend/src/features/hub/catalog/model-inspector.tsx b/studio/frontend/src/features/hub/catalog/model-inspector.tsxindex 0265ca9765a..e46203b0b03 100644--- a/studio/frontend/src/features/hub/catalog/model-inspector.tsx+++ b/studio/frontend/src/features/hub/catalog/model-inspector.tsx@@ -18,6 +18,7 @@ import {formatShortDate,} from "@/features/hub/lib/format";import { useHfTokenStore } from "@/features/hub/stores/hf-token-store";+import { taskForMediaPick } from "@/features/model-picker/components/model-selector/audio-picker-policy";import { Tick02Icon } from "@/lib/tick-icon";import { cn, formatCompact } from "@/lib/utils";import {@@ -43,6 +44,11 @@ import { memo, useDeferredValue, useMemo } from "react";import { selectActiveJob, useDownloadManagerStore } from "../download-manager";import { useCopyFeedback } from "../hooks/use-copy-feedback";import { useDatasetSize } from "../hooks/use-dataset-size";+import {+ type HubModelRunSelection,+ isHubModelRunEligible,+} from "../lib/model-run-selection";+import { studioPageForTask } from "../lib/unsloth-support";import {formatLibrary,formatLocalUpdated,@@ -52,23 +58,14 @@ import {import { confirmExternalLink } from "../stores/external-link-confirm";import type { SelectedModelView } from "../types";import { DatasetDownloadSection } from "./dataset-download-section";-import { taskForMediaPick } from "@/features/model-picker/components/model-selector/audio-picker-policy";-import { routableToMediaPage } from "../lib/local-path";-import { studioPageForTask } from "../lib/unsloth-support";import { DownloadSection } from "./download-section";import { LocalDatasetCard } from "./local-dataset-card";import { LocalOnDeviceCard } from "./local-on-device-card";+import { modelDownloadState } from "./model-download-state";import { ModelReadme } from "./model-readme";import { OwnerAvatar } from "./owner-avatar";import { AccessChip, CapabilityPill } from "./shared";-// HF pipeline_tag values authoritative for embedding-only repos; capability-// labels (code/vision/audio) can leak onto them via name or tags.-const EMBEDDING_PIPELINE_TAGS: ReadonlySet<string> = new Set([- "feature-extraction",- "sentence-similarity",-]);-function ViewRepositoryButton({repoId,isDataset,@@ -389,7 +386,6 @@ export type ModelInspectorRuntime = {isActive: boolean;activeGgufVariant: string | null;isLoadingThisModel: boolean;- loadingPhase?: "downloading" | "starting";minMemory: string | null;vramInfo: {est: number;@@ -402,18 +398,13 @@ export type ModelInspectorRuntime = {};export type ModelInspectorActions = {- onLoad: (opts: { ggufVariant?: string; expectedBytes?: number }) => void;- onLoadLocal: (opts?: {- ggufVariant?: string;- expectedBytes?: number;- }) => void;- onUseInChat: () => void;- onEject?: () => void;- onTrain?: () => void;onInventoryChange?: () => void;onSearchHub?: (query: string) => void;- /** Open settings with the quant the card resolved. */- onOpenSettings?: (ggufVariant: string | null) => void;+ onRun?: (+ selection: HubModelRunSelection,+ mediaPage: ReturnType<typeof studioPageForTask>,+ ) => void;+ runConfigPending?: boolean;};export const ModelInspector = memo(function ModelInspector({@@ -432,7 +423,6 @@ export const ModelInspector = memo(function ModelInspector({metadataUnavailable?: boolean;selectionHiddenByFilters?: boolean;preferredGgufFile?: string | null;-preferredGgufFileIntent?: number;runtime: ModelInspectorRuntime;actions: ModelInspectorActions;@@ -441,7 +431,6 @@ export const ModelInspector = memo(function ModelInspector({isActive,activeGgufVariant,isLoadingThisModel,- loadingPhase,minMemory,vramInfo,gpuGb,@@ -449,17 +438,16 @@ export const ModelInspector = memo(function ModelInspector({systemRamGb,} = runtime;const {- onLoad,- onLoadLocal,- onUseInChat,- onEject,- onTrain,onInventoryChange,onSearchHub,- onOpenSettings,+ onRun,+ runConfigPending = false,} = actions;const deviceType = usePlatformStore((s) => s.deviceType);const chatOnly = usePlatformStore((s) => s.isChatOnly());+ const chatOnlyMeasured = usePlatformStore(+ (s) => s.isChatOnly() && !s.capabilitiesUnknown(),+ );const hfToken = useHfTokenStore((s) => s.token);const datasetRepoId = isDataset && model?.hubRepoId ? model.hubRepoId : null;const datasetSize = useDatasetSize(datasetRepoId, {@@ -527,13 +515,14 @@ export const ModelInspector = memo(function ModelInspector({<p className="max-w-sm text-ui-12p5 leading-5 text-muted-foreground">{isDataset? "Choose a dataset from the catalog to inspect its download state and details."- : "Choose an item from the catalog to inspect its runtime fit, download state, and model card."}+ : "Choose an item from the catalog to inspect its hardware fit, download state, and model card."}</p></div></div>);}+ const downloadState = modelDownloadState(model);const updatedRaw = model.updatedAt? formatRelativeShort(model.updatedAt): formatLocalUpdated(model.localUpdatedAt);@@ -560,55 +549,23 @@ export const ModelInspector = memo(function ModelInspector({const paramsLabel = model.totalParams? formatCompact(model.totalParams): "N/A";- const unslothSupported = unslothSupport.status !== "unsupported";- // Embedding-only non-GGUF repos have no generative head, so keep them out of- // the Run gate. Prefer the pipeline tag, else the capability heuristic.- const isEmbeddingOnly =- !model.isGguf &&- model.capabilities.some((c) => c.key === "embedding") &&- (EMBEDDING_PIPELINE_TAGS.has(model.pipelineTag?.toLowerCase() ?? "") ||- !model.capabilities.some(- (c) =>- c.key === "conversational" ||- c.key === "tools" ||- c.key === "reasoning" ||- c.key === "code" ||- c.key === "vision" ||- c.key === "audio",- ));- // An image / video model runs on its own page, which onLoad already routes to;- // the chat gates below would leave it greyed out as if it were unusable. Only when the- // row is one onLoad can actually route there: those pages resolve a routed `model` as a- // Hub id, so a filesystem row fails routableToMediaPage and the click falls through to- // the chat loader, which unloads the resident model for a load that can only fail.- // Whether this model's runtime is llama.cpp at all. Deliberately NOT- // runsOnMediaPage below: that one also asks whether the click can be ROUTED to- // the page, which is a different question. A diffusion GGUF on a filesystem row- // is not routable and still does not load through llama.cpp, so a memory bar- // there would describe the wrong runtime either way.- const runsOnMediaRuntime =- studioPageForTask(- taskForMediaPick(model.pipelineTag, model.task) ?? undefined,- ) !== undefined;- const runsOnMediaPage =- studioPageForTask(- taskForMediaPick(model.pipelineTag, model.task) ?? undefined,- ) !== undefined &&- routableToMediaPage(model.kind, model.localSource);- // Chat-only hosts (no supported GPU / usable MLX) run inference only through- // llama.cpp, so only GGUF is loadable.- const canRunModel =- !isDataset &&- (runsOnMediaPage ||- ((model.runtimeCapabilities?.canChat ?? true) &&- !isEmbeddingOnly &&- (model.isGguf || (!chatOnly && unslothSupported))));- const canTrainModel =- !isDataset &&- (model.runtimeCapabilities?.canTrain ?? false) &&- model.modelFormat !== "gguf" &&- model.modelFormat !== "adapter" &&- unslothSupported;+ // Media models use a separate runtime, so the llama.cpp memory estimate does+ // not describe their load.+ const mediaPage = studioPageForTask(+ taskForMediaPick(model.pipelineTag, model.task) ?? undefined,+ );+ const runsOnMediaRuntime = mediaPage !== undefined;+ const runEligible = isHubModelRunEligible({+ model,+ isDataset,+ mediaRuntime: runsOnMediaRuntime,+ nonGgufRuntimeAvailable:+ !chatOnlyMeasured && unslothSupport.status !== "unsupported",+ });+ const runAction =+ runEligible && onRun+ ? (selection: HubModelRunSelection) => onRun(selection, mediaPage)+ : undefined;const languages = parseLanguageTags(model.tags);const datasetSizeBytes =@@ -687,13 +644,9 @@ export const ModelInspector = memo(function ModelInspector({<InspectorDownloadSlot><DatasetDownloadSectionrepoId={model.hubRepoId}- isDownloaded={model.isDownloaded}- isPartial={model.isPartial ?? false}- partialTransport={model.partialTransport ?? null}- partialResumable={model.partialResumable === true}+ {...downloadState}cachePath={model.path}knownBytes={model.cachedBytes}- onTrain={onTrain}onChange={onInventoryChange}/></InspectorDownloadSlot>@@ -704,7 +657,6 @@ export const ModelInspector = memo(function ModelInspector({sourceLabel={model.sourceLabel}source={model.localSource ?? "custom"}path={model.path}- onTrain={onTrain}/></InspectorDownloadSlot>)}@@ -714,6 +666,7 @@ export const ModelInspector = memo(function ModelInspector({<LocalOnDeviceCardshowMemoryBar={!runsOnMediaRuntime}modelId={model.id}+ displayName={model.title}repoId={model.hubRepoId}sourceLabel={model.sourceLabel}source={model.localSource ?? "custom"}@@ -727,30 +680,23 @@ export const ModelInspector = memo(function ModelInspector({baseModelSummary={model.baseModelSummary}adapterType={model.adapterType}trainingMethod={model.trainingMethod}- canRun={canRunModel}isActive={isActive}activeGgufVariant={activeGgufVariant}isLoading={isLoadingThisModel}- loadingPhase={loadingPhase}gpuGb={gpuGb}gpuCount={gpuCount}systemRamGb={systemRamGb}-preferredFile={preferredGgufFile}preferredFileIntent={preferredGgufFileIntent}unsupportedReason={- unslothSupport.status === "unsupported" && !unslothSupport.supportedIn+ unslothSupport.status === "unsupported" &&+ !unslothSupport.supportedIn? (unslothSupport.reason ?? "Unsupported format"): null}- onLoad={onLoadLocal}- onUseInChat={onUseInChat}- onEject={onEject}- onTrain={- model.isDownloaded && canTrainModel ? onTrain : undefined- }+ onRun={runAction}+ runPending={runConfigPending}onChange={onInventoryChange}- onOpenSettings={onOpenSettings}/>) : (<DownloadSection@@ -758,16 +704,11 @@ export const ModelInspector = memo(function ModelInspector({mediaRuntime={runsOnMediaRuntime}repoId={model.isLocal ? (model.hubRepoId ?? model.id) : model.id}isGguf={model.isGguf}- isDownloaded={model.isDownloaded}- isPartial={model.isPartial ?? false}- partialTransport={model.partialTransport ?? null}- partialResumable={model.partialResumable === true}+ {...downloadState}modelFormat={model.modelFormat}- canRun={canRunModel}isActive={isActive}activeQuant={isActive ? (activeGgufVariant ?? null) : null}preferredGgufFile={preferredGgufFile}-preferredGgufFileIntent={preferredGgufFileIntent}isLoadingThisModel={isLoadingThisModel}gpuGb={gpuGb}@@ -775,12 +716,8 @@ export const ModelInspector = memo(function ModelInspector({systemRamGb={systemRamGb}cachePath={model.path}knownBytes={model.cachedBytes}- onLoad={model.isLocal ? onLoadLocal : onLoad}- onUseInChat={onUseInChat}- onEject={onEject}- onTrain={- model.isDownloaded && canTrainModel ? onTrain : undefined- }+ onRun={runAction}+ runPending={runConfigPending}onChange={onInventoryChange}/>)}diff --git a/studio/frontend/src/features/hub/catalog/models-catalog-lists.tsx b/studio/frontend/src/features/hub/catalog/models-catalog-lists.tsxindex e4402ca1145..2219e5daf7e 100644--- a/studio/frontend/src/features/hub/catalog/models-catalog-lists.tsx+++ b/studio/frontend/src/features/hub/catalog/models-catalog-lists.tsx@@ -267,15 +267,12 @@ export function DownloadedList({onClearFilters,scrollElement,columns = 1,- activeCheckpoint,- activeGgufVariant,isDataset,inventoryTokens,deviceType,compact = false,sort,onInventoryChange,- onOpenModelSettings,}: {cachedRows: CachedInventoryRow[];localRows: LocalInventoryRow[];@@ -288,8 +285,6 @@ export function DownloadedList({onClearFilters?: () => void;scrollElement: HTMLDivElement | null;columns?: number;- activeCheckpoint: string | null;- activeGgufVariant: string | null;isDataset: boolean;inventoryTokens: readonly string[];deviceType: string | null;@@ -297,7 +292,6 @@ export function DownloadedList({compact?: boolean;sort: InventorySort;onInventoryChange?: () => void;- onOpenModelSettings?: (row: CachedInventoryRow | LocalInventoryRow) => void;}) {// Pinned repos surface first regardless of the active sort, which still orders within groups.const pinnedIds = usePinnedModelsStore((s) => s.pinned);@@ -400,15 +394,12 @@ export function DownloadedList({<InventoryRowrow={item.row}selected={selectedId === item.row.id}- activeCheckpoint={activeCheckpoint}- activeGgufVariant={activeGgufVariant}isDataset={isDataset}dimmed={!inventoryRowMatches(item.row, inventoryTokens)}deviceType={deviceType}compact={compact}onSelect={onSelect}onChange={onInventoryChange}- onOpenSettings={onOpenModelSettings}/>);diff --git a/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx b/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsxindex cfa37450d0d..7ae5b1c319d 100644--- a/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx+++ b/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx@@ -21,7 +21,6 @@ import {ggufVariantDisplayLabel,useHfTokenStore,} from "@/features/hub";-import { modelIdsMatch } from "../lib/model-identity";import {ModelRowMenu,pinKey,@@ -241,7 +240,6 @@ export function StatChip({function CatalogRow({selected,- active,onClick,tooltip,label,@@ -249,7 +247,6 @@ function CatalogRow({variant = "flat",}: {selected: boolean;- active?: boolean;tooltip?: ReactNode;onClick: () => void;label: string;@@ -262,7 +259,6 @@ function CatalogRow({const button = (<divdata-selected={selected || undefined}- data-active={active || undefined}onPointerEnter={arm}onFocusCapture={arm}className={cn(@@ -423,14 +419,12 @@ export function buildRowStatusTooltip({export const DiscoverModelRow = memo(function DiscoverModelRow({row,selected,- active,deviceType,isDataset,onSelect,}: {row: DiscoverRow;selected: boolean;- active: boolean;deviceType: string | null;isDataset: boolean;onSelect: (id: string) => void;@@ -467,7 +461,6 @@ export const DiscoverModelRow = memo(function DiscoverModelRow({return (<CatalogRowselected={selected}- active={active}tooltip={tooltip}label={row.repo}onClick={handleClick}@@ -538,47 +531,18 @@ export const DiscoverModelRow = memo(function DiscoverModelRow({);});-function cachedRowActive(- row: CachedInventoryRow,- activeCheckpoint: string | null,- activeGgufVariant: string | null,-): boolean {- if (!modelIdsMatch(activeCheckpoint, row.loadId)) return false;- if (row.modelFormat === "gguf") {- return row.capabilities.requiresVariant ? activeGgufVariant !== null : true;- }- return activeGgufVariant === null;-}--function localRowActive(- row: LocalInventoryRow,- activeCheckpoint: string | null,- activeGgufVariant: string | null,-): boolean {- if (!modelIdsMatch(activeCheckpoint, row.loadId)) return false;- if (row.modelFormat === "gguf") {- return row.capabilities.requiresVariant ? activeGgufVariant !== null : true;- }- return activeGgufVariant === null;-}-export const InventoryRow = memo(function InventoryRow({row,selected,- activeCheckpoint,- activeGgufVariant,isDataset,dimmed,deviceType,compact = false,onSelect,onChange,- onOpenSettings,}: {row: CachedInventoryRow | LocalInventoryRow;selected: boolean;- activeCheckpoint: string | null;- activeGgufVariant: string | null;isDataset: boolean;dimmed: boolean;deviceType: string | null;@@ -586,8 +550,6 @@ export const InventoryRow = memo(function InventoryRow({compact?: boolean;onSelect: (id: string) => void;onChange?: () => void;- /** Open this model's settings page. Omitted for datasets. */- onOpenSettings?: (row: CachedInventoryRow | LocalInventoryRow) => void;}) {const rowModelId =row.kind === "cache"@@ -616,10 +578,6 @@ export const InventoryRow = memo(function InventoryRow({deviceType,]);const handleClick = useCallback(() => onSelect(row.id), [onSelect, row.id]);- const active =- row.kind === "cache"- ? cachedRowActive(row, activeCheckpoint, activeGgufVariant)- : localRowActive(row, activeCheckpoint, activeGgufVariant);const title = row.kind === "cache" ? row.repo : row.title;const subLabel = row.owner;@@ -735,18 +693,13 @@ export const InventoryRow = memo(function InventoryRow({const rowPinned =cacheDeletableRepoId != null &&pinnedKeys.includes(pinKey(cacheDeletableRepoId));- // Settings applies to any downloaded model, not just deletable ones, so the menu renders- // when either action applies. `deletableRepoId` keeps the delete closures' narrowing.- const settingsAction =- !isDataset && onOpenSettings ? { onOpen: () => onOpenSettings(row) } : undefined;const deletableRepoId = canDelete ? cacheDeletableRepoId : null;const deleteAction =- deletableRepoId || settingsAction ? (+ deletableRepoId ? (<ModelRowMenuariaLabel={`More options for ${deletableRepoId ?? rowModelId}`}buttonClassName="pointer-events-auto hub-modal-pe-guard size-8 opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100 [@media(pointer:coarse)]:opacity-100"iconClassName="size-4"- settings={settingsAction}pin={isDataset || !deletableRepoId? undefined@@ -811,7 +764,6 @@ export const InventoryRow = memo(function InventoryRow({<CatalogRowvariant="flat"selected={selected}- active={active}tooltip={tooltip}label={title}onClick={handleClick}@@ -882,7 +834,6 @@ export const InventoryRow = memo(function InventoryRow({<CatalogRowvariant="card"selected={selected}- active={active}tooltip={tooltip}label={title}onClick={handleClick}diff --git a/studio/frontend/src/features/hub/catalog/models-catalog.tsx b/studio/frontend/src/features/hub/catalog/models-catalog.tsxindex 0d94d335ddc..2913cad48a2 100644--- a/studio/frontend/src/features/hub/catalog/models-catalog.tsx+++ b/studio/frontend/src/features/hub/catalog/models-catalog.tsx@@ -18,7 +18,6 @@ import {import type {CachedInventoryRow,DiscoverRow,- InventoryRow,LocalInventoryRow,ModelsTab,} from "../types";@@ -46,8 +45,6 @@ export interface ModelsCatalogState {inventoryError: boolean;inventoryWarning: boolean;query: string;- activeCheckpoint: string | null;- activeGgufVariant: string | null;searchError: string | null;searchFailure?: HubFailure | null;online: boolean;@@ -74,7 +71,6 @@ export interface ModelsCatalogHandlers {onRetry: () => void;onInventoryChange?: () => void;onSwitchDevice?: () => void;- onOpenModelSettings?: (row: InventoryRow) => void;}function assignRef<T>(ref: RefObject<T | null>, value: T | null) {@@ -113,8 +109,6 @@ export const ModelsCatalog = memo(function ModelsCatalog({inventoryError,inventoryWarning,query,- activeCheckpoint,- activeGgufVariant,searchError,searchFailure,online,@@ -134,7 +128,6 @@ export const ModelsCatalog = memo(function ModelsCatalog({onRetry,onInventoryChange,onSwitchDevice,- onOpenModelSettings,} = handlers;const [scrolled, setScrolled] = useState(false);const [streamingActive, setStreamingActive] = useState(false);@@ -476,8 +469,6 @@ export const ModelsCatalog = memo(function ModelsCatalog({typeFilterActive={typeFilterActive}onClearFilters={onClearFilters}scrollElement={downloadedScrollEl}- activeCheckpoint={activeCheckpoint}- activeGgufVariant={activeGgufVariant}isDataset={isDataset}inventoryTokens={inventoryTokens}deviceType={deviceType}@@ -485,7 +476,6 @@ export const ModelsCatalog = memo(function ModelsCatalog({columns={discoverView === "two" ? 2 : 1}sort={inventorySort}onInventoryChange={onInventoryChange}- onOpenModelSettings={onOpenModelSettings}/></div>) : (diff --git a/studio/frontend/src/features/hub/catalog/models-header.tsx b/studio/frontend/src/features/hub/catalog/models-header.tsxindex 09b7b85471b..47798d0501f 100644--- a/studio/frontend/src/features/hub/catalog/models-header.tsx+++ b/studio/frontend/src/features/hub/catalog/models-header.tsx@@ -1,11 +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 {- Tooltip,- TooltipContent,- TooltipTrigger,-} from "@/components/ui/tooltip";import { useSettingsDialogStore } from "@/features/settings";import {ChipIcon,@@ -13,7 +8,6 @@ import {Database02Icon,PackageIcon,RamMemoryIcon,- RemoveCircleIcon,} from "@hugeicons/core-free-icons";import type { IconSvgElement } from "@hugeicons/react";import { HugeiconsIcon } from "@hugeicons/react";@@ -47,10 +41,7 @@ export function ModelsHeader({gpuSharedLabel,ramLabel,coreLabel,- activeCheckpoint,- activeGgufVariant,onTitleClick,- onEject,}: {cachedCount: number;localCount: number;@@ -59,10 +50,7 @@ export function ModelsHeader({gpuSharedLabel: string | null;ramLabel: string;coreLabel: string;- activeCheckpoint: string | null;- activeGgufVariant: string | null;onTitleClick: () => void;- onEject: () => void;}) {const openSettings = useSettingsDialogStore((s) => s.openDialog);const gpuMemoryValue = gpuSharedLabel@@ -75,8 +63,8 @@ export function ModelsHeader({onTitleClick={onTitleClick}subtitle={isDataset- ? "Discover, download, and train on datasets locally."- : "Discover, download, and run inference models locally."+ ? "Discover and download datasets locally."+ : "Discover and download models locally."}/>@@ -100,43 +88,6 @@ export function ModelsHeader({/><StatPill icon={RamMemoryIcon} label="RAM" value={ramLabel} /><StatPill icon={CpuIcon} label="CPU" value={coreLabel} />-- {activeCheckpoint && (- <div className="hub-tag-soft ml-1 inline-flex items-center gap-1.5 px-2 py-1 text-ui-11p5">- <span- className="size-1.5 rounded-full bg-emerald-500"- aria-hidden="true"- />- <Tooltip>- <TooltipTrigger asChild={true}>- <span className="max-w-[120px] cursor-default truncate font-medium text-primary">- {activeCheckpoint}- {activeGgufVariant ? ` · ${activeGgufVariant}` : ""}- </span>- </TooltipTrigger>- <TooltipContent- side="bottom"- sideOffset={6}- className="tooltip-compact"- >- {activeCheckpoint}- {activeGgufVariant ? ` · ${activeGgufVariant}` : ""}- </TooltipContent>- </Tooltip>- <button- type="button"- onClick={onEject}- className="-mr-0.5 ml-0.5 inline-flex cursor-pointer items-center gap-1 rounded-md px-1.5 text-ui-11 text-muted-foreground transition-colors hover:text-foreground"- >- <HugeiconsIcon- icon={RemoveCircleIcon}- strokeWidth={1.75}- className="size-3"- />- Eject- </button>- </div>- )}</div></header>);diff --git a/studio/frontend/src/features/hub/catalog/safetensors-download-card.tsx b/studio/frontend/src/features/hub/catalog/safetensors-download-card.tsxindex 2e709478b8d..d3685ca266b 100644--- a/studio/frontend/src/features/hub/catalog/safetensors-download-card.tsx+++ b/studio/frontend/src/features/hub/catalog/safetensors-download-card.tsx@@ -1,31 +1,18 @@// 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 { Spinner } from "@/components/ui/spinner";import {Tooltip,TooltipContent,TooltipTrigger,} from "@/components/ui/tooltip";-import { cn } from "@/lib/utils";-import {- Alert02Icon,- PlayIcon,- RemoveCircleIcon,-} from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";import { useEffect, useState } from "react";-import { TrainIcon } from "../components/train-icon";import { useHttpPartialsResumable, useRepoDownload } from "../download-manager";import { useOnlineStatus } from "../hooks/use-online-status";import { deleteCachedModel } from "../inventory";import type { ModelInventoryFormat } from "../inventory";import { fetchModelSize } from "../lib/dataset-size";import { formatBytes } from "../lib/format";-import {- HUB_NON_GGUF_RUN_ACTIONS_VISIBLE,- HUB_POST_DOWNLOAD_ACTIONS_VISIBLE,-} from "../lib/hub-feature-flags";import { fingerprintToken } from "../lib/token-fingerprint";import { useHfTokenStore } from "../stores/hf-token-store";import { DotTag } from "./dot-tag";@@ -34,6 +21,7 @@ import {DeleteConfirmDialog,DownloadActionButton,DownloadCard,+ ModelRunActionButton,} from "./download-card";import { QuantOptionsMenu } from "./gguf-download-card";import { useCardDelete } from "./use-card-delete";@@ -60,14 +48,12 @@ export function SafetensorsDownloadCard({partialTransport = null,partialResumable = false,modelFormat,- canRun = true,isActive,isLoadingThisModel,cachePath,knownBytes,- onLoad,- onEject,- onTrain,+ onRun,+ runPending = false,onChange,}: {repoId: string;@@ -76,17 +62,13 @@ export function SafetensorsDownloadCard({partialTransport?: string | null;partialResumable?: boolean;modelFormat?: ModelInventoryFormat | null;- canRun?: boolean;isActive: boolean;isLoadingThisModel: boolean;/** Owning cache dir, threaded into delete so it targets this copy. */cachePath?: string | null;knownBytes?: number | null;- onLoad: (opts: { ggufVariant?: string; expectedBytes?: number }) => void;- /** Accepted for API parity; the run bar ejects instead of opening chat. */- onUseInChat?: () => void;- onEject?: () => void;- onTrain?: () => void;+ onRun?: () => void;+ runPending?: boolean;onChange?: () => void;}) {const hfToken = useHfTokenStore((s) => s.token);@@ -167,16 +149,23 @@ export function SafetensorsDownloadCard({partialResumable,partialsResumable,});- const showActionPair = isDownloaded && !downloading && (canRun || !!onTrain);- const showUnavailableAction =- isDownloaded && !downloading && !canRun && !onTrain;- const trainActionVisible = !!onTrain && HUB_POST_DOWNLOAD_ACTIONS_VISIBLE;+ const showDownloadAction =+ !isDownloaded || downloading || cancelling || downloadAction.starting;+ const showRunAction =+ Boolean(onRun) &&+ isDownloaded &&+ !isPartial &&+ !downloading &&+ !cancelling &&+ !downloadAction.starting &&+ !isLoadingThisModel;const canDelete =(isDownloaded || isPartial) &&!downloading &&!repoPeerActive &&!isActive &&- !isLoadingThisModel;+ !isLoadingThisModel &&+ !runPending;// Same preview the On Device and picker rows run: without it this card kept an enabled Delete// for a companion base an installed image GGUF still needs, and the refusal arrived as a 400@@ -218,13 +207,8 @@ export function SafetensorsDownloadCard({><div className="relative flex h-9 min-w-0 flex-1 items-center pl-3 pr-2"><span className="flex items-center gap-1.5 text-ui-12 text-muted-foreground">- {(isActive || isDownloaded) && (- <DotTag- tone="success"- label={isActive ? "Loaded" : "On device"}- />- )}- {!isDownloaded && !isActive && isPartial && !downloading && (+ {isDownloaded && <DotTag tone="success" label="On device" />}+ {!isDownloaded && isPartial && !downloading && (<Tooltip><TooltipTrigger asChild={true}><span className="inline-flex">@@ -248,9 +232,8 @@ export function SafetensorsDownloadCard({)}</span><div className="ml-auto flex items-center gap-0.5">- {/* TODO: inference settings gear hidden for now, work on it in a future PR. */}{/* Same 3-dots menu as GGUF, at repo level (no quant); pinning is- omitted in the run bar. Managed HF-cache repos only. */}+ omitted here. Managed HF-cache repos only. */}{(isDownloaded || (isPartial && !downloading)) &&!/^([/\\~.]|[A-Za-z]:)/.test(repoId) && (<QuantOptionsMenu@@ -266,81 +249,12 @@ export function SafetensorsDownloadCard({)}</div></div>- {/* Info/actions hairline; dropped for the run action row (no divider before- Run, as in the GGUF card's Run CTA), restored when the Train pair ships. */}- {(!showActionPair || trainActionVisible) && <CardDivider />}- {showActionPair ? (- <div- className={cn(- "group/pair flex h-9 shrink-0 items-stretch gap-1.5",- !HUB_NON_GGUF_RUN_ACTIONS_VISIBLE && "hidden",- )}- >- {trainActionVisible && (- <button- type="button"- onClick={onTrain}- className="hub-action-btn w-24"- >- <HugeiconsIcon icon={TrainIcon} strokeWidth={1.75} />- Train- </button>- )}- <button- type="button"- disabled={isLoadingThisModel || !canRun}- onClick={() => {- if (!canRun) return;- if (isActive) {- onEject?.();- return;- }- onLoad({});- }}- className={cn(- isLoadingThisModel || isActive || !canRun- ? "hub-action-btn w-24"- : "hub-run-action-btn w-24",- (isLoadingThisModel || !canRun) && "opacity-70",- )}- >- {isLoadingThisModel ? (- <>- <Spinner />- Loading…- </>- ) : isActive ? (- <>- <HugeiconsIcon icon={RemoveCircleIcon} strokeWidth={1.75} />- Eject- </>- ) : canRun ? (- <>- <HugeiconsIcon icon={PlayIcon} strokeWidth={1.75} />- Run- </>- ) : (- <>- <HugeiconsIcon icon={Alert02Icon} strokeWidth={1.75} />- No run- </>- )}- </button>- </div>- ) : showUnavailableAction ? (- <button- type="button"- disabled={true}- className="hub-action-btn w-28 opacity-70"- >- <HugeiconsIcon icon={Alert02Icon} strokeWidth={1.75} />- Unavailable- </button>- ) : (+ {(showDownloadAction || showRunAction) && <CardDivider />}+ {showDownloadAction && (<DownloadActionButtondownloading={downloadAction.downloading}cancelling={downloadAction.cancelling}- loading={isLoadingThisModel || downloadAction.starting}+ loading={downloadAction.starting}isPartial={downloadAction.isPartial}partialResumable={downloadAction.partialResumable}stopMode={downloadAction.stopMode}@@ -350,6 +264,13 @@ export function SafetensorsDownloadCard({className={repoPeerActive ? "opacity-70" : undefined}/>)}+ {showRunAction && onRun && (+ <ModelRunActionButton+ label={`Configure and run ${repoId}`}+ onClick={onRun}+ loading={runPending}+ />+ )}</DownloadCard></div>);diff --git a/studio/frontend/src/features/hub/hooks/use-selected-model-view.ts b/studio/frontend/src/features/hub/hooks/use-selected-model-view.tsindex 5b9c582f1d1..68b88a29edc 100644--- a/studio/frontend/src/features/hub/hooks/use-selected-model-view.ts+++ b/studio/frontend/src/features/hub/hooks/use-selected-model-view.ts@@ -12,7 +12,6 @@ import type {CachedInventoryRow,DiscoverRow,LocalInventoryRow,- SelectedResourceRef,SelectedModelView,} from "../types";@@ -27,54 +26,6 @@ function detectViewCapabilities(return detectCapabilities(tags, pipelineTag, modelId);}-function cachedResource(row: CachedInventoryRow): SelectedResourceRef {- return {- repoId: row.repoId,- localPath: row.cachePath ?? null,- source: "hub_cache",- cacheState: row.partial ? "partial" : "cached",- runId: row.loadId,- trainId: row.loadId,- };-}--function localResource(- row: LocalInventoryRow,- repoId: string | null = row.repoId,-): SelectedResourceRef {- const cacheState = row.partial- ? "partial"- : row.source === "hf_cache"- ? "cached"- : "local";- const id =- row.source === "hf_cache" &&- row.activeCache !== false &&- repoId &&- !row.partial- ? repoId- : row.loadId;- return {- repoId,- localPath: row.path,- source: row.source,- cacheState,- runId: id,- trainId: id,- };-}--function remoteResource(row: DiscoverRow): SelectedResourceRef {- return {- repoId: row.result.id,- localPath: null,- source: "huggingface",- cacheState: row.isPartialOnDevice ? "partial" : "remote",- runId: row.result.id,- trainId: row.result.id,- };-}-function localFormatLabel(row: LocalInventoryRow): string {if (row.modelFormat === "gguf") return "local GGUF";if (row.modelFormat === "adapter") return "local adapter";@@ -103,14 +54,10 @@ export function useSelectedModelView({selectedLocalRow &&selectedLocalRow.source !== "hf_cache") {- const resource = localResource(- selectedLocalRow,- selectedDiscoverRow.result.id,- );return {- id: resource.runId,+ id: selectedLocalRow.loadId,+ loadId: selectedLocalRow.loadId,kind: "local",- resource,displayId: selectedDiscoverRow.id,hubRepoId: selectedDiscoverRow.result.id,owner: selectedDiscoverRow.owner,@@ -136,10 +83,10 @@ export function useSelectedModelView({: null,baseModelHubId: selectedDiscoverRow.result.baseModel ?? null,isDownloaded: !selectedLocalRow.partial,+ runtimeCanChat: selectedLocalRow.capabilities.canChat,isPartial: selectedLocalRow.partial ?? false,partialTransport: selectedLocalRow.partialTransport ?? null,partialResumable: selectedLocalRow.partialResumable === true,- runtimeCapabilities: selectedLocalRow.capabilities,capabilities: selectedDiscoverRow.capabilities,license: detectLicense(selectedDiscoverRow.result.tags),pipelineTag: selectedDiscoverRow.result.pipelineTag,@@ -161,14 +108,14 @@ export function useSelectedModelView({const onDevicePath =selectedCachedRow?.cachePath ?? selectedLocalRow?.path ?? null;- const resource = selectedCachedRow- ? cachedResource(selectedCachedRow)+ const isResolvedPartial = selectedCachedRow+ ? Boolean(selectedCachedRow.partial): selectedLocalRow?.source === "hf_cache"- ? localResource(selectedLocalRow, selectedDiscoverRow.result.id)- : remoteResource(selectedDiscoverRow);- const isResolvedPartial = resource.cacheState === "partial";- const isResolvedOnDevice =- resource.cacheState === "cached" || resource.cacheState === "local";+ ? Boolean(selectedLocalRow.partial)+ : selectedDiscoverRow.isPartialOnDevice;+ const isResolvedOnDevice = selectedCachedRow+ ? !selectedCachedRow.partial+ : selectedLocalRow?.source === "hf_cache" && !selectedLocalRow.partial;const resolvedModelFormat =selectedCachedRow?.modelFormat ??(selectedLocalRow?.modelFormat &&@@ -179,8 +126,8 @@ export function useSelectedModelView({: null);return {id: selectedDiscoverRow.id,+ loadId: selectedCachedRow?.loadId ?? selectedLocalRow?.loadId ?? null,kind: "discover",- resource,displayId: selectedDiscoverRow.id,hubRepoId: selectedDiscoverRow.result.id,owner: selectedDiscoverRow.owner,@@ -208,6 +155,10 @@ export function useSelectedModelView({: null,baseModelHubId: selectedDiscoverRow.result.baseModel ?? null,isDownloaded: isResolvedOnDevice,+ runtimeCanChat:+ selectedCachedRow?.capabilities.canChat ??+ selectedLocalRow?.capabilities.canChat ??+ false,isPartial: isResolvedPartial,partialTransport:selectedCachedRow?.partialTransport ??@@ -215,8 +166,6 @@ export function useSelectedModelView({null,partialResumable:(selectedCachedRow ?? selectedLocalRow)?.partialResumable === true,- runtimeCapabilities:- selectedCachedRow?.capabilities ?? selectedLocalRow?.capabilities,capabilities: selectedDiscoverRow.capabilities,license: detectLicense(selectedDiscoverRow.result.tags),pipelineTag: selectedDiscoverRow.result.pipelineTag,@@ -241,7 +190,6 @@ export function useSelectedModelView({}if (selectedCachedRow) {- const resource = cachedResource(selectedCachedRow);const cachedSummary = isDatasetMode? "Cached dataset, ready to use.": selectedCachedRow.isGguf@@ -263,8 +211,8 @@ export function useSelectedModelView({const mergedBaseModel = selectedHfResult?.baseModel ?? null;return {id: selectedCachedRow.repoId,+ loadId: selectedCachedRow.loadId,kind: "cache",- resource,displayId: selectedCachedRow.repoId,hubRepoId: selectedCachedRow.repoId,owner: selectedCachedRow.owner,@@ -282,10 +230,10 @@ export function useSelectedModelView({baseModelSource: mergedBaseModel ? "huggingface" : null,baseModelHubId: mergedBaseModel,isDownloaded: !selectedCachedRow.partial,+ runtimeCanChat: selectedCachedRow.capabilities.canChat,isPartial: selectedCachedRow.partial ?? false,partialTransport: selectedCachedRow.partialTransport ?? null,partialResumable: selectedCachedRow.partialResumable === true,- runtimeCapabilities: selectedCachedRow.capabilities,capabilities: detectViewCapabilities(mergedTags,mergedPipelineTag,@@ -315,7 +263,6 @@ export function useSelectedModelView({if (selectedLocalRow) {const localHubRepoId =selectedLocalRow.source === "hf_cache" ? selectedLocalRow.repoId : null;- const resource = localResource(selectedLocalRow, localHubRepoId);const localDisplayId = selectedLocalRow.repoId ?? selectedLocalRow.loadId;const isPartialHubCache =selectedLocalRow.source === "hf_cache" &&@@ -343,8 +290,8 @@ export function useSelectedModelView({if (isPartialHubCache && selectedLocalRow.repoId) {return {id: selectedLocalRow.repoId,+ loadId: selectedLocalRow.loadId,kind: "cache",- resource,displayId: selectedLocalRow.repoId,hubRepoId: selectedLocalRow.repoId,owner: selectedLocalRow.owner,@@ -359,10 +306,10 @@ export function useSelectedModelView({requiresVariant: selectedLocalRow.capabilities.requiresVariant,modelFormat: selectedLocalRow.modelFormat,isDownloaded: false,+ runtimeCanChat: selectedLocalRow.capabilities.canChat,isPartial: true,partialTransport: selectedLocalRow.partialTransport ?? null,partialResumable: selectedLocalRow.partialResumable === true,- runtimeCapabilities: selectedLocalRow.capabilities,capabilities: detectViewCapabilities(mergedTags,mergedPipelineTag,@@ -392,8 +339,8 @@ export function useSelectedModelView({return {id: selectedLocalRow.loadId,+ loadId: selectedLocalRow.loadId,kind: "local",- resource,displayId: localDisplayId,hubRepoId: localHubRepoId,owner: selectedLocalRow.owner,@@ -415,7 +362,7 @@ export function useSelectedModelView({adapterType: selectedLocalRow.adapterType ?? null,trainingMethod: selectedLocalRow.trainingMethod ?? null,isDownloaded: true,- runtimeCapabilities: selectedLocalRow.capabilities,+ runtimeCanChat: selectedLocalRow.capabilities.canChat,capabilities: detectViewCapabilities(mergedTags,mergedPipelineTag,diff --git a/studio/frontend/src/features/hub/hub-page.tsx b/studio/frontend/src/features/hub/hub-page.tsxindex ee382baace6..9b681bdc591 100644--- a/studio/frontend/src/features/hub/hub-page.tsx+++ b/studio/frontend/src/features/hub/hub-page.tsx@@ -4,35 +4,28 @@import { usePlatformStore } from "@/config/env";import {applyActiveModelStatusToStore,+ clearNewChatDraft,getInferenceStatus,isExternalModelId,isSpeechOnlyStatus,- listGgufVariants,resolveInferenceCheckpointId,- useChatModelRuntime,useChatRuntimeStore,} from "@/features/chat";-import { useOnlineStatus } from "@/features/hub/hooks/use-online-status";import { useHubInfiniteScroll } from "@/features/hub";+import { useOnlineStatus } from "@/features/hub/hooks/use-online-status";import {- type ModelPickTarget,- type PerModelConfig,- adoptLegacyConfigKey,- applyModelLoadConfigToRuntime,- applyPerModelConfigToRuntime,- currentRuntimePerModelConfig,+ clearModelConfigHandoff,+ createModelConfigHandoffRequestId,hfModelFitsDevice,loadScopedGpu,- resolveInitialConfig,- useActiveModelConfig,+ requestModelConfigHandoff,} from "@/features/model-picker";import { loadOpenAIAutoSwitchSettings } from "@/features/settings";-import { taskForMediaPick } from "@/features/model-picker/components/model-selector/audio-picker-policy";-import { diffusionRouteSearch } from "@/lib/diffusion-route-search";import { useDebouncedValue } from "@/hooks/use-debounced-value";import { useGpuInfo, useInferenceGpuInfo } from "@/hooks/use-gpu-info";import { useVramBudgetFraction } from "@/hooks/use-vram-budget-fraction";-import { toast } from "@/lib/toast";+import { diffusionRouteSearch } from "@/lib/diffusion-route-search";+import { subscribeModelLifecycle } from "@/lib/model-lifecycle-events";import { cn } from "@/lib/utils";import { useNavigate, useSearch } from "@tanstack/react-router";import {@@ -43,10 +36,11 @@ import {useRef,useState,} from "react";+import { toast } from "sonner";import { ExternalLinkConfirmDialog } from "./catalog/external-link-confirm-dialog";+import { FreeUpSpaceDialog } from "./catalog/free-up-space-dialog";import { HubDetailView } from "./catalog/hub-detail-view";import { HubFeed } from "./catalog/hub-feed";-import { HubModelSettingsView } from "./catalog/hub-model-settings-view";import { HubTopBar } from "./catalog/hub-top-bar";import {ModelsCatalog,@@ -64,7 +58,6 @@ import {ResultListHeader,} from "./catalog/models-table";import { ModelsToolbar } from "./catalog/models-toolbar";-import { FreeUpSpaceDialog } from "./catalog/free-up-space-dialog";import { OnDeviceFoldersDialog } from "./catalog/on-device-folders-dialog";import { OwnerScopeToggle } from "./catalog/owner-scope-toggle";import { useDiscoverSearch } from "./hooks/use-discover-search";@@ -81,15 +74,7 @@ import { useHubModelVram } from "./hooks/use-hub-model-vram";import { useModelsSelection } from "./hooks/use-models-selection";import { resolveSelectionUrlSync } from "./lib/selection-resolution";import { useHubInventory } from "./inventory";-import { LOCAL_MODEL_SOURCE } from "./inventory/constants";-import { settingsGgufVariantForRow } from "./inventory/settings-identity";import { adoptResidentModelStatus } from "./lib/adopt-inference-status";-import { subscribeResidentStatusRefresh } from "./lib/resident-status-refresh";-import {- type RefreshSupersession,- registerRefresh,- supersedingRefresh,-} from "./lib/superseded-refresh";import {CHANNEL_TO_SECTION,type ChannelId,@@ -104,19 +89,25 @@ import {isHiddenModelId,} from "./lib/hidden-models";import { inventoryRowMatches, tokenizeQuery } from "./lib/inventory-search";-import { looksLikeLocalPath, routableToMediaPage } from "./lib/local-path";+import { routableToMediaPage } from "./lib/local-path";+import { residentModelIdMatches } from "./lib/model-identity";import {- ggufVariantsMatch,- modelIdsMatch,- residentModelIdMatches,-} from "./lib/model-identity";+ createHubModelConfigHandoff,+ type HubModelRunSelection,+} from "./lib/model-run-selection";import {type ModelTypeFilter,matchesModelType,} from "./lib/model-type-filter";import { resolveOwnerProviderLogo } from "./lib/provider-logos";-import { studioPageForTask } from "./lib/unsloth-support";+import { subscribeResidentStatusRefresh } from "./lib/resident-status-refresh";+import {+ type RefreshSupersession,+ registerRefresh,+ supersedingRefresh,+} from "./lib/superseded-refresh";import { fingerprintToken } from "./lib/token-fingerprint";+import { studioPageForTask } from "./lib/unsloth-support";import {buildDiscoverRows,detectResultFormat,@@ -135,30 +126,61 @@ import type {ModelsTab,ResourceTypeFilter,SelectedModelView,- SelectedResourceRef,} from "./types";-// What per-model settings are keyed by, which is not always what the loader is handed: a repo-// cached outside the active HF cache loads by snapshot path while the picker keys it by repo-// id. The row decides that, not the view it is shown in; `hub_cache` marks exactly those.-function modelConfigIdentity(- kind: SelectedModelView["kind"],- resource: SelectedResourceRef,-): string {- if (kind !== "cache" && resource.source !== "hub_cache") {- return resource.runId;- }- return resource.repoId ?? resource.runId;-}-const MODELS_TAB_STORAGE_KEY = "unsloth.hub.modelsTab";const ALL_MODELS_VIEW_STORAGE_KEY = "unsloth.hub.allModelsView";const INVENTORY_SORT_STORAGE_KEY = "unsloth.hub.inventorySort";const OWNER_SCOPE_STORAGE_KEY = "unsloth.hub.ownerScope";+const RUN_CONFIG_REFRESH_TIMEOUT_MS = 5_000;// Iconless models (no provider logo, e.g. Ornith, Inkling) show once they clear this many likes.const MIN_ICONLESS_MODEL_LIKES = 30;+async function waitForRunConfigRefresh(+ refresh: Promise<void>,+ signal: AbortSignal,+): Promise<void> {+ if (signal.aborted) return;+ let timeoutId: number | undefined;+ let onAbort: (() => void) | undefined;+ try {+ await Promise.race([+ refresh,+ new Promise<void>((resolve) => {+ timeoutId = window.setTimeout(resolve, RUN_CONFIG_REFRESH_TIMEOUT_MS);+ }),+ new Promise<void>((resolve) => {+ onAbort = resolve;+ signal.addEventListener("abort", onAbort, { once: true });+ }),+ ]);+ } finally {+ if (timeoutId !== undefined) window.clearTimeout(timeoutId);+ if (onAbort) signal.removeEventListener("abort", onAbort);+ }+}++class RunConfigOpenCoordinator {+ private active: AbortController | null = null;++ begin(): AbortController {+ this.cancel();+ const controller = new AbortController();+ this.active = controller;+ return controller;+ }++ cancel(): void {+ this.active?.abort();+ this.active = null;+ }++ finish(controller: AbortController): void {+ if (this.active === controller) this.active = null;+ }+}+/** Discover browsing scope: the whole Hub (default) or only the unsloth org. */export type OwnerScope = "unsloth" | "all";@@ -191,8 +213,6 @@ const FEED_LIST_CHANNEL_ID: ChannelId = "unsloth-latest";type DiscoverMode = "feed" | "channel-list" | "search";-type ModelLoadOptions = { ggufVariant?: string; expectedBytes?: number };-// Focused list heading stays "Models"/"Datasets" regardless of filters; only search relabels it.function buildFocusedHeading({query,@@ -365,10 +385,20 @@ function selectedRepoMatchesRuntime(ggufVariant: string | null,): boolean {if (!selectedModel || !runtimeId) return false;- if (!modelIdsMatch(runtimeId, selectedModel.resource.runId)) return false;+ if (+ !residentModelIdMatches(+ runtimeId,+ selectedModel.id,+ selectedModel.loadId,+ selectedModel.hubRepoId,+ selectedModel.path,+ selectedModel.displayId,+ )+ ) {+ return false;+ }if (selectedModel.modelFormat === "gguf") {- const localPath =- selectedModel.resource.localPath ?? selectedModel.path ?? "";+ const localPath = selectedModel.path ?? "";return ggufVariant !== null || localPath.toLowerCase().endsWith(".gguf");}return ggufVariant === null;@@ -413,41 +443,23 @@ export function ModelsPage() {const preferredGgufFile = hubSearch.file ?? null;const preferredGgufFileIntent = hubSearch.intent ?? 0;- const { selectModel, loadingModel, loadProgress, ejectModel } =- useChatModelRuntime();const checkpoint = useChatRuntimeStore((s) => s.params.checkpoint);const residentCheckpoint = useChatRuntimeStore((s) => s.residentCheckpoint);- // Resident, not merely picked. An image or video load evicts the chat model- // and leaves the pick alone, so the cards kept saying "Loaded" for weights the- // backend had already released. `undefined` is "no status read yet", which- // stays as it was rather than flashing "On device" on every launch.const activeCheckpoint =checkpoint && !isExternalModelId(checkpoint) && residentCheckpoint !== null? checkpoint: null;const activeGgufVariant = useChatRuntimeStore((s) => s.activeGgufVariant);- const activeLoadedContextLength = useChatRuntimeStore(- (s) => s.loadedContextLength,- );+ const loadingModel = useChatRuntimeStore((s) => s.loadingModelPick);const [initialResidentStatusSettled, setInitialResidentStatusSettled] =useState(false);- // Live settings of the loaded model, so its page shows what it is running with.- const { config: activeModelConfig } = useActiveModelConfig();- // Shared with the chat model selector: list only models sized for this device.const fitOnDeviceOnly = useChatRuntimeStore((s) => s.fitOnDeviceOnly);const setFitOnDeviceOnly = useChatRuntimeStore((s) => s.setFitOnDeviceOnly);- // Drops a response that lands after a newer read started, or after unmount.const residentStatusSeq = useRef(0);- // The newest read started, so a dropped response can resolve with that instead of nothing. The- // settings handlers' own guard counts settings opens only: a focus refresh supersedes without bumping.const residentStatusSupersession = useRef<RefreshSupersession>({latest: null,});- // /status cannot say whether an empty answer is an idle eviction that will reload or a real- // unload, and only this endpoint knows. Read alongside every status read rather than cached,- // since the idle timeout is editable while this page stays mounted. Last answer wins on- // failure, not the default: "disarmed" clears the checkpoint, so a blip would discard a selection.const idleUnloadArmed = useRef(false);const readIdleUnloadArmed = useCallback((): Promise<boolean> =>@@ -459,60 +471,61 @@ export function ModelsPage() {.catch(() => idleUnloadArmed.current),[],);- // Returns the read so a caller that needs the answer first can wait for it.- const refreshResidentModelStatus = useCallback((): Promise<void> => {- const seq = ++residentStatusSeq.current;- const read = Promise.all([getInferenceStatus(), readIdleUnloadArmed()])- .then(([status, idleUnloadArmed]) => {- // A newer read owns the store, so this writes nothing; resolving with the refresh that took- // it over keeps an awaiting caller off the pre-switch store the await was there to replace.- if (seq !== residentStatusSeq.current)- return supersedingRefresh(residentStatusSupersession.current, seq);- const store = useChatRuntimeStore.getState();- adoptResidentModelStatus(- {- // The loadable identifier: a GGUF off disk loads by path, and two files sharing a stem collapse.- // Null for a speech model: this page is the other writer of params.checkpoint,- // so adopting one here made it the chat model just as the mount sync did.- checkpointId: isSpeechOnlyStatus(status)- ? null- : resolveInferenceCheckpointId(status),- speechOnly: isSpeechOnlyStatus(status),- ggufVariant: status.gguf_variant ?? null,- },- {- checkpoint: store.params.checkpoint,- checkpointIsExternal: isExternalModelId(store.params.checkpoint),- activeGgufVariant: store.activeGgufVariant,- modelLoading: store.modelLoading,- idleUnloadArmed,- },- {- setCheckpoint: (checkpointId, ggufVariant) => {- store.setCheckpoint(checkpointId, ggufVariant);+ const refreshResidentModelStatus = useCallback(+ (+ { preserveIdleUnloaded = true }: {+ preserveIdleUnloaded?: boolean;+ } = {},+ ): Promise<void> => {+ const seq = ++residentStatusSeq.current;+ const read = Promise.all([getInferenceStatus(), readIdleUnloadArmed()])+ .then(([status, idleUnloadArmed]) => {+ if (seq !== residentStatusSeq.current)+ return supersedingRefresh(residentStatusSupersession.current, seq);+ const store = useChatRuntimeStore.getState();+ adoptResidentModelStatus(+ {+ // The loadable identifier: a GGUF off disk loads by path, and two files sharing a stem collapse.+ // Null for a speech model: this page is the other writer of params.checkpoint,+ // so adopting one here made it the chat model just as the mount sync did.+ checkpointId: isSpeechOnlyStatus(status)+ ? null+ : resolveInferenceCheckpointId(status),+ speechOnly: isSpeechOnlyStatus(status),+ ggufVariant: status.gguf_variant ?? null,},- clearCheckpoint: () => {- store.clearCheckpoint();+ {+ checkpoint: store.params.checkpoint,+ checkpointIsExternal: isExternalModelId(store.params.checkpoint),+ activeGgufVariant: store.activeGgufVariant,+ modelLoading: store.modelLoading,+ idleUnloadArmed: preserveIdleUnloaded && idleUnloadArmed,},- // The one entry point that has applied no status yet, so settings would read defaults.- applyStatus: (previous) => {- applyActiveModelStatusToStore(status, {- previousCheckpoint: previous.checkpoint ?? undefined,- previousGgufVariant: previous.ggufVariant,- adoptingExistingServerModel:- previous.checkpoint === null || previous.checkpoint === "",- });+ {+ setCheckpoint: (checkpointId, ggufVariant) => {+ store.setCheckpoint(checkpointId, ggufVariant);+ },+ clearCheckpoint: () => {+ store.clearCheckpoint();+ },+ applyStatus: (previous) => {+ applyActiveModelStatusToStore(status, {+ previousCheckpoint: previous.checkpoint ?? undefined,+ previousGgufVariant: previous.ggufVariant,+ adoptingExistingServerModel:+ previous.checkpoint === null || previous.checkpoint === "",+ });+ },},- },- );- })- .catch(() => undefined);- // In start order, synchronously with the sequence number, so a dropped response finds the newest read.- registerRefresh(residentStatusSupersession.current, seq, read);- return read;- }, [readIdleUnloadArmed]);-- // Mount, then whenever this tab could have missed an API-driven switch. Re-reading is safe.+ );+ })+ .catch(() => undefined);+ registerRefresh(residentStatusSupersession.current, seq, read);+ return read;+ },+ [readIdleUnloadArmed],+ );+useEffect(() => {let active = true;void refreshResidentModelStatus().finally(() => {@@ -523,12 +536,20 @@ export function ModelsPage() {);return () => {active = false;- // A response still in flight adopts nothing once the Hub is gone.residentStatusSeq.current += 1;unsubscribe();};}, [refreshResidentModelStatus]);+ useEffect(+ () =>+ subscribeModelLifecycle(({ runtime }) => {+ if (runtime === "chat" || runtime === "stt") return;+ void refreshResidentModelStatus({ preserveIdleUnloaded: false });+ }),+ [refreshResidentModelStatus],+ );+const { tab, setTab: setModelsTab } = useModelsTabState();const [query, setQuery] = useState("");const [sortBy, setSortBy] = useState<HfSortKey>(@@ -1184,17 +1205,31 @@ export function ModelsPage() {accessToken: apiHfToken,online,});+ const [runConfigOpenCoordinator] = useState(+ () => new RunConfigOpenCoordinator(),+ );+ const [runConfigOpening, setRunConfigOpening] = useState<{+ modelId: string;+ controller: AbortController;+ } | null>(null);+ useEffect(() => {+ return () => runConfigOpenCoordinator.cancel();+ }, [runConfigOpenCoordinator, selectedId]);const handleSelect = useCallback((id: string) => {+ runConfigOpenCoordinator.cancel();+ setRunConfigOpening(null);void navigate({to: "/hub",search: (prev) => ({ ...prev, model: id, file: undefined }),});},- [navigate],+ [navigate, runConfigOpenCoordinator],);const handleCloseDetail = useCallback(() => {+ runConfigOpenCoordinator.cancel();+ setRunConfigOpening(null);// From split view, "Back to Hub" returns to the main hub feed (not the filtered list): leave// split mode, reset discover state, and clear the inline preview and channel.if (allModelsView === "split") {@@ -1218,7 +1253,7 @@ export function ModelsPage() {to: "/hub",search: (prev) => ({ ...prev, model: undefined }),});- }, [navigate, allModelsView]);+ }, [navigate, allModelsView, runConfigOpenCoordinator]);const handleQueryChange = useCallback((next: string) => {if (next.trim() === "") {@@ -1340,7 +1375,14 @@ export function ModelsPage() {const isLoadingThisModel = useMemo(() => {if (!loadingModel || !selectedModel) return false;- return modelIdsMatch(loadingModel.id, selectedModel.resource.runId);+ return residentModelIdMatches(+ loadingModel.id,+ selectedModel.id,+ selectedModel.loadId,+ selectedModel.hubRepoId,+ selectedModel.path,+ selectedModel.displayId,+ );}, [loadingModel, selectedModel]);const { vramInfo, minMemory } = useHubModelVram(selectedModel, gpu);@@ -1360,322 +1402,6 @@ export function ModelsPage() {gpu.cpuCore > 0 && gpu.cpuThread > 0? `${gpu.cpuCore}/${gpu.cpuThread}`: "Unavailable";-- const openNewChat = useCallback(() => {- void navigate({ to: "/chat", search: { new: crypto.randomUUID() } });- }, [navigate]);- const runSelectedModel = useCallback(- (opts: ModelLoadOptions, isDownloaded: boolean) => {- if (!selectedModel) return;- const runId = selectedModel.resource.runId;- // An image / video model is run by its own page, not by chat: loading it here evicted- // the resident chat model for a llama.cpp load that could only fail. Same resolution- // and destination the chat picker uses, so both surfaces route a pick identically.- // `task` is not optional here: only CachedModelRepo carries pipelineTag, so every- // cached GGUF repo (the reported MiniMax-H3 case) reports its modality on `task`.- const mediaPage = studioPageForTask(- taskForMediaPick(selectedModel.pipelineTag, selectedModel.task) ?? undefined,- );- // The target pages read a routed `model` as a Hub id, so a runId that is a PATH would- // arrive as a repo that does not exist -- prefer the Hub id, which loads the same copy- // since the loader reuses whichever cache root holds it. That covers a filesystem row- // (left on today's route, and the backend preflight now refuses it by name) and a- // cached repo the inventory pinned to its snapshot directory, whose symlinked entries- // the pages' containment check rejects anyway.- const routeId = runId && !looksLikeLocalPath(runId) ? runId : selectedModel.hubRepoId;- if (- mediaPage &&- routableToMediaPage(selectedModel.kind, selectedModel.localSource) &&- routeId- ) {- void navigate({- to: `/${mediaPage}`,- // `quant` is consumed verbatim as a gguf filename, so a label rides `ggufQuant`.- search: diffusionRouteSearch(routeId, {- ggufVariant: opts.ggufVariant ?? null,- }),- });- return;- }- const configIdentity = modelConfigIdentity(- selectedModel.kind,- selectedModel.resource,- );- // A cached repo used to be keyed by its snapshot path (its runId); move that record over first.- adoptLegacyConfigKey(configIdentity, runId, opts.ggufVariant);- const resolvedConfig = resolveInitialConfig(- configIdentity,- opts.ggufVariant,- );- const rememberedConfig = resolvedConfig.remembered- ? resolvedConfig.config- : null;- const previousConfig = currentRuntimePerModelConfig({- includeMaxSeqLength: true,- });- const hasAppliedConfig = applyModelLoadConfigToRuntime(rememberedConfig);- void selectModel({- id: runId,- ggufVariant: opts.ggufVariant,- isDownloaded,- expectedBytes: opts.expectedBytes,- keepSpeculative: hasAppliedConfig,- throwOnError: true,- previousConfig,- // The runtime store is not enough: applyPerModelConfigToRuntime has no field- // for the launch flags, and /load only inherits them from the SAME resident- // model, so a cold launch or a switch from another model ran without the- // arguments this model was remembered with.- ...(rememberedConfig ? { config: rememberedConfig } : {}),- })- .then(() => {- // Read fresh: the load is async, so the checkpoint may have changed.- const store = useChatRuntimeStore.getState();- if (!modelIdsMatch(store.params.checkpoint, runId)) {- store.setCheckpoint(runId, opts.ggufVariant ?? null);- }- })- .catch(() => undefined);- openNewChat();- },- [navigate, openNewChat, selectModel, selectedModel],- );- const handleLoad = useCallback(- (opts: ModelLoadOptions) =>- runSelectedModel(opts, selectedModel?.isDownloaded ?? true),- [runSelectedModel, selectedModel],- );-- // Full-page per-model settings. Local state, not a URL param: a deep link would need the row re-resolved.- const [settingsTarget, setSettingsTarget] = useState<ModelPickTarget | null>(- null,- );- // Opening settings is where a stale read costs something: the editor is seeded once and Apply- // reloads with what it seeded. Resolving a target is openModelSettings' own read.- useEffect(() => {- if (settingsTarget) void refreshResidentModelStatus();- }, [settingsTarget, refreshResidentModelStatus]);- // Bumped per open so a slow lookup for an abandoned row cannot land on the chosen one.- const settingsOpenSeq = useRef(0);- const openModelSettings = useCallback(- async (row: CachedInventoryRow | LocalInventoryRow) => {- const openSeq = ++settingsOpenSeq.current;- // Before anything reads the store: the status effect watches settingsTarget. Every path out- // seeds the editor from the store and Apply reloads with that, so a stale read misconfigures.- await refreshResidentModelStatus();- if (settingsOpenSeq.current !== openSeq) return;- // loadId is what the loader accepts; repoId is only a display/API alias.- const id = row.loadId;- // Every name this row answers to.- const rowAliases =- row.kind === "local"- ? [id, row.repoId, row.path]- : [id, row.repoId, row.cachePath];- // Cached repo rows carry no quant, and a null variant keys the config to `repo::` while the loader reads `repo::Q4_K_M`.- let ggufVariant = settingsGgufVariantForRow(row);- if (!ggufVariant && row.isGguf && row.capabilities.requiresVariant) {- // A local row only carries a repo id inside the HF cache, so a plain folder of quants has- // none while still needing one; the listing scans a path in the same position.- const repoId =- row.kind === "cache" ? row.repoId : (row.repoId ?? row.path ?? null);- if (repoId) {- try {- const res = await listGgufVariants(repoId, hfApiToken(hfToken), {- preferLocalCache: true,- localPath:- row.kind === "local" ? row.path : (row.cachePath ?? null),- });- const downloaded = res.variants.filter((v) => v.downloaded);- // Re-read after this await too: the lookup hits the network, and a switch during it would- // leave the branch below on the displaced model's quant. Against the server, not the store:- // nothing pushes an API switch into this tab.- await refreshResidentModelStatus();- if (settingsOpenSeq.current !== openSeq) return;- const settled = useChatRuntimeStore.getState();- const settledCheckpoint =- settled.params.checkpoint &&- !isExternalModelId(settled.params.checkpoint)- ? settled.params.checkpoint- : null;- const settledIsActive = rowAliases.some((alias) =>- modelIdsMatch(alias, settledCheckpoint),- );- ggufVariant =- // Loaded quant, then repo default, then whatever is on disk, mirroring LocalOnDeviceCard.- (settledIsActive- ? downloaded.find((v) =>- ggufVariantsMatch(v.quant, settled.activeGgufVariant),- )?.quant- : undefined) ??- downloaded.find((v) =>- ggufVariantsMatch(v.quant, res.default_variant),- )?.quant ??- downloaded[0]?.quant ??- null;- } catch {- ggufVariant = null;- }- }- if (!ggufVariant) {- // A model needing a quant cannot be configured without one: the picker matches variants exactly.- toast.error("Couldn't determine which quant to configure.", {- description:- "Settings for this model are per quant. Check the connection or the model's cache, then try again.",- });- return;- }- }- // The lookup is async: without this, whichever call finished last would win.- if (settingsOpenSeq.current !== openSeq) {- return;- }- // A repo in a previous cache loads by snapshot path, so `id` ends in the revision hash.- const configId = row.kind === "cache" ? row.repoId : id;- const leaf = configId.split(/[\\/]/).filter(Boolean).pop() ?? configId;- setSettingsTarget({- id,- configId,- displayName: ggufVariant ? `${leaf} · ${ggufVariant}` : leaf,- ggufVariant,- isGguf: row.isGguf,- apiLoadable:- row.isGguf &&- (row.kind !== "local" || row.source !== LOCAL_MODEL_SOURCE.OLLAMA),- meta: {- source: "local",- isLora: row.modelFormat === "adapter",- ggufVariant: ggufVariant ?? undefined,- isGguf: row.isGguf,- // A partial opens settings too; claiming complete would skip download progress.- isDownloaded: !row.partial,- // Not on inventory rows; ModelConfigPage reads the GGUF header itself.- contextLength: null,- },- });- },- [activeCheckpoint, activeGgufVariant, hfToken, refreshResidentModelStatus],- );- // Applying loads the model with exactly these settings, already persisted by ModelConfigPage.- const runSettingsTarget = useCallback(- (config: PerModelConfig) => {- const target = settingsTarget;- if (!target) return;- const previousConfig = currentRuntimePerModelConfig({- includeMaxSeqLength: true,- });- applyPerModelConfigToRuntime(config);- setSettingsTarget(null);- void selectModel({- id: target.id,- source: "local",- ggufVariant: target.ggufVariant ?? undefined,- isGguf: target.isGguf,- // A partial row opens settings too; claiming complete would skip download progress.- isDownloaded: target.meta.isDownloaded,- isLora: target.meta.isLora,- keepSpeculative: true,- forceReload: true,- // The submitted config, not only its echo in the runtime store: the store- // does not carry llamaExtraArgs, so without this the load omits the field- // and the route keeps the resident server's old list. Applying an edit, or- // clearing the box, would then do nothing on this page.- config,- previousConfig,- }).catch(() => undefined);- },- [selectModel, settingsTarget],- );- const handleLoadLocal = useCallback(- (opts: ModelLoadOptions = {}) => runSelectedModel(opts, true),- [runSelectedModel],- );- const handleTrain = useCallback(() => {- // Hub → train integration ships in a later PR.- }, []);- // Opened from the on-device card, which passes in the quant it already resolved.- const openSelectedModelSettings = useCallback(- async (ggufVariant: string | null, quantIsUserPicked = false) => {- if (!selectedModel) return;- // Shared with openModelSettings: another row's pending lookup must not land here.- const openSeq = ++settingsOpenSeq.current;- // Unconditional, as in openModelSettings: the editor seeds from the store and Apply reloads it.- await refreshResidentModelStatus();- if (settingsOpenSeq.current !== openSeq) return;- let variant = ggufVariant;- // The card derived this quant from the store's active variant. A user-picked quant stands.- if (!quantIsUserPicked) {- const settled = useChatRuntimeStore.getState();- const settledCheckpoint =- settled.params.checkpoint &&- !isExternalModelId(settled.params.checkpoint)- ? settled.params.checkpoint- : null;- // Every name this model answers to, as the row menu path matches them.- const aliases = [- selectedModel.resource.runId,- selectedModel.resource.repoId,- selectedModel.resource.localPath,- ];- if (- settled.activeGgufVariant &&- aliases.some((alias) => modelIdsMatch(alias, settledCheckpoint))- ) {- variant = settled.activeGgufVariant;- }- }- // The card passes null while its lookup is pending or failed, so guard as openModelSettings does.- if (!variant && selectedModel.isGguf && selectedModel.requiresVariant) {- toast.error("Couldn't determine which quant to configure.", {- description:- "Settings for this model are per quant. Check the connection or the model's cache, then try again.",- });- return;- }- const id = selectedModel.resource.runId;- const configId = modelConfigIdentity(- selectedModel.kind,- selectedModel.resource,- );- // As in runSelectedModel: the editor seeds from this key, so the move must happen first.- adoptLegacyConfigKey(configId, id, variant);- const leaf = configId.split(/[\\/]/).filter(Boolean).pop() ?? configId;- setSettingsTarget({- id,- configId,- displayName: variant ? `${leaf} · ${variant}` : leaf,- ggufVariant: variant,- isGguf: selectedModel.isGguf,- apiLoadable:- selectedModel.isGguf &&- selectedModel.localSource !== LOCAL_MODEL_SOURCE.OLLAMA,- meta: {- source: "local",- isLora: selectedModel.modelFormat === "adapter",- ggufVariant: variant ?? undefined,- isGguf: selectedModel.isGguf,- isDownloaded: selectedModel.isDownloaded,- contextLength: null,- },- });- },- [selectedModel, refreshResidentModelStatus],- );- // Whether the settings page is open on the loaded model, so it can show the live launch config.- // A GGUF off disk loads by path but is reported by its public id, so the row's path and its- // settings identity are both offered as aliases; a loose .gguf carries no variant.- const settingsTargetIsStandaloneFile =- settingsTarget !== null &&- settingsTarget.ggufVariant == null &&- settingsTarget.id.toLowerCase().endsWith(".gguf");- const settingsTargetIsResident =- settingsTarget !== null &&- residentModelIdMatches(- activeCheckpoint,- settingsTarget.id,- settingsTarget.configId,- ) &&- (settingsTargetIsStandaloneFile ||- ggufVariantsMatch(activeGgufVariant, settingsTarget.ggufVariant));const handleSearchHub = useCallback((next: string) => {const trimmed = next.trim();@@ -1701,13 +1427,77 @@ export function ModelsPage() {},[navigate, setModelsTab, setOwnerScope],);+ const handleRun = useCallback(+ async (+ selection: HubModelRunSelection,+ mediaPage: ReturnType<typeof studioPageForTask>,+ ) => {+ if (!selectedModel) return;+ if (mediaPage) {+ runConfigOpenCoordinator.cancel();+ setRunConfigOpening(null);+ if (+ !selectedModel.hubRepoId ||+ !routableToMediaPage(selectedModel.kind, selectedModel.localSource)+ ) {+ return;+ }+ void navigate({+ to: `/${mediaPage}`,+ search: diffusionRouteSearch(selectedModel.hubRepoId, selection),+ });+ return;+ }+ const controller = runConfigOpenCoordinator.begin();+ setRunConfigOpening({ modelId: selectedModel.id, controller });+ try {+ await waitForRunConfigRefresh(+ refreshResidentModelStatus(),+ controller.signal,+ );+ if (controller.signal.aborted) return;+ const requestId = createModelConfigHandoffRequestId();+ const request = createHubModelConfigHandoff({+ requestId,+ model: selectedModel,+ selection,+ });+ if (!request) {+ toast.error("Couldn't open run settings.", {+ description:+ "The model or selected quantization is no longer available to run.",+ });+ return;+ }+ clearNewChatDraft();+ const chatRuntime = useChatRuntimeStore.getState();+ chatRuntime.setActiveThreadId(null);+ chatRuntime.setActiveProjectId(null);+ chatRuntime.setIncognito(false);+ requestModelConfigHandoff(request);+ void navigate({ to: "/chat", search: { new: requestId } }).catch(() => {+ clearModelConfigHandoff(requestId);+ });+ } finally {+ runConfigOpenCoordinator.finish(controller);+ setRunConfigOpening((current) =>+ current?.controller === controller ? null : current,+ );+ }+ },+ [+ navigate,+ refreshResidentModelStatus,+ runConfigOpenCoordinator,+ selectedModel,+ ],+ );const inspectorRuntime = useMemo(() => ({isActive,activeGgufVariant,isLoadingThisModel,- loadingPhase: loadProgress?.phase,minMemory,vramInfo,gpuGb: inferenceGpu.available ? inferenceGpu.memoryTotalGb : undefined,@@ -1721,7 +1511,6 @@ export function ModelsPage() {isActive,activeGgufVariant,isLoadingThisModel,- loadProgress?.phase,minMemory,vramInfo,inferenceGpu.available,@@ -1733,24 +1522,17 @@ export function ModelsPage() {const inspectorActions = useMemo(() => ({- onLoad: handleLoad,- onLoadLocal: handleLoadLocal,- onUseInChat: openNewChat,- onEject: () => void ejectModel(),- onTrain: handleTrain,onInventoryChange: refreshInventory,onSearchHub: handleSearchHub,- onOpenSettings: openSelectedModelSettings,+ onRun: handleRun,+ runConfigPending: runConfigOpening?.modelId === selectedModel?.id,}),[- handleLoad,- handleLoadLocal,- openNewChat,- ejectModel,- handleTrain,+ handleRun,handleSearchHub,refreshInventory,- openSelectedModelSettings,+ runConfigOpening,+ selectedModel?.id,],);@@ -1769,8 +1551,6 @@ export function ModelsPage() {inventoryError,inventoryWarning,query,- activeCheckpoint,- activeGgufVariant,searchError,searchFailure,online,@@ -1796,8 +1576,6 @@ export function ModelsPage() {inventoryError,inventoryWarning,query,- activeCheckpoint,- activeGgufVariant,searchError,searchFailure,online,@@ -1834,7 +1612,6 @@ export function ModelsPage() {onRetry: handleRetrySearch,onInventoryChange: refreshInventory,onSwitchDevice: handleSwitchDevice,- onOpenModelSettings: openModelSettings,}),[handleSelect,@@ -1843,7 +1620,6 @@ export function ModelsPage() {handleRetrySearch,refreshInventory,handleSwitchDevice,- openModelSettings,],);@@ -1984,8 +1760,8 @@ export function ModelsPage() {const detailOpen = urlModel !== null;const splitMode = allModelsView === "split";- // Unreachable under an opaque overlay: the detail view (full-page only) or settings.- const catalogCovered = (detailOpen && !splitMode) || settingsTarget !== null;+ // Unreachable under the full-page detail overlay.+ const catalogCovered = detailOpen && !splitMode;return (<div className="hub-page flex min-h-0 min-w-0 flex-1 basis-0 flex-col overflow-hidden bg-background">@@ -1998,10 +1774,7 @@ export function ModelsPage() {gpuSharedLabel={gpuSharedLabel}ramLabel={ramLabel}coreLabel={coreLabel}- activeCheckpoint={activeCheckpoint}- activeGgufVariant={activeGgufVariant}onTitleClick={handleResetToDiscover}- onEject={() => void ejectModel()}/><ModelsToolbartab={tab}@@ -2064,7 +1837,6 @@ export function ModelsPage() {detailOpen ? (<divclassName="hub-canvas z-20 flex min-h-0 flex-col max-lg:absolute max-lg:inset-0 lg:relative lg:min-w-0 lg:flex-1"- inert={settingsTarget !== null || undefined}><HubDetailViewmodel={selectedModel}@@ -2089,7 +1861,6 @@ export function ModelsPage() {detailOpen && (<divclassName="hub-canvas absolute inset-0 z-20 flex min-h-0 flex-col"- inert={settingsTarget !== null || undefined}><HubDetailViewmodel={selectedModel}@@ -2106,22 +1877,6 @@ export function ModelsPage() {</div>))}-- {/* Above the detail overlay (z-30), so settings do not stack behind a preview. */}- {settingsTarget && (- <div className="hub-canvas absolute inset-0 z-30 flex min-h-0 flex-col">- <HubModelSettingsView- target={settingsTarget}- loadedConfig={settingsTargetIsResident ? activeModelConfig : null}- loadedContextLength={- settingsTargetIsResident ? activeLoadedContextLength : null- }- onBack={() => setSettingsTarget(null)}- onRun={runSettingsTarget}- compact={splitMode}- />- </div>- )}</div><OnDeviceFoldersDialogdiff --git a/studio/frontend/src/features/hub/hub.css b/studio/frontend/src/features/hub/hub.cssindex 7c2e8966664..b05394d52fe 100644--- a/studio/frontend/src/features/hub/hub.css+++ b/studio/frontend/src/features/hub/hub.css@@ -48,8 +48,8 @@}@layer base {- /* Shared measure for every centered Hub column (top bar, catalog, detail,- settings). Container-relative, so the column tracks the width actually+ /* Shared measure for every centered Hub column (top bar, catalog, detail).+ Container-relative, so the column tracks the width actuallyavailable instead of pinning to 1100px and leaving wide empty gutters.The floor keeps the old measure on ~1280px laptops, the cap stops rowsstretching on ultrawides, and `max-width` never forces overflow, so the@@ -594,30 +594,17 @@box-shadow: none;}- /* On-device rows reuse the result-row card but carry selection/active state:- a neutral tint for the inspected row and a success tint with a matching- success edge for the model currently loaded. Discover rows never set these- attributes. */+ /* On-device rows reuse the result-row card with a neutral tint for the+ inspected row. */.hub-page .hub-result-row[data-selected="true"] {background-color: color-mix(in srgb, var(--foreground) 5%, var(--card));}- .hub-page .hub-result-row[data-active="true"] {- background-color: color-mix(in srgb, var(--status-success) 7%, var(--card));- box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.16),- inset 2px 0 0 0 var(--status-success);- }-html.dark .hub-page .hub-result-row[data-selected="true"] {background-color: color-mix(in srgb, var(--foreground) 11%, var(--background));box-shadow: none;}- html.dark .hub-page .hub-result-row[data-active="true"] {- background-color: color-mix(in srgb, var(--status-success) 14%, var(--background));- box-shadow: inset 2px 0 0 0 var(--status-success);- }-/* Recent-searches suggestion panel. The surface comes from.menu-soft-surface; these rules add the row + control hover affordancesusing the same neutral foreground mixes as the option menus and list@@ -738,14 +725,6 @@background-color: color-mix(in srgb, var(--foreground) 6%, transparent);}- /* Currently-loaded checkpoint: a brand-green left stripe plus a faint- green wash, orthogonal to the neutral selected tint so a row that is- both loaded and selected still reads as loaded. */- html:not(.dark) .hub-page .catalog-row[data-active="true"] {- background-color: color-mix(in srgb, var(--status-success) 7%, transparent);- box-shadow: inset 2px 0 0 0 var(--status-success);- }-html.dark .hub-page .catalog-row {background-color: transparent;border-color: transparent;@@ -760,11 +739,6 @@html.dark .hub-page .catalog-row[data-selected="true"] {background-color: color-mix(in srgb, var(--foreground) 7%, transparent);}-- html.dark .hub-page .catalog-row[data-active="true"] {- background-color: color-mix(in srgb, var(--status-success) 12%, transparent);- box-shadow: inset 2px 0 0 0 var(--status-success);- }}@layer utilities {@@ -1110,7 +1084,7 @@margin-block: 0;}- /* Inspector action pills (Download / Run / Train / Cancel) for the hub+ /* Inspector action pills (Download / Update / Cancel) for the hubinspector card. Centralized so all three sections (GGUF, safetensors,datasets) stay in lock-step on type scale, padding, hover surface, andthe 16px icon size — mirrors the pattern used for `.sidebar-nav-btn`.@@ -1158,12 +1132,6 @@flex-shrink: 0;}- /* Primary "Run" action — confirms loading/running a model. Pill shape- (rounded-full) so it reads as the unmistakable CTA in a row of- ghost actions and matches the live-model status-success token used- elsewhere in the app. Same h-9 geometry, 13px- medium type, tracking-tight, and 16px icon slot as .hub-action-btn- so the height aligns with adjacent ghost buttons. */.hub-run-action-btn {display: inline-flex;height: 2.25rem;@@ -1182,8 +1150,9 @@letter-spacing: -0.025em;color: var(--status-success-foreground);transition: background-color 150ms, transform 150ms;- box-shadow: inset 0 1px 0- color-mix(in srgb, var(--status-success-foreground) 18%, transparent),+ box-shadow:+ inset 0 1px 0+ color-mix(in srgb, var(--status-success-foreground) 18%, transparent),0 1px 2px color-mix(in srgb, var(--status-success) 22%, transparent);}@@ -1196,8 +1165,13 @@}.hub-run-action-btn:disabled {- cursor: not-allowed;- opacity: 0.5;+ cursor: wait;+ opacity: 0.78;+ }++ .hub-run-action-btn:focus-visible {+ outline: 2px solid var(--ring);+ outline-offset: 2px;}.hub-run-action-btn svg {diff --git a/studio/frontend/src/features/hub/index.ts b/studio/frontend/src/features/hub/index.tsindex a828daa1b06..70e557c2c59 100644--- a/studio/frontend/src/features/hub/index.ts+++ b/studio/frontend/src/features/hub/index.ts@@ -78,7 +78,6 @@ export {localSourceLabel,normalizeCapabilities,normalizeModelFormat,- normalizeRuntime,normalizeTimestamp,partialSetFromRows,removeScanFolder,diff --git a/studio/frontend/src/features/hub/inventory/index.ts b/studio/frontend/src/features/hub/inventory/index.tsindex b88a796baf5..1fbe6734c26 100644--- a/studio/frontend/src/features/hub/inventory/index.ts+++ b/studio/frontend/src/features/hub/inventory/index.ts@@ -48,7 +48,6 @@ export {localSourceLabel,normalizeCapabilities,normalizeModelFormat,- normalizeRuntime,} from "./view-models";export {epochMillisecondsToSeconds,diff --git a/studio/frontend/src/features/hub/inventory/settings-identity.ts b/studio/frontend/src/features/hub/inventory/settings-identity.tsdeleted file mode 100644index bf054f6cf58..00000000000--- a/studio/frontend/src/features/hub/inventory/settings-identity.ts+++ /dev/null@@ -1,21 +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--// How an inventory row maps onto the identity its saved settings are keyed by.--import type { CachedInventoryRow, LocalInventoryRow } from "./types";--/**- * The GGUF variant a settings page keys this row's config by, before any per-repo lookup. A- * standalone `.gguf` has no quant to choose between, but the inventory still labels it from its- * filename, and adopting that label would key its settings to `<path>:Q4_K_M` while every other- * surface uses the bare path, leaving two configs for one file.- */-export function settingsGgufVariantForRow(- row: CachedInventoryRow | LocalInventoryRow,-): string | null {- if (row.kind === "local" && row.path.toLowerCase().endsWith(".gguf")) {- return null;- }- return row.formatVariant?.trim() || null;-}diff --git a/studio/frontend/src/features/hub/inventory/types.ts b/studio/frontend/src/features/hub/inventory/types.tsindex b634bc88c49..a694cac7ac5 100644--- a/studio/frontend/src/features/hub/inventory/types.ts+++ b/studio/frontend/src/features/hub/inventory/types.ts@@ -10,12 +10,6 @@ export type ModelInventoryFormat =| "adapter"| "checkpoint"| "unknown";-export type ModelInventoryRuntime =- | "llama_cpp"- | "transformers"- | "adapter"- | "unknown";-export interface ModelInventoryCapabilities {canTrain: boolean;canChat: boolean;@@ -43,7 +37,6 @@ export interface CachedInventoryRow {repo: string;isGguf: boolean;modelFormat: ModelInventoryFormat;- runtime: ModelInventoryRuntime;formatVariant?: string | null;capabilities: ModelInventoryCapabilities;bytes: number;@@ -88,7 +81,6 @@ export interface LocalInventoryRow {path: string;isGguf: boolean;modelFormat: ModelInventoryFormat;- runtime: ModelInventoryRuntime;formatVariant?: string | null;capabilities: ModelInventoryCapabilities;baseModel?: string | null;diff --git a/studio/frontend/src/features/hub/inventory/use-hub-inventory.ts b/studio/frontend/src/features/hub/inventory/use-hub-inventory.tsindex 6bbdc09fcdb..54fc61f1c32 100644--- a/studio/frontend/src/features/hub/inventory/use-hub-inventory.ts+++ b/studio/frontend/src/features/hub/inventory/use-hub-inventory.ts@@ -266,12 +266,6 @@ function liveDownloadInventoryRows(inventory_id: cachedInventoryId(modelFormat, job.repoId),load_id: job.repoId,model_format: modelFormat,- runtime:- modelFormat === "gguf"- ? "llama_cpp"- : modelFormat === "safetensors"- ? "transformers"- : "unknown",size_bytes: job.displayBytes,// live jobs already use epoch millisecondslast_modified: job.startedAt,@@ -547,7 +541,6 @@ export function useHubInventory(isGguf: false,loadId: ds.id,modelFormat: "unknown" as const,- runtime: "unknown" as const,formatVariant: null,capabilities: defaultCapabilities("unknown"),updatedAt: normalizeTimestamp(ds.updated_at),diff --git a/studio/frontend/src/features/hub/inventory/view-models.ts b/studio/frontend/src/features/hub/inventory/view-models.tsindex 2951a8a4306..5bb72c15510 100644--- a/studio/frontend/src/features/hub/inventory/view-models.ts+++ b/studio/frontend/src/features/hub/inventory/view-models.ts@@ -9,7 +9,6 @@ import type {BackendModelCapabilities,LocalModelInfo,ModelInventoryFormat,- ModelInventoryRuntime,} from "./api";import type {ModelInventoryCapabilities,@@ -88,26 +87,6 @@ export function normalizeModelFormat(return fallback;}-export function normalizeRuntime(- value: string | null | undefined,- modelFormat: ModelInventoryFormat,-): ModelInventoryRuntime {- if (- value === "llama_cpp" ||- value === "transformers" ||- value === "adapter" ||- value === "unknown"- ) {- return value;- }- if (modelFormat === "gguf") return "llama_cpp";- if (modelFormat === "adapter") return "adapter";- if (modelFormat === "safetensors" || modelFormat === "checkpoint") {- return "transformers";- }- return "unknown";-}-export function defaultCapabilities(modelFormat: ModelInventoryFormat,partial = false,@@ -188,7 +167,6 @@ export function buildCachedInventoryRow(inventory_id?: string | null;load_id?: string | null;model_format?: ModelInventoryFormat | null;- runtime?: string | null;format_variant?: string | null;capabilities?: BackendModelCapabilities | null;last_modified?: number | null;@@ -225,10 +203,6 @@ export function buildCachedInventoryRow(repo: row.repo_id.includes("/") ? repoOf(row.repo_id) : row.repo_id,isGguf: modelFormat === "gguf",modelFormat,- runtime: normalizeRuntime(- inferredFromEndpoint ? null : row.runtime,- modelFormat,- ),formatVariant: row.format_variant ?? null,capabilities,bytes: row.size_bytes,@@ -309,7 +283,6 @@ export function buildLocalInventoryRows(path: model.path,isGguf: modelFormat === "gguf",modelFormat,- runtime: normalizeRuntime(model.runtime, modelFormat),formatVariant: model.format_variant ?? null,capabilities,baseModel,diff --git a/studio/frontend/src/features/hub/lib/adopt-inference-status.ts b/studio/frontend/src/features/hub/lib/adopt-inference-status.tsindex dfe4502d06f..7ea393e6779 100644--- a/studio/frontend/src/features/hub/lib/adopt-inference-status.ts+++ b/studio/frontend/src/features/hub/lib/adopt-inference-status.ts@@ -1,10 +1,8 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-// Adopting the resident model into the chat runtime store from the Hub. Landing straight on /hub-// is the one entry point where nothing has applied /api/inference/status yet, and pinning only-// the checkpoint leaves every other useActiveModelConfig field at its default, which the settings-// page would pass on as the live config. So adoption applies the whole status, as chat does.+// Landing straight on /hub is the one entry point where nothing else applies+// /api/inference/status. Cache mutation guards need the same resident state as Chat.import { ggufVariantsMatch, modelIdsMatch } from "./model-identity.ts";@@ -14,7 +12,7 @@ export interface ResidentAdoptionState {/** Whether that checkpoint names an external provider's model. */checkpointIsExternal: boolean;activeGgufVariant: string | null;- /** ``modelLoading``: a load this tab started still owns the store. */+ /** ``modelLoading``: a model load still owns the store. */modelLoading: boolean;/** Whether the idle-unload loop will actually free the model. From* ``/openai-auto-switch``; ``/status`` says nothing about it. */@@ -36,8 +34,7 @@ export interface ResidentStatusFacts {export interface ResidentAdoptionActions {/** Re-pin ``params.checkpoint`` onto the resident model. */setCheckpoint: (checkpointId: string, ggufVariant: string | null) => void;- /** Drop a checkpoint the server has genuinely unloaded. Optional, so a caller- * that only wants the pinning half can leave it out. */+ /** Drop a checkpoint the server has genuinely unloaded. */clearCheckpoint?: () => void;/*** Apply the rest of the status. Receives the store values from BEFORE ``setCheckpoint`` ran,@@ -59,23 +56,20 @@ export function adoptResidentModelStatus(actions: ResidentAdoptionActions,): boolean {const { checkpointId } = status;- // An external selection has no local mirror, so the resident GGUF's settings would- // describe a model the user is not talking to.+ // An external selection has no local mirror.if (state.checkpointIsExternal) {return false;}- // A load this tab started applies its own status when it settles, and owns the params- // meanwhile. Adopting underneath it would fight both.+ // A load applies its own status when it settles and owns the store meanwhile.if (state.modelLoading) {return false;}if (!checkpointId) {// An empty status means one of two things and /status cannot say which. Armed, the idle// loop frees the model but keeps a stash the next request reloads, so clearing would drop- // a selection that is coming back. Disarmed, nothing brings it back, and leaving the row- // resident seeds the settings editor from a launch config nothing is running.+ // a selection that is coming back. Disarmed, nothing brings it back.// A speech model is neither: an Audio load took the slot, not the idle loop, and no- // stash reloads the chat model. Holding the pick left the Hub calling it Loaded.+ // stash reloads the chat model. Keeping the prior pick would leave stale Hub residency.if (state.idleUnloadArmed && !status.speechOnly) {return false;}diff --git a/studio/frontend/src/features/hub/lib/gguf-variant-sort.ts b/studio/frontend/src/features/hub/lib/gguf-variant-sort.tsindex 7fe155f36c1..479a47f65da 100644--- a/studio/frontend/src/features/hub/lib/gguf-variant-sort.ts+++ b/studio/frontend/src/features/hub/lib/gguf-variant-sort.ts@@ -92,17 +92,46 @@ export function sortDownloadableGgufVariants(export function sortLocalGgufVariants(variants: readonly GgufVariantDetail[],options: GgufFitInput & {- activeGgufVariant?: string | null;defaultVariant?: string | null;},): GgufVariantDetail[] {+ const defaultVariant = options.defaultVariant?.trim();return [...variants].sort((a, b) => {- const aActive = ggufVariantsMatch(a.quant, options.activeGgufVariant);- const bActive = ggufVariantsMatch(b.quant, options.activeGgufVariant);- if (aActive !== bActive) return aActive ? -1 : 1;- const aDefault = ggufVariantsMatch(a.quant, options.defaultVariant);- const bDefault = ggufVariantsMatch(b.quant, options.defaultVariant);- if (aDefault !== bDefault) return aDefault ? -1 : 1;+ if (defaultVariant) {+ const aDefault = ggufVariantsMatch(a.quant, defaultVariant);+ const bDefault = ggufVariantsMatch(b.quant, defaultVariant);+ if (aDefault !== bDefault) return aDefault ? -1 : 1;+ }return compareGgufVariantFitAndSize(a, b, options);});}++export function resolveLocalGgufVariant<T extends { quant: string }>(+ variants: readonly T[] | null | undefined,+ options: {+ selectedVariant?: string | null;+ activeVariant?: string | null;+ defaultVariant?: string | null;+ },+): T | null {+ if (!variants || variants.length === 0) {+ return null;+ }+ for (const candidate of [+ options.selectedVariant,+ options.activeVariant,+ options.defaultVariant,+ ]) {+ // Blank candidates must not match a blank variant key.+ if (!candidate?.trim()) {+ continue;+ }+ const match = variants.find((variant) =>+ ggufVariantsMatch(variant.quant, candidate),+ );+ if (match) {+ return match;+ }+ }+ return variants[0] ?? null;+}diff --git a/studio/frontend/src/features/hub/lib/hub-feature-flags.ts b/studio/frontend/src/features/hub/lib/hub-feature-flags.tsdeleted file mode 100644index 6c74f71d1bf..00000000000--- a/studio/frontend/src/features/hub/lib/hub-feature-flags.ts+++ /dev/null@@ -1,16 +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--// Hub feature flags for staged rollout. JSX/wiring stay in place so flipping-// a flag here is the only edit needed to re-enable.--// Post-download New Chat / Use in chat / Train CTAs; hidden until the-// Hub-aware chat and train pickers ship. Run CTAs are gated separately below.-export const HUB_POST_DOWNLOAD_ACTIONS_VISIBLE = false;--export const HUB_GGUF_RUN_ACTIONS_VISIBLE = true;--// Post-download Run CTA for non-GGUF models (MLX repos classify as safetensors).-// Run has no dependency on the Hub-aware chat/train pickers, so it enables-// independently of HUB_POST_DOWNLOAD_ACTIONS_VISIBLE, which still gates those.-export const HUB_NON_GGUF_RUN_ACTIONS_VISIBLE = true;diff --git a/studio/frontend/src/features/hub/lib/model-run-selection.ts b/studio/frontend/src/features/hub/lib/model-run-selection.tsnew file mode 100644index 00000000000..1a80bb59db5--- /dev/null+++ b/studio/frontend/src/features/hub/lib/model-run-selection.ts@@ -0,0 +1,172 @@+// 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 { ModelConfigHandoffRequest } from "@/features/model-picker";+import type { SelectedModelView } from "../types";+import { EMBEDDING_TAGS } from "./hf-model-meta.ts";+import { routableToMediaPage } from "./local-path.ts";++export interface HubModelRunSelection {+ ggufVariant?: string;+ ggufFilename?: string;+ expectedBytes?: number;+}++function isPresent(value: string | null | undefined): value is string {+ return Boolean(value?.trim());+}++function hasSupportedFormat(model: SelectedModelView): boolean {+ if (model.modelFormat === "gguf") {+ return model.isGguf;+ }+ return (+ (model.modelFormat === "safetensors" ||+ model.modelFormat === "checkpoint" ||+ model.modelFormat === "adapter") &&+ !model.isGguf+ );+}++const GENERATIVE_CAPABILITIES = new Set([+ "conversational",+ "tools",+ "reasoning",+ "code",+ "vision",+ "audio",+ "diffusion",+]);++function isEmbeddingOnly(model: SelectedModelView): boolean {+ if (+ model.isGguf ||+ !model.capabilities.some((capability) => capability.key === "embedding")+ ) {+ return false;+ }+ if (EMBEDDING_TAGS.has(model.pipelineTag?.trim().toLowerCase() ?? "")) {+ return true;+ }+ return !model.capabilities.some((capability) =>+ GENERATIVE_CAPABILITIES.has(capability.key),+ );+}++function hasCompleteInventoryModel(model: SelectedModelView): boolean {+ return model.isDownloaded && !model.isPartial && isPresent(model.loadId);+}++function hasRunnableChatModel(model: SelectedModelView): boolean {+ return (+ model.runtimeCanChat &&+ hasCompleteInventoryModel(model) &&+ !isEmbeddingOnly(model) &&+ hasSupportedFormat(model)+ );+}++function hasValidSelection(+ model: SelectedModelView,+ selection: HubModelRunSelection,+): boolean {+ const hasGgufVariant = isPresent(selection.ggufVariant);+ const hasGgufFilename = isPresent(selection.ggufFilename);+ if (model.modelFormat !== "gguf") {+ return !(hasGgufVariant || hasGgufFilename);+ }+ return !model.requiresVariant || hasGgufVariant;+}++function createHandoffMeta(+ model: SelectedModelView,+ selection: HubModelRunSelection,+ usesLocalIdentity: boolean,+): ModelConfigHandoffRequest["meta"] {+ const meta: ModelConfigHandoffRequest["meta"] = {+ source: usesLocalIdentity ? "local" : "hub",+ isLora: model.modelFormat === "adapter",+ loadId: model.loadId,+ isDownloaded: true,+ isGguf: model.modelFormat === "gguf",+ pipelineTag: model.task ?? model.pipelineTag ?? null,+ };+ if (isPresent(selection.ggufVariant)) {+ meta.ggufVariant = selection.ggufVariant;+ }+ if (isPresent(selection.ggufFilename)) {+ meta.ggufFilename = selection.ggufFilename;+ }+ if (+ selection.expectedBytes != null &&+ Number.isFinite(selection.expectedBytes) &&+ selection.expectedBytes > 0+ ) {+ meta.expectedBytes = selection.expectedBytes;+ }+ return meta;+}++export function isHubModelRunEligible({+ model,+ isDataset,+ mediaRuntime,+ nonGgufRuntimeAvailable,+}: {+ model: SelectedModelView | null;+ isDataset: boolean;+ mediaRuntime: boolean;+ nonGgufRuntimeAvailable: boolean;+}): boolean {+ if (!model || isDataset) {+ return false;+ }++ if (mediaRuntime) {+ return (+ hasCompleteInventoryModel(model) &&+ isPresent(model.hubRepoId) &&+ routableToMediaPage(model.kind, model.localSource)+ );+ }++ if (!hasRunnableChatModel(model)) {+ return false;+ }++ return model.modelFormat === "gguf" || nonGgufRuntimeAvailable;+}++export function createHubModelConfigHandoff({+ requestId,+ model,+ selection,+}: {+ requestId: string;+ model: SelectedModelView;+ selection: HubModelRunSelection;+}): ModelConfigHandoffRequest | null {+ if (!isPresent(requestId)) {+ return null;+ }+ if (!hasRunnableChatModel(model)) {+ return null;+ }++ if (!hasValidSelection(model, selection)) {+ return null;+ }++ const usesLocalIdentity = model.isLocal && model.localSource !== "hf_cache";+ const id = usesLocalIdentity ? model.id : (model.hubRepoId ?? model.id);+ if (!isPresent(id)) {+ return null;+ }++ return {+ requestId,+ id,+ displayName: model.title,+ meta: createHandoffMeta(model, selection, usesLocalIdentity),+ };+}diff --git a/studio/frontend/src/features/hub/lib/resident-status-refresh.ts b/studio/frontend/src/features/hub/lib/resident-status-refresh.tsindex 2fb0fe14466..7178c3c5a50 100644--- a/studio/frontend/src/features/hub/lib/resident-status-refresh.ts+++ b/studio/frontend/src/features/hub/lib/resident-status-refresh.ts@@ -1,11 +1,8 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-// When the Hub has to re-read /api/inference/status. An API request can auto-switch the resident-// model at any moment and nothing else on /hub reads status, so a mount-only read leaves every-// "loaded" marker (and the settings page's live config) pinned to whatever was resident when the-// Hub opened. A background timer would keep asking a server that usually has not changed, so-// re-read only on the moments this tab could have missed a switch.+// An API request can switch the resident model while the Hub is open. Re-read+// only when this tab could have missed a switch, rather than polling./** The event targets to listen on; injected so this is testable off a browser. */export interface ResidentStatusRefreshTargets {diff --git a/studio/frontend/src/features/hub/lib/superseded-refresh.ts b/studio/frontend/src/features/hub/lib/superseded-refresh.tsindex 2c68333939e..fd7dc53c672 100644--- a/studio/frontend/src/features/hub/lib/superseded-refresh.ts+++ b/studio/frontend/src/features/hub/lib/superseded-refresh.ts@@ -1,17 +1,8 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-// A caller that awaits a status refresh is waiting for the store to be settled, not for one-// particular HTTP response. Refreshes are sequenced so the newest read owns the store, and a-// response that lands after a newer read started writes nothing. Resolving that dropped-// response's promise anyway releases its caller onto the store the newer read has not written-// yet, which is exactly the pre-read store the await was there to replace: the Hub's settings-// handlers would then resolve a quant from the model an API switch already displaced and bake-// it into the settings target, and Apply reloads and persists under whatever the target names.-// A settings open is guarded against a newer settings open, but nothing bumps that guard for a-// focus or visibilitychange refresh, so those are the reads that can supersede one unnoticed.-//-// So a dropped response resolves with the refresh that superseded it instead of with nothing.+// A caller waiting for resident state must wait for the newest refresh, not only+// for an older response that was dropped after a focus or visibility refresh./** The newest refresh started, so a superseded one can hand its caller that promise. */export interface RefreshSupersession {diff --git a/studio/frontend/src/features/hub/types.ts b/studio/frontend/src/features/hub/types.tsindex 64e160e8a12..046f726276a 100644--- a/studio/frontend/src/features/hub/types.ts+++ b/studio/frontend/src/features/hub/types.ts@@ -4,7 +4,6 @@import type {BaseModelSource,LocalSource,- ModelInventoryCapabilities,ModelInventoryFormat,} from "@/features/hub/inventory";import type { HfModelResult } from "@/features/hub/hooks/use-hub-model-search";@@ -39,27 +38,10 @@ export interface DiscoverRow {capabilities: Capability[];}-export type SelectedResourceSource = "huggingface" | "hub_cache" | LocalSource;--export type SelectedResourceCacheState =- | "remote"- | "cached"- | "local"- | "partial";--export interface SelectedResourceRef {- repoId: string | null;- localPath: string | null;- source: SelectedResourceSource;- cacheState: SelectedResourceCacheState;- runId: string;- trainId: string;-}-export interface SelectedModelView {id: string;+ loadId: string | null;kind: "discover" | "cache" | "local";- resource: SelectedResourceRef;displayId: string;hubRepoId: string | null;owner: string;@@ -79,10 +61,10 @@ export interface SelectedModelView {adapterType?: string | null;trainingMethod?: string | null;isDownloaded: boolean;+ runtimeCanChat: boolean;isPartial?: boolean;partialTransport?: string | null;partialResumable?: boolean;- runtimeCapabilities?: ModelInventoryCapabilities;capabilities: Capability[];license: string | null;pipelineTag?: string;diff --git a/studio/frontend/src/features/model-picker/components/model-selector.tsx b/studio/frontend/src/features/model-picker/components/model-selector.tsxindex 2f81ff30250..2c46a2180bd 100644--- a/studio/frontend/src/features/model-picker/components/model-selector.tsx+++ b/studio/frontend/src/features/model-picker/components/model-selector.tsx@@ -34,7 +34,14 @@ import {useState,} from "react";import {- isOllamaLinkPath,+ type ModelConfigHandoffRequest,+ modelConfigTarget,+ modelConfigTargetIsResident,+ modelConfigTargetMatchesSelection,+} from "../model-config/model-config-handoff";+import { modelConfigInstanceKey } from "../model-config/config-signature";+import {+ ggufVariantsMatch,modelDisplayName,} from "../model-config/model-identity";import {@@ -153,6 +160,8 @@ interface ModelSelectorProps {activeLoadedContextLength?: number | null;selectedConfig?: PerModelConfig | null;selectedGgufVariant?: string | null;+ configRequest?: ModelConfigHandoffRequest | null;+ onConfigRequestAdopted?: (requestId: string) => void;onValueChange?: (value: string, meta: ModelSelectorChangeMeta) => void;/** Optional task-specific resolver for companion assets a GGUF row alone cannot describe. */resolveDownloadFootprint?: ModelDownloadFootprintResolver;@@ -358,11 +367,14 @@ function ModelSelectorContent({loraModels,externalModels,value,+ loaded,activeGgufVariant,activeModelConfig,activeLoadedContextLength,selectedConfig,selectedGgufVariant,+ configRequest,+ onConfigRequestAdopted,onSelect,resolveDownloadFootprint,onEject,@@ -383,11 +395,14 @@ function ModelSelectorContent({loraModels: LoraModelOption[];externalModels: ExternalModelOption[];value?: string;+ loaded?: boolean;activeGgufVariant?: string | null;activeModelConfig?: PerModelConfig | null;activeLoadedContextLength?: number | null;selectedConfig?: PerModelConfig | null;selectedGgufVariant?: string | null;+ configRequest?: ModelConfigHandoffRequest | null;+ onConfigRequestAdopted?: (requestId: string) => void;onSelect: (id: string, meta: ModelSelectorChangeMeta) => void;resolveDownloadFootprint?: ModelDownloadFootprintResolver;onEject?: () => void;@@ -445,6 +460,9 @@ function ModelSelectorContent({const [configTarget, setConfigTarget] = useState<ModelPickTarget | null>(null,);+ const [adoptedConfigRequestId, setAdoptedConfigRequestId] = useState<+ string | null+ >(null);// The picker remounts on each open but this section state does not, so re-derive the default// section on the open edge.@@ -504,21 +522,51 @@ function ModelSelectorContent({}}- const visibleConfigTarget = open ? configTarget : null;const openConfigPage = (id: string, meta: ModelSelectorChangeMeta) => {- const leaf = id.includes("/") ? id.slice(id.lastIndexOf("/") + 1) : id;- const isGguf = meta.isGguf ?? Boolean(meta.ggufVariant);- setConfigTarget({- id,- displayName: meta.ggufVariant ? `${leaf} · ${meta.ggufVariant}` : leaf,- ggufVariant: meta.ggufVariant ?? null,- isGguf,- // Ollama's models sit under a link dir the resolver skips, so mirroring their settings would- // advertise an impossible load.- apiLoadable: isGguf && !isOllamaLinkPath(id),- meta,- });+ setConfigTarget(modelConfigTarget(id, meta));};+ const requestedConfigTarget = useMemo(+ () =>+ open && configRequest+ ? modelConfigTarget(+ configRequest.id,+ configRequest.meta,+ configRequest.displayName,+ )+ : null,+ [configRequest, open],+ );+ const visibleConfigTarget = open+ ? (requestedConfigTarget ?? configTarget)+ : null;+ const visibleConfigMatchesSelection =+ visibleConfigTarget !== null &&+ modelConfigTargetMatchesSelection(visibleConfigTarget, value);+ const visibleConfigIsResident =+ visibleConfigTarget !== null &&+ modelConfigTargetIsResident({+ target: visibleConfigTarget,+ selectedId: value,+ activeGgufVariant,+ loaded,+ });+ const visibleLoadedConfig = visibleConfigIsResident+ ? (activeModelConfig ?? null)+ : null;+ if (+ configRequest &&+ requestedConfigTarget &&+ adoptedConfigRequestId !== configRequest.requestId+ ) {+ setAdoptedConfigRequestId(configRequest.requestId);+ setConfigTarget(requestedConfigTarget);+ }+ useEffect(() => {+ if (!configRequest || adoptedConfigRequestId !== configRequest.requestId) {+ return;+ }+ onConfigRequestAdopted?.(configRequest.requestId);+ }, [adoptedConfigRequestId, configRequest, onConfigRequestAdopted]);const handlePick = (id: string, meta: ModelSelectorChangeMeta) => {if (meta.source === "external") {onSelect(id, meta);@@ -535,6 +583,11 @@ function ModelSelectorContent({<PopoverContentalign="start"alignOffset={10}+ aria-label={+ visibleConfigTarget+ ? `Run settings for ${visibleConfigTarget.displayName}`+ : undefined+ }data-tour={dataTour}onKeyDown={handlePickerEntryKeyDown}className={cn(@@ -569,38 +622,39 @@ function ModelSelectorContent({{visibleConfigTarget ? (<div className="min-h-0 w-full overflow-y-auto px-4 pt-4 pb-4"><ModelConfigPage- key={`${visibleConfigTarget.id}::${visibleConfigTarget.ggufVariant ?? ""}`}- target={visibleConfigTarget}- onBack={() => setConfigTarget(null)}- onRun={(config, isDiffusion) =>- onSelect(visibleConfigTarget.id, {- ...visibleConfigTarget.meta,- config,- isDiffusion,- forceReload: true,- })- }- loadedConfig={- value === visibleConfigTarget.id &&- (activeGgufVariant ?? null) ===- (visibleConfigTarget.ggufVariant ?? null)- ? (activeModelConfig ?? null)- : null- }- loadedContextLength={- value === visibleConfigTarget.id &&- (activeGgufVariant ?? null) ===- (visibleConfigTarget.ggufVariant ?? null)- ? (activeLoadedContextLength ?? null)- : null- }- initialConfig={- value === visibleConfigTarget.id &&- (selectedGgufVariant ?? null) ===- (visibleConfigTarget.ggufVariant ?? null)- ? (selectedConfig ?? null)- : null- }+ key={modelConfigInstanceKey(+ visibleConfigTarget.configId ?? visibleConfigTarget.id,+ visibleConfigTarget.ggufVariant,+ visibleLoadedConfig,+ )}+ target={visibleConfigTarget}+ onBack={() => setConfigTarget(null)}+ onRun={(config, isDiffusion) =>+ onSelect(+ visibleConfigTarget.configId ?? visibleConfigTarget.id,+ {+ ...visibleConfigTarget.meta,+ config,+ isDiffusion,+ forceReload: true,+ },+ )+ }+ loadedConfig={visibleLoadedConfig}+ loadedContextLength={+ visibleConfigIsResident+ ? (activeLoadedContextLength ?? null)+ : null+ }+ initialConfig={+ visibleConfigMatchesSelection &&+ ggufVariantsMatch(+ selectedGgufVariant,+ visibleConfigTarget.ggufVariant,+ )+ ? (selectedConfig ?? null)+ : null+ }/></div>) : (@@ -662,6 +716,8 @@ export function ModelSelector({activeLoadedContextLength,selectedConfig,selectedGgufVariant,+ configRequest,+ onConfigRequestAdopted,onValueChange,resolveDownloadFootprint,onEject,@@ -828,11 +884,14 @@ export function ModelSelector({loraModels={loraModels}externalModels={externalModels}value={selected}+ loaded={loaded}activeGgufVariant={activeGgufVariant}activeModelConfig={activeModelConfig}activeLoadedContextLength={activeLoadedContextLength}selectedConfig={selectedConfig}selectedGgufVariant={selectedGgufVariant}+ configRequest={configRequest}+ onConfigRequestAdopted={onConfigRequestAdopted}onSelect={handleSelect}resolveDownloadFootprint={resolveDownloadFootprint}onEject={onEject ? handleEject : undefined}diff --git a/studio/frontend/src/features/model-picker/components/model-selector/model-row-menu.tsx b/studio/frontend/src/features/model-picker/components/model-selector/model-row-menu.tsxindex fe08f9e1fed..c72a1d33d64 100644--- a/studio/frontend/src/features/model-picker/components/model-selector/model-row-menu.tsx+++ b/studio/frontend/src/features/model-picker/components/model-selector/model-row-menu.tsx@@ -1,9 +1,8 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-// Condensed row actions for model rows: everything except the run-settings gear collapses into-// one dots menu (pin, update, delete) so rows do not grow an icon strip. Mirrors the sidebar-// chat rows' MoreVertical menu pattern.+// Condensed row actions for model rows so pin, update, and delete do not grow into an icon strip.+// Mirrors the sidebar chat rows' MoreVertical menu pattern.import {DropdownMenu,@@ -30,7 +29,6 @@ import {MoreVerticalIcon,PinIcon,PinOffIcon,- Settings02Icon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { RefreshCw } from "lucide-react";@@ -79,17 +77,11 @@ interface ModelRowMenuCachePath {variant?: string;}-/** The model's settings page: load config plus what the API will apply. */-interface ModelRowMenuSettings {- onOpen: () => void;-}-export function ModelRowMenu({ariaLabel,buttonClassName,iconClassName,cachePath,- settings,pin,update,del,@@ -99,7 +91,6 @@ export function ModelRowMenu({iconClassName?: string;/** Enables "Reveal in Finder" for cached repos. */cachePath?: ModelRowMenuCachePath;- settings?: ModelRowMenuSettings;pin?: ModelRowMenuPin;update?: ModelRowMenuUpdate;del?: ModelRowMenuDelete;@@ -180,7 +171,7 @@ export function ModelRowMenu({});}, [cachePathRepoId, cachePathVariant]);- if (!pin && !update && !del && !cachePath && !settings) return null;+ if (!pin && !update && !del && !cachePath) return null;return (<>@@ -209,21 +200,6 @@ export function ModelRowMenu({sideOffset={2}className="unsloth-plus-menu menu-flat-destructive w-48">- {settings && (- <DropdownMenuItem- onSelect={(e) => {- e.stopPropagation();- settings.onOpen();- }}- >- <HugeiconsIcon- icon={Settings02Icon}- strokeWidth={1.75}- className="size-icon"- />- <span>Settings</span>- </DropdownMenuItem>- )}{pin && (<DropdownMenuItemonSelect={(e) => {diff --git a/studio/frontend/src/features/model-picker/components/sidebar-model-config.tsx b/studio/frontend/src/features/model-picker/components/sidebar-model-config.tsxindex c8ee44b0811..b786da8f192 100644--- a/studio/frontend/src/features/model-picker/components/sidebar-model-config.tsx+++ b/studio/frontend/src/features/model-picker/components/sidebar-model-config.tsx@@ -44,8 +44,8 @@ export function SidebarModelConfig({onReload,}: SidebarModelConfigProps) {// A standalone .gguf has no quant to choose between, but the loader labels it from its filename and- // /status echoes that back. Keying settings by it would write "<path>:Q4_K_M" while every other- // surface uses the bare path. Same rule as settingsGgufVariantForRow.+ // /status echoes that back. Keying settings by it would write "<path>:Q4_K_M" while all other+ // settings entry points use the bare path.const settingsGgufVariant = isStandaloneGgufPath(modelId)? null: ggufVariant;diff --git a/studio/frontend/src/features/model-picker/index.ts b/studio/frontend/src/features/model-picker/index.tsindex e1d67ae6747..ec924421eda 100644--- a/studio/frontend/src/features/model-picker/index.ts+++ b/studio/frontend/src/features/model-picker/index.ts@@ -40,6 +40,17 @@ export type {ModelSelectorChangeMeta,} from "./components/model-selector";export { modelConfigInstanceKey } from "./model-config/config-signature";+export {+ clearModelConfigHandoff,+ createModelConfigHandoffRequestId,+ modelConfigHandoffForDestination,+ modelConfigTarget,+ modelConfigTargetIsResident,+ modelConfigTargetMatchesSelection,+ requestModelConfigHandoff,+ useModelConfigHandoffStore,+ type ModelConfigHandoffRequest,+} from "./model-config/model-config-handoff";export {applyModelLoadConfigToRuntime,applyPerModelConfigToRuntime,diff --git a/studio/frontend/src/features/model-picker/model-config/model-config-handoff.ts b/studio/frontend/src/features/model-picker/model-config/model-config-handoff.tsnew file mode 100644index 00000000000..beddfa8700e--- /dev/null+++ b/studio/frontend/src/features/model-picker/model-config/model-config-handoff.ts@@ -0,0 +1,170 @@+// 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 { create } from "zustand";+import type {+ ModelPickTarget,+ ModelSelectorChangeMeta,+} from "../components/model-selector/types";+import {+ ggufVariantsMatch,+ isOllamaLinkPath,+ isStandaloneGgufPath,+ modelDisplayName,+ residentModelIdMatches,+} from "./model-identity";+import { adoptLegacyConfigKey } from "./per-model-config";++export interface ModelConfigHandoffRequest {+ requestId: string;+ id: string;+ displayName?: string;+ meta: ModelSelectorChangeMeta;+}++interface ModelConfigHandoffState {+ request: ModelConfigHandoffRequest | null;+ submit: (request: ModelConfigHandoffRequest) => void;+ clear: (requestId: string) => void;+}++interface RandomUuidSource {+ randomUUID?: () => string;+}++function fallbackRequestId(): string {+ const random = Math.random().toString(36).slice(2, 10).padEnd(8, "0");+ return `${Date.now()}-${random}`;+}++export function createModelConfigHandoffRequestId(+ cryptoSource: RandomUuidSource | null = globalThis.crypto ?? null,+): string {+ if (typeof cryptoSource?.randomUUID !== "function") {+ return fallbackRequestId();+ }+ try {+ return cryptoSource.randomUUID();+ } catch {+ return fallbackRequestId();+ }+}++export function modelConfigTarget(+ id: string,+ meta: ModelSelectorChangeMeta,+ displayName?: string,+): ModelPickTarget {+ const name = displayName?.trim() || modelDisplayName(id);+ const isGguf = meta.isGguf ?? Boolean(meta.ggufVariant);+ const separateLoadId =+ meta.source === "hub" && Boolean(meta.loadId?.trim()) && meta.loadId !== id+ ? meta.loadId+ : null;+ const loadId = separateLoadId ?? id;+ return {+ id: loadId,+ displayName: meta.ggufVariant ? `${name} · ${meta.ggufVariant}` : name,+ ggufVariant: meta.ggufVariant ?? null,+ isGguf,+ apiLoadable: isGguf && !isOllamaLinkPath(id) && !isOllamaLinkPath(loadId),+ ...(separateLoadId ? { configId: id } : {}),+ meta,+ };+}++export function modelConfigTargetMatchesSelection(+ target: ModelPickTarget,+ selectedId: string | null | undefined,+): boolean {+ return residentModelIdMatches(+ selectedId,+ target.configId,+ target.id,+ target.meta.loadId,+ );+}++export function modelConfigTargetIsResident({+ target,+ selectedId,+ activeGgufVariant,+ loaded = true,+}: {+ target: ModelPickTarget;+ selectedId: string | null | undefined;+ activeGgufVariant: string | null | undefined;+ loaded?: boolean;+}): boolean {+ if (!loaded) {+ return false;+ }+ if (!modelConfigTargetMatchesSelection(target, selectedId)) {+ return false;+ }+ if (+ target.isGguf &&+ target.ggufVariant == null &&+ (isStandaloneGgufPath(target.id) || isOllamaLinkPath(target.id))+ ) {+ return true;+ }+ return ggufVariantsMatch(activeGgufVariant, target.ggufVariant);+}++export function modelConfigHandoffForDestination(+ request: ModelConfigHandoffRequest | null,+ destination: {+ active: boolean;+ newChatId?: string | null;+ threadId?: string | null;+ compareId?: string | null;+ projectId?: string | null;+ },+): ModelConfigHandoffRequest | null {+ if (!request) {+ return null;+ }+ if (+ !destination.active ||+ destination.threadId ||+ destination.compareId ||+ destination.projectId ||+ request.requestId !== destination.newChatId+ ) {+ return null;+ }+ return request;+}++export const useModelConfigHandoffStore = create<ModelConfigHandoffState>(+ (set) => ({+ request: null,+ submit: (request) => set({ request }),+ clear: (requestId) =>+ set((state) =>+ state.request?.requestId === requestId ? { request: null } : state,+ ),+ }),+);++export function requestModelConfigHandoff(+ request: ModelConfigHandoffRequest,+): void {+ if (+ request.meta.source === "hub" &&+ request.meta.loadId?.trim() &&+ request.meta.loadId !== request.id+ ) {+ adoptLegacyConfigKey(+ request.id,+ request.meta.loadId,+ request.meta.ggufVariant,+ );+ }+ useModelConfigHandoffStore.getState().submit(request);+}++export function clearModelConfigHandoff(requestId: string): void {+ useModelConfigHandoffStore.getState().clear(requestId);+}diff --git a/studio/frontend/src/features/model-picker/model-config/model-identity.ts b/studio/frontend/src/features/model-picker/model-config/model-identity.tsindex c5e006d0958..b0ec746d845 100644--- a/studio/frontend/src/features/model-picker/model-config/model-identity.ts+++ b/studio/frontend/src/features/model-picker/model-config/model-identity.ts@@ -13,10 +13,12 @@ export {isNativeFileLabel,isOllamaLinkPath,isStandaloneGgufPath,+ ggufVariantsMatch,modelDisplayName,normalizeGgufVariantIdentity,normalizeModelIdentity,publicModelId,+ residentModelIdMatches,} from "@/features/hub/lib/model-identity";const MODEL_STORAGE_KEY_PREFIX = "v2:";diff --git a/studio/frontend/tests/appearance-accent-vars.test.ts b/studio/frontend/tests/appearance-accent-vars.test.tsindex b8b77b00987..80731cae34c 100644--- a/studio/frontend/tests/appearance-accent-vars.test.ts+++ b/studio/frontend/tests/appearance-accent-vars.test.ts@@ -252,21 +252,6 @@ test("a narrow valid band between custom and elevated surfaces is not skipped",assert.ok(ratio(corrected, "#212121") >= 2.5);});-test("loaded-model stripes stay on the semantic success color", () => {- const hubCss = readFileSync(- new URL("../src/features/hub/hub.css", import.meta.url),- "utf8",- );- const activeBlocks = [- ...hubCss.matchAll(/\[data-active="true"\]\s*\{([^}]+)\}/g),- ];- assert.equal(activeBlocks.length, 4);- for (const [, declarations = ""] of activeBlocks) {- assert.match(declarations, /box-shadow:[^;]+var\(--status-success\)/);- assert.doesNotMatch(declarations, /var\(--primary\)/);- }-});-test("resize-handle glows follow the primary token", () => {const source = readFileSync(new URL("../src/components/ui/resizable.tsx", import.meta.url),diff --git a/studio/frontend/tests/chat-model-residency.test.ts b/studio/frontend/tests/chat-model-residency.test.tsindex b1389103e54..044ab7a3b91 100644--- a/studio/frontend/tests/chat-model-residency.test.ts+++ b/studio/frontend/tests/chat-model-residency.test.ts@@ -140,14 +140,6 @@ test("the picker's Loaded badge asks residency, not the selection", () => {);});-test("the hub cards ask residency before saying Loaded", () => {- const hub = readFileSync(- new URL("../src/features/hub/hub-page.tsx", import.meta.url),- "utf8",- );- assert.match(hub, /residentCheckpoint !== null\s*\n?\s*\? checkpoint/);-});-// Nothing in the chat runtime polls /status: refresh runs on mount and when the// model lists change, never on a timer. So an eviction caused by the Images// page was never observed and residentCheckpoint stayed undefined, which readsdiff --git a/studio/frontend/tests/hub-local-gguf-selection.test.ts b/studio/frontend/tests/hub-local-gguf-selection.test.tsnew file mode 100644index 00000000000..56cbc536521--- /dev/null+++ b/studio/frontend/tests/hub-local-gguf-selection.test.ts@@ -0,0 +1,145 @@+// 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 test from "node:test";++import { registerBundlerResolver } from "./helpers/kit.ts";++registerBundlerResolver();++const { resolveLocalGgufVariant, sortLocalGgufVariants } = await import(+ "../src/features/hub/lib/gguf-variant-sort.ts"+);++const variants = [{ quant: "Q4_K_M" }, { quant: "Q8_0" }, { quant: "Q6_K" }];++test("an explicit Hub quant selection takes priority", () => {+ assert.equal(+ resolveLocalGgufVariant(variants, {+ selectedVariant: "q6_k",+ activeVariant: "Q8_0",+ defaultVariant: "Q4_K_M",+ })?.quant,+ "Q6_K",+ );+});++test("the resident quant takes priority over the repository default", () => {+ assert.equal(+ resolveLocalGgufVariant(variants, {+ activeVariant: "q8_0",+ defaultVariant: "Q4_K_M",+ })?.quant,+ "Q8_0",+ );+});++test("selection falls back through default, first variant, and empty state", () => {+ assert.equal(+ resolveLocalGgufVariant(variants, {+ activeVariant: "missing",+ defaultVariant: "q4_k_m",+ })?.quant,+ "Q4_K_M",+ );+ assert.equal(resolveLocalGgufVariant(variants, {})?.quant, "Q4_K_M");+ assert.equal(resolveLocalGgufVariant([], {}), null);+ assert.equal(resolveLocalGgufVariant(null, {}), null);+});++test("blank preferences preserve the first-variant fallback", () => {+ const withBlankQuant = [{ quant: "Q4_K_M" }, { quant: "" }];+ assert.equal(resolveLocalGgufVariant(withBlankQuant, {})?.quant, "Q4_K_M");+ assert.equal(+ resolveLocalGgufVariant(withBlankQuant, {+ selectedVariant: null,+ activeVariant: null,+ defaultVariant: null,+ })?.quant,+ "Q4_K_M",+ );+ assert.equal(+ resolveLocalGgufVariant(withBlankQuant, {+ selectedVariant: " ",+ activeVariant: "",+ })?.quant,+ "Q4_K_M",+ );+ assert.equal(+ resolveLocalGgufVariant([{ quant: "" }, { quant: "Q8_0" }], {+ selectedVariant: "Q8_0",+ })?.quant,+ "Q8_0",+ );+});++const localVariants = [+ { quant: "", filename: "blank-key.gguf", size_bytes: 100 * 1024 ** 3 },+ { quant: "Q4_K_M", filename: "model-Q4_K_M.gguf", size_bytes: 4 * 1024 ** 3 },+ { quant: "Q8_0", filename: "model-Q8_0.gguf", size_bytes: 8 * 1024 ** 3 },+];++test("sorting and selection ignore blank defaults", () => {+ for (const defaultVariant of [undefined, null, "", " \t\n", "missing"]) {+ const sorted = sortLocalGgufVariants(localVariants, {+ defaultVariant,+ gpuGb: 24,+ });+ assert.deepEqual(sorted, [+ localVariants[2],+ localVariants[1],+ localVariants[0],+ ]);+ assert.equal(+ resolveLocalGgufVariant(sorted, { defaultVariant }),+ localVariants[2],+ );+ }+ assert.deepEqual(+ localVariants.map((variant) => variant.quant),+ ["", "Q4_K_M", "Q8_0"],+ );+});++test("blank selections preserve resident and default preferences after sorting", () => {+ const defaultVariant = " q4_k_m ";+ const sorted = sortLocalGgufVariants(localVariants, {+ defaultVariant,+ gpuGb: 24,+ });+ assert.equal(sorted[0], localVariants[1]);+ for (const selectedVariant of [undefined, null, "", " \t\n", "missing"]) {+ assert.equal(+ resolveLocalGgufVariant(sorted, {+ selectedVariant,+ activeVariant: " q8_0 ",+ defaultVariant,+ }),+ localVariants[2],+ );+ assert.equal(+ resolveLocalGgufVariant(sorted, {+ selectedVariant,+ activeVariant: " ",+ defaultVariant,+ }),+ localVariants[1],+ );+ }+});++test("a blank-quant variant remains eligible for the ranked fallback", () => {+ const blank = {+ quant: "",+ filename: "blank-key.gguf",+ size_bytes: 4 * 1024 ** 3,+ };+ const oversized = {+ quant: "Q8_0",+ filename: "model-Q8_0.gguf",+ size_bytes: 100 * 1024 ** 3,+ };+ const sorted = sortLocalGgufVariants([oversized, blank], { gpuGb: 24 });+ assert.equal(resolveLocalGgufVariant(sorted, {}), blank);+});diff --git a/studio/frontend/tests/hub-media-run-gate.test.ts b/studio/frontend/tests/hub-media-run-gate.test.tsindex 25373ed3d40..1ef8fb60389 100644--- a/studio/frontend/tests/hub-media-run-gate.test.ts+++ b/studio/frontend/tests/hub-media-run-gate.test.ts@@ -4,37 +4,98 @@import assert from "node:assert/strict";import test from "node:test";-import { routableToMediaPage } from "../src/features/hub/lib/local-path.ts";+import type { SelectedModelView } from "../src/features/hub/types.ts";import { studioPageForTask } from "../src/features/hub/lib/unsloth-support.ts";+import { registerBundlerResolver } from "./helpers/kit.ts";-// What the inspector must decide before enabling Run, and what runSelectedModel requires-// before navigating. They have to agree: the handler falls through to the chat loader for a-// row it cannot route, and that unloads the resident model for a load that can only fail.-const runsOnMediaPage = (- task: string | null | undefined,+registerBundlerResolver();++const { isHubModelRunEligible } = await import(+ "../src/features/hub/lib/model-run-selection.ts"+);+const { taskForMediaPick } = await import(+ "../src/features/model-picker/components/model-selector/audio-picker-policy.ts"+);++function mediaModel(+ task: SelectedModelView["pipelineTag"],kind: "discover" | "cache" | "local",- localSource?: string | null,-) => studioPageForTask(task) !== undefined && routableToMediaPage(kind, localSource);+ localSource?: SelectedModelView["localSource"],+): SelectedModelView {+ const loadId = "/cache/models--Org--Model/snapshots/revision";+ return {+ id: kind === "local" ? loadId : "Org/Model",+ loadId,+ kind,+ displayId: "Org/Model",+ hubRepoId: "Org/Model",+ owner: "Org",+ title: "Model",+ summary: "Model",+ sourceLabel: "Hub cache",+ path: loadId,+ localSource,+ isLocal: kind === "local",+ isGguf: false,+ modelFormat: "safetensors",+ isDownloaded: true,+ runtimeCanChat: false,+ capabilities: [],+ license: null,+ pipelineTag: task,+ };+}++function mediaRunEligible(model: SelectedModelView): boolean {+ const task = taskForMediaPick(model.pipelineTag, model.task);+ return isHubModelRunEligible({+ model,+ isDataset: false,+ mediaRuntime: studioPageForTask(task ?? undefined) !== undefined,+ nonGgufRuntimeAvailable: false,+ });+}// The backend tags a local non-GGUF diffusers checkpoint text-to-image (_local_model_task),// and it does that for every local row whatever its source, so these rows are real.test("a filesystem diffusion row never counts as running on a media page", () => {- assert.equal(runsOnMediaPage("text-to-image", "local", "models_dir"), false);- assert.equal(runsOnMediaPage("text-to-image", "local", "lmstudio"), false);- assert.equal(runsOnMediaPage("text-to-image", "local", "ollama"), false);- assert.equal(runsOnMediaPage("text-to-video", "local", "custom"), false);- assert.equal(runsOnMediaPage("text-to-image", "local", undefined), false);+ assert.equal(+ mediaRunEligible(mediaModel("text-to-image", "local", "models_dir")),+ false,+ );+ assert.equal(+ mediaRunEligible(mediaModel("text-to-image", "local", "lmstudio")),+ false,+ );+ assert.equal(+ mediaRunEligible(mediaModel("text-to-image", "local", "ollama")),+ false,+ );+ assert.equal(+ mediaRunEligible(mediaModel("text-to-video", "local", "custom")),+ false,+ );+ assert.equal(mediaRunEligible(mediaModel("text-to-image", "local")), false);});-test("hub-backed diffusion rows stay runnable on their page", () => {+test("complete Hub-backed diffusion rows stay runnable on their page", () => {// An hf_cache row is a complete Hub snapshot, so it routes like a cached repo.- assert.equal(runsOnMediaPage("text-to-image", "local", "hf_cache"), true);- assert.equal(runsOnMediaPage("text-to-image", "cache"), true);- assert.equal(runsOnMediaPage("image-text-to-video", "discover"), true);+ assert.equal(+ mediaRunEligible(mediaModel("text-to-image", "local", "hf_cache")),+ true,+ );+ assert.equal(mediaRunEligible(mediaModel("text-to-image", "cache")), true);+ assert.equal(+ mediaRunEligible(mediaModel("image-text-to-video", "discover")),+ true,+ );});-test("a chat task is unaffected by the media gate", () => {- assert.equal(runsOnMediaPage("text-generation", "cache"), false);- assert.equal(runsOnMediaPage(null, "discover"), false);- assert.equal(runsOnMediaPage("text-generation", "local", "hf_cache"), false);+test("chat tasks are not eligible through the media route", () => {+ assert.equal(mediaRunEligible(mediaModel("text-generation", "cache")), false);+ assert.equal(mediaRunEligible(mediaModel(undefined, "discover")), false);+ assert.equal(+ mediaRunEligible(mediaModel("text-generation", "local", "hf_cache")),+ false,+ );});diff --git a/studio/frontend/tests/hub-model-run-selection.test.ts b/studio/frontend/tests/hub-model-run-selection.test.tsnew file mode 100644index 00000000000..c8b9fe47775--- /dev/null+++ b/studio/frontend/tests/hub-model-run-selection.test.ts@@ -0,0 +1,481 @@+// 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 test from "node:test";++import type { SelectedModelView } from "../src/features/hub/types.ts";+import { registerBundlerResolver } from "./helpers/kit.ts";++registerBundlerResolver();++const { createHubModelConfigHandoff, isHubModelRunEligible } = await import(+ "../src/features/hub/lib/model-run-selection.ts"+);+const { modelConfigTarget } = await import(+ "../src/features/model-picker/model-config/model-config-handoff.ts"+);++function selectedModel(+ overrides: Partial<SelectedModelView> = {},+): SelectedModelView {+ return {+ id: "Org/Model",+ loadId: "/cache/models--Org--Model/snapshots/revision",+ kind: "cache",+ displayId: "Org/Model",+ hubRepoId: "Org/Model",+ owner: "Org",+ title: "Model",+ summary: "Model",+ sourceLabel: "Hub cache",+ path: "/cache/models--Org--Model/snapshots/revision",+ isLocal: false,+ isGguf: false,+ modelFormat: "safetensors",+ isDownloaded: true,+ runtimeCanChat: true,+ capabilities: [],+ license: null,+ ...overrides,+ };+}++function localModel(+ id: string,+ overrides: Partial<SelectedModelView> = {},+): SelectedModelView {+ return selectedModel({+ id,+ loadId: id,+ kind: "local",+ displayId: id,+ hubRepoId: null,+ path: id,+ localSource: "custom",+ isLocal: true,+ ...overrides,+ });+}++function eligible(+ model: SelectedModelView,+ overrides: Partial<{+ isDataset: boolean;+ mediaRuntime: boolean;+ nonGgufRuntimeAvailable: boolean;+ }> = {},+): boolean {+ return isHubModelRunEligible({+ model,+ isDataset: false,+ mediaRuntime: false,+ nonGgufRuntimeAvailable: true,+ ...overrides,+ });+}++test("only complete chat-loadable models in supported formats are eligible", () => {+ assert.equal(eligible(selectedModel()), true);+ assert.equal(+ eligible(+ selectedModel({+ isGguf: true,+ modelFormat: "gguf",+ requiresVariant: true,+ }),+ { nonGgufRuntimeAvailable: false },+ ),+ true,+ );+ assert.equal(eligible(selectedModel(), { isDataset: true }), false);+ assert.equal(+ eligible(selectedModel(), { nonGgufRuntimeAvailable: false }),+ false,+ );+ assert.equal(eligible(selectedModel({ runtimeCanChat: false })), false);+ assert.equal(eligible(selectedModel({ isDownloaded: false })), false);+ assert.equal(eligible(selectedModel({ isPartial: true })), false);+ assert.equal(eligible(selectedModel({ loadId: null })), false);++ assert.equal(eligible(selectedModel({ modelFormat: "checkpoint" })), true);+ assert.equal(eligible(selectedModel({ modelFormat: "adapter" })), true);+ assert.equal(+ eligible(selectedModel({ modelFormat: "checkpoint" }), {+ nonGgufRuntimeAvailable: false,+ }),+ false,+ );+ assert.equal(+ eligible(selectedModel({ modelFormat: "adapter" }), {+ nonGgufRuntimeAvailable: false,+ }),+ false,+ );+ assert.equal(eligible(selectedModel({ modelFormat: "unknown" })), false);+});++test("complete Hub-backed media models are eligible for their dedicated runtime", () => {+ const mediaModel = selectedModel({+ pipelineTag: "text-to-image",+ runtimeCanChat: false,+ });++ assert.equal(+ eligible(mediaModel, {+ mediaRuntime: true,+ nonGgufRuntimeAvailable: false,+ }),+ true,+ );+ assert.equal(+ eligible(mediaModel, { mediaRuntime: true, isDataset: true }),+ false,+ );+ assert.equal(+ eligible(selectedModel({ isDownloaded: false }), { mediaRuntime: true }),+ false,+ );+ assert.equal(+ eligible(selectedModel({ isPartial: true }), { mediaRuntime: true }),+ false,+ );+ assert.equal(+ eligible(selectedModel({ hubRepoId: null }), { mediaRuntime: true }),+ false,+ );+ assert.equal(+ eligible(localModel("/models/image-model"), { mediaRuntime: true }),+ false,+ );+ assert.equal(+ eligible(+ localModel("/inactive-cache/image-model", {+ hubRepoId: "Org/Image-Model",+ localSource: "hf_cache",+ runtimeCanChat: false,+ }),+ { mediaRuntime: true },+ ),+ true,+ );+});++test("embedding-only non-GGUF models never enter the Chat run flow", () => {+ const embedding = { key: "embedding" as const, label: "Embeddings" };++ for (const pipelineTag of [+ "feature-extraction",+ "sentence-similarity",+ " text-embeddings-inference ",+ ]) {+ assert.equal(+ eligible(selectedModel({ pipelineTag, capabilities: [embedding] })),+ false,+ pipelineTag,+ );+ }+ assert.equal(eligible(selectedModel({ capabilities: [embedding] })), false);+ assert.equal(+ eligible(+ selectedModel({+ capabilities: [+ embedding,+ { key: "conversational", label: "Conversational" },+ ],+ }),+ ),+ true,+ );+ assert.equal(+ eligible(+ selectedModel({+ isGguf: true,+ modelFormat: "gguf",+ pipelineTag: "feature-extraction",+ capabilities: [embedding],+ }),+ ),+ true,+ );+});++test("checkpoint handoffs use the whole-model Chat identity", () => {+ const request = createHubModelConfigHandoff({+ requestId: "request-checkpoint",+ model: selectedModel({ modelFormat: "checkpoint" }),+ selection: {},+ });++ assert.equal(request?.id, "Org/Model");+ assert.equal(request?.meta.isLora, false);+ assert.equal(request?.meta.isGguf, false);+ assert.equal(+ createHubModelConfigHandoff({+ requestId: "request-checkpoint-variant",+ model: selectedModel({ modelFormat: "checkpoint" }),+ selection: { ggufVariant: "Q4_K_M" },+ }),+ null,+ );+});++test("adapter handoffs preserve loader identity and LoRA intent", () => {+ const loadId = String.raw`C:\Models\adapter`;+ const localRequest = createHubModelConfigHandoff({+ requestId: "request-adapter",+ model: localModel(loadId, {+ modelFormat: "adapter",+ }),+ selection: {},+ });++ assert.deepEqual(localRequest, {+ requestId: "request-adapter",+ id: loadId,+ displayName: "Model",+ meta: {+ source: "local",+ isLora: true,+ loadId,+ isDownloaded: true,+ isGguf: false,+ pipelineTag: null,+ },+ });++ const cachedLoadId =+ "/inactive-cache/models--Org--Adapter/snapshots/revision";+ const cachedRequest = createHubModelConfigHandoff({+ requestId: "request-cached-adapter",+ model: localModel(cachedLoadId, {+ hubRepoId: "Org/Adapter",+ localSource: "hf_cache",+ modelFormat: "adapter",+ }),+ selection: {},+ });++ assert.ok(cachedRequest);+ assert.equal(cachedRequest.id, "Org/Adapter");+ assert.equal(cachedRequest.meta.source, "hub");+ assert.equal(cachedRequest.meta.loadId, cachedLoadId);+ assert.equal(cachedRequest.meta.isLora, true);++ const target = modelConfigTarget(+ cachedRequest.id,+ cachedRequest.meta,+ cachedRequest.displayName,+ );+ assert.equal(target.id, cachedLoadId);+ assert.equal(target.configId, "Org/Adapter");+ assert.equal(target.meta.isLora, true);+});++test("MLX safetensors follow runtime availability", () => {+ const models = [+ selectedModel({ libraryName: " MLX " }),+ selectedModel({ tags: ["transformers", "MLX"] }),+ selectedModel({+ id: "mlx-community/Model",+ hubRepoId: "mlx-community/Model",+ }),+ selectedModel({+ id: "Org/Model-MLX-4bit",+ hubRepoId: "Org/Model-MLX-4bit",+ }),+ localModel(String.raw`C:\Models\mlx-community\Qwen2`),+ ];++ for (const model of models) {+ assert.equal(eligible(model), true);+ assert.equal(eligible(model, { nonGgufRuntimeAvailable: false }), false);+ assert.notEqual(+ createHubModelConfigHandoff({+ requestId: "request-mlx",+ model,+ selection: {},+ }),+ null,+ );+ }+});++test("GGUF remains runnable when its conversion retains an MLX identity", () => {+ const models = [+ selectedModel({+ id: "mlx-community/Model-MLX-GGUF",+ hubRepoId: "mlx-community/Model-MLX-GGUF",+ isGguf: true,+ modelFormat: "gguf",+ requiresVariant: true,+ tags: ["mlx", "gguf"],+ libraryName: "mlx",+ }),+ localModel(String.raw`C:\Models\mlx-community\Model.gguf`, {+ isGguf: true,+ modelFormat: "gguf",+ requiresVariant: true,+ tags: ["mlx", "gguf"],+ libraryName: "mlx",+ }),+ ];++ for (const model of models) {+ assert.equal(eligible(model), true);+ assert.notEqual(+ createHubModelConfigHandoff({+ requestId: "request-gguf",+ model,+ selection: {+ ggufVariant: "Q4_K_M",+ ggufFilename: "model-Q4_K_M.gguf",+ },+ }),+ null,+ );+ }+});++test("managed cache handoffs retain separate public, loader, and GGUF identities", () => {+ const loadId = String.raw`C:\Users\alice\.cache\models--Org--Model\snapshots\revision`;+ const ggufVariant = " builds/Q4 K M ";+ const ggufFilename = " builds/My Model Q4 K M.gguf ";+ const request = createHubModelConfigHandoff({+ requestId: "request-1",+ model: selectedModel({+ id: "cache:gguf:Org%2FModel",+ loadId,+ isGguf: true,+ modelFormat: "gguf",+ requiresVariant: true,+ task: "text-generation",+ }),+ selection: {+ ggufVariant,+ ggufFilename,+ expectedBytes: 4096,+ },+ });++ assert.deepEqual(request, {+ requestId: "request-1",+ id: "Org/Model",+ displayName: "Model",+ meta: {+ source: "hub",+ isLora: false,+ loadId,+ isDownloaded: true,+ isGguf: true,+ pipelineTag: "text-generation",+ ggufVariant,+ ggufFilename,+ expectedBytes: 4096,+ },+ });+});++test("matched Discover rows keep the Chat picker's local configuration identity", () => {+ const loadId = "/mnt/c/models/Org/Model";+ const request = createHubModelConfigHandoff({+ requestId: "request-2",+ model: selectedModel({+ id: loadId,+ loadId,+ kind: "local",+ hubRepoId: "Org/Model",+ isLocal: true,+ localSource: "custom",+ }),+ selection: {},+ });++ assert.equal(request?.id, loadId);+ assert.equal(request?.meta.source, "local");+ assert.equal(request?.meta.loadId, loadId);+});++test("opaque local loader identities remain unchanged on every desktop path style", () => {+ const loadIds = [+ String.raw`C:\Models\Family\Model.gguf`,+ String.raw`\\server\models\Model.gguf`,+ "/mnt/c/Models/Family/Model.gguf",+ "/home/alice/models/Model.gguf",+ "/Users/alice/Models/Model.gguf",+ "ollama-manifest:library/model:latest",+ ];++ for (const loadId of loadIds) {+ const request = createHubModelConfigHandoff({+ requestId: loadId,+ model: selectedModel({+ id: loadId,+ loadId,+ kind: "local",+ hubRepoId: null,+ path: loadId,+ isLocal: true,+ localSource: loadId.startsWith("ollama-") ? "ollama" : "custom",+ isGguf: true,+ modelFormat: "gguf",+ }),+ selection: {},+ });++ assert.equal(request?.id, loadId);+ assert.equal(request?.meta.loadId, loadId);+ }+});++test("opaque local identities retain the inventory display name", () => {+ const request = createHubModelConfigHandoff({+ requestId: "ollama-display",+ model: selectedModel({+ id: "ollama-manifest:%2Fhome%2Fhz%2F.ollama%2Fmodels%2Fmanifests%2Flibrary%2Fllama",+ loadId:+ "ollama-manifest:%2Fhome%2Fhz%2F.ollama%2Fmodels%2Fmanifests%2Flibrary%2Fllama",+ title: "Llama 3.2",+ kind: "local",+ hubRepoId: null,+ isLocal: true,+ localSource: "ollama",+ isGguf: true,+ modelFormat: "gguf",+ }),+ selection: {},+ });++ assert.equal(request?.displayName, "Llama 3.2");+});++test("invalid format and variant combinations fail closed", () => {+ assert.equal(+ createHubModelConfigHandoff({+ requestId: "missing-variant",+ model: selectedModel({+ isGguf: true,+ modelFormat: "gguf",+ requiresVariant: true,+ }),+ selection: {},+ }),+ null,+ );+ assert.equal(+ createHubModelConfigHandoff({+ requestId: "unexpected-variant",+ model: selectedModel(),+ selection: { ggufVariant: "Q4_K_M" },+ }),+ null,+ );+ assert.equal(+ createHubModelConfigHandoff({+ requestId: "partial",+ model: selectedModel({ isPartial: true }),+ selection: {},+ }),+ null,+ );+});diff --git a/studio/frontend/tests/hub-resident-status.test.ts b/studio/frontend/tests/hub-resident-status.test.tsindex 9c201697476..fd4ef28fc26 100644--- a/studio/frontend/tests/hub-resident-status.test.ts+++ b/studio/frontend/tests/hub-resident-status.test.ts@@ -38,9 +38,8 @@ function refusing(messages: {};}-test("landing on the Hub applies the whole status, not just the checkpoint", () => {- // Nothing else on /hub hydrates the runtime store, so pinning only the checkpoint- // leaves useActiveModelConfig at its defaults and the settings page offers those.+test("landing on the Hub synchronizes the full resident status", () => {+ // Cache mutation guards read the same resident store as Chat.const { calls, actions } = spies();const adopted = adoptResidentModelStatus(RESIDENT, emptyStore(), actions);assert.equal(adopted, true);@@ -107,7 +106,7 @@ test("nothing is adopted when no model is loaded", () => {});test("an external-provider selection is left alone", () => {- // No local mirror, so the resident GGUF's settings would describe the wrong model.+ // An external selection has no local runtime mirror.const { calls, actions } = spies();const adopted = adoptResidentModelStatus(RESIDENT,@@ -134,8 +133,7 @@ test("a load in flight is not fought", () => {});test("an empty status drops the checkpoint when idle unload is disarmed", () => {- // Nothing will bring the model back, so it really is gone. Leaving the row resident would- // seed the settings editor from a launch config nothing is running.+ // Nothing will bring the model back, so it really is gone.const cleared: string[] = [];const adopted = adoptResidentModelStatus({ checkpointId: null, ggufVariant: null },@@ -174,8 +172,6 @@ test("an empty status leaves the checkpoint pinned while idle unload is armed",});test("a speech model in the slot clears the pick even while idle unload is armed", () => {- // Not the idle eviction the rule above is about: an Audio load took the single slot and- // no stash reloads the chat model, so holding the pick left the Hub calling it Loaded.const cleared: string[] = [];const adopted = adoptResidentModelStatus({ checkpointId: null, ggufVariant: null, speechOnly: true },@@ -217,7 +213,7 @@ test("an empty status leaves an external pick alone", () => {}),refusing({setCheckpoint: "an external pick is not a local model",- applyStatus: "the resident GGUF's status describes another model",+ applyStatus: "the resident GGUF belongs to another runtime",}),);assert.equal(adopted, false);@@ -268,10 +264,7 @@ test("a tab going hidden does not read", () => {assert.equal(reads, 1);});-test("an auto-switch under a mounted Hub stops hiding the live config", () => {- // End to end: an API request swaps the resident model under a mounted Hub. Without a second- // read settingsTargetIsResident says it is not resident, so the editor seeds from saved- // values that Apply then reloads over the API's choice.+test("an auto-switch under a mounted Hub updates the mutation guard", () => {const store = emptyStore({checkpoint: "unsloth/Qwen3-8B-GGUF",activeGgufVariant: "Q4_K_M",@@ -295,8 +288,7 @@ test("an auto-switch under a mounted Hub stops hiding the live config", () => {);};- // hub-page.tsx's settingsTargetIsResident, for the model the API just loaded.- const settingsTargetIsResident = () =>+ const selectedModelIsResident = () =>residentModelIdMatches(store.checkpoint, serverStatus.checkpointId) &&ggufVariantsMatch(store.activeGgufVariant, serverStatus.ggufVariant);@@ -304,12 +296,12 @@ test("an auto-switch under a mounted Hub stops hiding the live config", () => {subscribeResidentStatusRefresh(readStatusAndAdopt, targets);assert.equal(- settingsTargetIsResident(),+ selectedModelIsResident(),false,"precondition: the mount-time read predates the switch",);targets.fire("window", "focus");- assert.equal(settingsTargetIsResident(), true);+ assert.equal(selectedModelIsResident(), true);// A load this tab started owns the store until it settles, so a mid-switch refresh// must not re-pin the model being moved away from.diff --git a/studio/frontend/tests/hub-runtime-boundary.test.ts b/studio/frontend/tests/hub-runtime-boundary.test.tsnew file mode 100644index 00000000000..3bd66fed69b--- /dev/null+++ b/studio/frontend/tests/hub-runtime-boundary.test.ts@@ -0,0 +1,352 @@+// 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 { existsSync, readFileSync, readdirSync } from "node:fs";+import path from "node:path";+import { test } from "node:test";+import { fileURLToPath } from "node:url";++const HERE = path.dirname(fileURLToPath(import.meta.url));+const FRONTEND_ROOT = path.join(HERE, "..");+const HUB_ROOT = path.join(FRONTEND_ROOT, "src/features/hub");++function sourceFiles(directory: string): string[] {+ return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {+ const target = path.join(directory, entry.name);+ if (entry.isDirectory()) return sourceFiles(target);+ return /\.(?:ts|tsx)$/.test(entry.name) ? [target] : [];+ });+}++const HUB_SOURCE_FILES = sourceFiles(HUB_ROOT);+const HUB_SOURCES = HUB_SOURCE_FILES.map((file) =>+ readFileSync(file, "utf8"),+).join("\n");+const HUB_RENDER_SOURCES = `${HUB_SOURCES}\n${readFileSync(+ path.join(HUB_ROOT, "hub.css"),+ "utf8",+)}`;++test("obsolete Hub action and settings modules stay removed", () => {+ const removedModules = [+ "catalog/hub-model-settings-view.tsx",+ "inventory/settings-identity.ts",+ "lib/hub-feature-flags.ts",+ ];++ for (const modulePath of removedModules) {+ assert.equal(+ existsSync(path.join(HUB_ROOT, modulePath)),+ false,+ modulePath,+ );+ }+});++test("the Hub no longer owns model runtime actions or model configuration", () => {+ const removedIdentifiers = [+ "HubModelSettingsView",+ "useChatModelRuntime",+ "ModelConfigPage",+ "PerModelConfig",+ "modelConfigIdentity",+ "settingsGgufVariantForRow",+ "openSelectedModelSettings",+ "onOpenModelSettings",+ "CardSettingsButton",+ "settingsTarget",+ "runSelectedModel",+ "openNewChat",+ "loadingPhase",+ "runtimeCapabilities",+ "SelectedResourceRef",+ ];++ for (const identifier of removedIdentifiers) {+ assert.equal(HUB_SOURCES.includes(identifier), false, identifier);+ }+});++test("residency remains a cache mutation safety input", () => {+ const hubPage = readFileSync(path.join(HUB_ROOT, "hub-page.tsx"), "utf8");+ const adoptionSource = readFileSync(+ path.join(HUB_ROOT, "lib/adopt-inference-status.ts"),+ "utf8",+ );+ const ggufCard = readFileSync(+ path.join(HUB_ROOT, "catalog/gguf-download-card.tsx"),+ "utf8",+ );+ const localCard = readFileSync(+ path.join(HUB_ROOT, "catalog/local-on-device-card.tsx"),+ "utf8",+ );+ const safetensorsCard = readFileSync(+ path.join(HUB_ROOT, "catalog/safetensors-download-card.tsx"),+ "utf8",+ );++ assert.match(hubPage, /getInferenceStatus\(\)/);+ assert.match(hubPage, /adoptResidentModelStatus\(/);+ assert.match(+ hubPage,+ /Promise\.all\(\[getInferenceStatus\(\), readIdleUnloadArmed\(\)\]\)\s*\.then\(\(\[status, idleUnloadArmed\]\) => \{/,+ );+ assert.match(+ hubPage,+ /adoptResidentModelStatus\([\s\S]*?modelLoading: store\.modelLoading,\s*idleUnloadArmed: preserveIdleUnloaded && idleUnloadArmed,/,+ );+ assert.match(hubPage, /\.catch\(\(\) => idleUnloadArmed\.current\)/);+ assert.match(+ hubPage,+ /applyStatus: \(previous\) => \{\s*applyActiveModelStatusToStore\(status, \{/,+ );+ assert.match(+ hubPage,+ /adoptingExistingServerModel:\s*previous\.checkpoint === null \|\| previous\.checkpoint === "",/,+ );+ assert.match(+ hubPage,+ /checkpointId: isSpeechOnlyStatus\(status\)\s*\? null\s*: resolveInferenceCheckpointId\(status\),/,+ );+ assert.match(hubPage, /speechOnly: isSpeechOnlyStatus\(status\),/);+ assert.doesNotMatch(hubPage, /setCheckpoint\(status\.active_model/);+ assert.match(+ adoptionSource,+ /state\.idleUnloadArmed && !status\.speechOnly/,+ );+ assert.match(+ hubPage,+ /subscribeResidentStatusRefresh\(\s*refreshResidentModelStatus/,+ );+ assert.match(+ hubPage,+ /subscribeModelLifecycle\(\(\{ runtime \}\) => \{\s*if \(runtime === "chat" \|\| runtime === "stt"\) return;\s*void refreshResidentModelStatus\(\{ preserveIdleUnloaded: false \}\);\s*\}\)/,+ );+ assert.match(+ hubPage,+ /idleUnloadArmed: preserveIdleUnloaded && idleUnloadArmed/,+ );+ assert.ok((hubPage.match(/residentModelIdMatches\(/g) ?? []).length >= 2);+ assert.ok((hubPage.match(/selectedModel\.loadId/g) ?? []).length >= 2);+ assert.match(hubPage, /runtime=\{inspectorRuntime\}/);++ const selectedView = readFileSync(+ path.join(HUB_ROOT, "hooks/use-selected-model-view.ts"),+ "utf8",+ );+ assert.match(selectedView, /loadId: selectedCachedRow\.loadId/);+ assert.match(+ selectedView,+ /loadId: selectedCachedRow\?\.loadId \?\? selectedLocalRow\?\.loadId \?\? null/,+ );++ assert.match(+ ggufCard,+ /mutationBlocked=\{\s*runPending \|\|\s*isLoadingThisModel \|\|\s*\(isActive && item\.key === activeVariantKey\)/,+ );+ assert.match(+ ggufCard,+ /canDelete=\{[\s\S]*?!selectedIsActive[\s\S]*?!isLoadingThisModel[\s\S]*?\}/,+ );+ assert.match(+ ggufCard,+ /const showUpdateAction =[\s\S]*?!selectedIsActive[\s\S]*?!isLoadingThisModel[\s\S]*?;/,+ );+ assert.match(+ localCard,+ /const canUpdate =[\s\S]*?!isActive &&[\s\S]*?!isLoading &&[\s\S]*?updateAvailable;/,+ );+ assert.match(+ localCard,+ /const canDelete =[\s\S]*?!isActive &&[\s\S]*?!isLoading[\s\S]*?;/,+ );+ assert.match(+ safetensorsCard,+ /const canDelete =[\s\S]*?!isActive &&[\s\S]*?!isLoadingThisModel &&[\s\S]*?!runPending;/,+ );+});++test("the Hub routes Run to its owning workflow without owning runtime actions", () => {+ const hubPage = readFileSync(path.join(HUB_ROOT, "hub-page.tsx"), "utf8");+ const modelInspector = readFileSync(+ path.join(HUB_ROOT, "catalog/model-inspector.tsx"),+ "utf8",+ );+ const ggufCard = readFileSync(+ path.join(HUB_ROOT, "catalog/gguf-download-card.tsx"),+ "utf8",+ );+ const localCard = readFileSync(+ path.join(HUB_ROOT, "catalog/local-on-device-card.tsx"),+ "utf8",+ );+ const safetensorsCard = readFileSync(+ path.join(HUB_ROOT, "catalog/safetensors-download-card.tsx"),+ "utf8",+ );++ assert.match(HUB_RENDER_SOURCES, /hub-run-action-btn/);+ assert.match(HUB_RENDER_SOURCES, />\s*Run\s*</);+ assert.match(+ hubPage,+ /clearNewChatDraft\(\);[\s\S]*?setActiveThreadId\(null\);[\s\S]*?setActiveProjectId\(null\);[\s\S]*?setIncognito\(false\);[\s\S]*?requestModelConfigHandoff\(request\)/,+ );+ assert.match(hubPage, /requestModelConfigHandoff\(request\)/);+ assert.match(hubPage, /to: "\/chat", search: \{ new: requestId \}/);+ assert.match(+ modelInspector,+ /const mediaPage = studioPageForTask\([\s\S]*?taskForMediaPick\(model\.pipelineTag, model\.task\)/,+ );+ assert.match(+ hubPage,+ /routableToMediaPage\(selectedModel\.kind, selectedModel\.localSource\)/,+ );+ assert.match(+ hubPage,+ /to: `\/\$\{mediaPage\}`,[\s\S]*?diffusionRouteSearch\(selectedModel\.hubRepoId, selection\)/,+ );+ assert.match(+ hubPage,+ /const controller = runConfigOpenCoordinator\.begin\(\);[\s\S]*?await waitForRunConfigRefresh\(\s*refreshResidentModelStatus\(\),\s*controller\.signal,\s*\);\s*if \(controller\.signal\.aborted\) return;/,+ );+ assert.match(hubPage, /const RUN_CONFIG_REFRESH_TIMEOUT_MS = 5_000;/);+ assert.match(+ hubPage,+ /const handleCloseDetail = useCallback\(\(\) => \{\s*runConfigOpenCoordinator\.cancel\(\);\s*setRunConfigOpening\(null\);/,+ );+ assert.match(HUB_RENDER_SOURCES, /Opening…/);+ assert.match(HUB_RENDER_SOURCES, /aria-busy=\{loading\}/);+ assert.match(ggufCard, /open=\{runPending \? false : open\}/);+ assert.match(ggufCard, /disabled=\{runPending\}/);+ assert.match(localCard, /open=\{runPending \? false : variantOpen\}/);+ assert.match(+ localCard,+ /disabled=\{currentVariantState\.loading \|\| runPending\}/,+ );+ assert.match(+ localCard,+ /label=\{`Configure and run \$\{displayName\.trim\(\) \|\| "this model"\}`\}/,+ );+ assert.doesNotMatch(+ localCard,+ /label=\{`Configure and run \$\{repoId \?\? modelId\}`\}/,+ );+ assert.match(+ safetensorsCard,+ /const showRunAction =[^;]*?!isLoadingThisModel[^;]*?;/s,+ );+ assert.doesNotMatch(+ safetensorsCard,+ /const showRunAction =[^;]*?repoPeerActive[^;]*?;/s,+ );+ assert.match(+ ggufCard,+ /const showRunAction =[^;]*?!isLoadingThisModel[^;]*?;/s,+ );+ assert.match(+ localCard,+ /const showRunAction =[^;]*?!isLoading[^;]*?;/s,+ );+ assert.match(+ modelInspector,+ /s\.isChatOnly\(\) && !s\.capabilitiesUnknown\(\)/,+ );+ assert.match(+ modelInspector,+ /nonGgufRuntimeAvailable:\s*!chatOnlyMeasured &&\s*unslothSupport\.status !== "unsupported"/,+ );+ assert.match(modelInspector, /const runEligible = isHubModelRunEligible\(/);+ assert.match(+ modelInspector,+ /\? \(selection: HubModelRunSelection\) => onRun\(selection, mediaPage\)/,+ );+ assert.match(+ ggufCard,+ /const showRunAction =[^;]*?!downloadingThisVariant[^;]*?;/s,+ );+ assert.match(+ modelInspector,+ /<ModelStatusChips[\s\S]*?chatOnly=\{chatOnly\}/,+ );+ assert.doesNotMatch(+ HUB_RENDER_SOURCES,+ />\s*(?:Eject|Loaded|Use in Chat|New Chat|Train)\s*</,+ );+ assert.doesNotMatch(+ HUB_SOURCES,+ /\bonUseInChat\b|\bonEject\b|\bonTrain\b|\bejectModel\b|\bselectModel\b|\brunId\b/,+ );++ const filesWithOnLoad = HUB_SOURCE_FILES.filter((file) =>+ /\bonLoad(?:Local)?\b/.test(readFileSync(file, "utf8")),+ ).map((file) => path.relative(HUB_ROOT, file).split(path.sep).join("/"));++ // This is an image lifecycle callback, not a model runtime action.+ assert.deepEqual(filesWithOnLoad.sort(), ["catalog/owner-avatar.tsx"]);+});++test("the Run handoff opens configuration immediately and remains nonce-scoped", () => {+ const chatPage = readFileSync(+ path.join(FRONTEND_ROOT, "src/features/chat/chat-page.tsx"),+ "utf8",+ );+ const modelSelector = readFileSync(+ path.join(+ FRONTEND_ROOT,+ "src/features/model-picker/components/model-selector.tsx",+ ),+ "utf8",+ );++ assert.match(chatPage, /modelConfigHandoffForDestination\(state\.request,/);+ assert.match(+ chatPage,+ /active,\s*newChatId: search\.new,\s*threadId: search\.thread,\s*compareId: search\.compare,\s*projectId: search\.project,/,+ );+ assert.match(chatPage, /modelSelectorOpen \|\| modelConfigRequest !== null/);+ assert.match(modelSelector, /requestedConfigTarget \?\? configTarget/);+ assert.match(+ modelSelector,+ /aria-label=\{\s*visibleConfigTarget\s*\? `Run settings for \$\{visibleConfigTarget\.displayName\}`\s*:\s*undefined\s*\}/,+ );+ assert.match(+ modelSelector,+ /modelConfigInstanceKey\(\s*visibleConfigTarget\.configId \?\? visibleConfigTarget\.id,\s*visibleConfigTarget\.ggufVariant,\s*visibleLoadedConfig,/,+ );+ assert.match(+ modelSelector,+ /onRun=\{\(config, isDiffusion\) =>\s*onSelect\(\s*visibleConfigTarget\.configId \?\? visibleConfigTarget\.id,\s*\{/,+ );+ assert.match(+ modelSelector,+ /setAdoptedConfigRequestId\(configRequest\.requestId\);\s*setConfigTarget\(requestedConfigTarget\)/,+ );+ assert.match(+ modelSelector,+ /onConfigRequestAdopted\?\.\(configRequest\.requestId\)/,+ );+ assert.match(+ chatPage,+ /setSettingsOpen\(false\);\s*setModelSelectorLocked\(false\);\s*setModelSelectorOpen\(true\);\s*clearModelConfigHandoff\(requestId\)/,+ );+ assert.match(+ chatPage,+ /open=\{active && modelConfigRequest === null && settingsOpen\}/,+ );+});++test("the shared model row menu no longer offers Hub model settings", () => {+ const rowMenu = readFileSync(+ path.join(+ HERE,+ "..",+ "src/features/model-picker/components/model-selector/model-row-menu.tsx",+ ),+ "utf8",+ );++ assert.doesNotMatch(rowMenu, /ModelRowMenuSettings|Settings02Icon/);+ assert.doesNotMatch(rowMenu, />\s*Settings\s*</);+});diff --git a/studio/frontend/tests/hub-superseded-refresh.test.ts b/studio/frontend/tests/hub-superseded-refresh.test.tsindex 390d6334e6a..79fd574302e 100644--- a/studio/frontend/tests/hub-superseded-refresh.test.ts+++ b/studio/frontend/tests/hub-superseded-refresh.test.ts@@ -15,7 +15,7 @@ interface Status {ggufVariant: string;}-/** What the store holds before an API request switches the resident model under the tab. */+/** What the store holds before an API request switches the resident model. */const STALE: Status = {checkpoint: "unsloth/Qwen3-8B-GGUF",ggufVariant: "Q8_0",@@ -39,8 +39,8 @@ const flush = () => new Promise((r) => setTimeout(r, 0));/*** hub-page.tsx's refreshResidentModelStatus, with the status read held open so a test can- * choose the order responses land in. `coalesce` is the fix: whether a dropped response- * resolves with the refresh that superseded it or with nothing.+ * choose the order responses land in. `coalesce` controls whether a dropped response+ * waits for the refresh that superseded it.*/function hubPageRefresh(coalesce: boolean) {let seq = 0;@@ -88,19 +88,16 @@ async function settledEarly(promise: Promise<void>): Promise<boolean> {return done;}-test("a settings open waits out the focus refresh that superseded its own read", async () => {- // openModelSettings awaits a status read before it resolves a quant and builds the settings- // target. A window focus refresh started while that read was out takes the sequence number,- // so the settings read's response is dropped without writing the store.+test("the initial safety read waits out a newer focus refresh", async () => {const hub = hubPageRefresh(true);- const settingsRead = hub.refresh();+ const initialRead = hub.refresh();hub.refresh();hub.deliver(0);assert.equal(- await settledEarly(settingsRead),+ await settledEarly(initialRead),false,- "a dropped response must not release the settings open",+ "a dropped response must not release the safety gate",);assert.deepEqual(hub.store,@@ -109,51 +106,47 @@ test("a settings open waits out the focus refresh that superseded its own read",);hub.deliver(1);- await settingsRead;+ await initialRead;assert.deepEqual(hub.store, SWITCHED);});-test("without it the dropped response opens settings on the displaced model", async () => {- // The failure this guards: the settings handler's own sequence guard only counts settings- // opens, so a focus refresh supersedes it silently and it proceeds on the pre-switch store,- // naming the displaced model's quant in a target that Apply then loads and saves under.+test("without coalescing the dropped response releases stale state", async () => {const hub = hubPageRefresh(false);- const settingsRead = hub.refresh();+ const initialRead = hub.refresh();hub.refresh();hub.deliver(0);- assert.equal(await settledEarly(settingsRead), true);+ assert.equal(await settledEarly(initialRead), true);assert.deepEqual(hub.store, STALE);});test("every dropped response in a chain waits for the one read that wins", async () => {- // Focus and visibilitychange fire as a pair, so more than one refresh can pile up behind- // the settings read, and each one in turn is dropped.+ // Focus and visibilitychange can fire as a pair, so several reads may overlap.const hub = hubPageRefresh(true);- const settingsRead = hub.refresh();+ const initialRead = hub.refresh();hub.refresh();hub.refresh();hub.deliver(0);hub.deliver(1);- assert.equal(await settledEarly(settingsRead), false);+ assert.equal(await settledEarly(initialRead), false);assert.deepEqual(hub.store, STALE);hub.deliver(2);- await settingsRead;+ await initialRead;assert.deepEqual(hub.store, SWITCHED);});test("responses that land out of order still leave the store on the newest read", async () => {const hub = hubPageRefresh(true);- const settingsRead = hub.refresh();+ const initialRead = hub.refresh();hub.refresh();// The newest read answers first and writes the store; the older response is dropped and// finds its superseder already settled.hub.deliver(1);hub.deliver(0);- await settingsRead;+ await initialRead;assert.deepEqual(hub.store, SWITCHED);});diff --git a/studio/frontend/tests/llama-extra-args-panel-hydration.test.ts b/studio/frontend/tests/llama-extra-args-panel-hydration.test.tsindex db10a23c6ea..b768267730a 100644--- a/studio/frontend/tests/llama-extra-args-panel-hydration.test.ts+++ b/studio/frontend/tests/llama-extra-args-panel-hydration.test.ts@@ -94,18 +94,6 @@ test("a background auto-load hydrates a server-only override", () => {assert.match(ADAPTER, /candidate\.kind === "gguf" &&\s*\n?\s*!isDiffusion/);});-const HUB = readFileSync(- path.join(HERE, "..", "src/features/hub/hub-page.tsx"),- "utf8",-);--test("applying from the Hub settings page carries the arguments into the load", () => {- // applyPerModelConfigToRuntime does not store llamaExtraArgs, so a selection made- // without the config left the field undefined: the load omitted it, the route kept- // the resident server's old list, and an edit or a clear did nothing.- assert.match(HUB, /forceReload: true,\n(\s*\/\/.*\n)*\s*config,/);-});-test("a collapsed section stops objecting once nothing is left to object to", () => {// Reset with Advanced collapsed clears the list, and the row is not mounted to// withdraw the verdict it left standing, so Load stayed disabled.@@ -337,15 +325,11 @@ const CHAT_PAGE = readFileSync("utf8",);-test("a launch that only applies the remembered config still carries its arguments", () => {+test("a Chat launch that applies remembered config carries its arguments", () => {// applyPerModelConfigToRuntime has no field for the launch flags, and /load only// inherits them from the SAME resident model, so a cold launch or a switch from- // another model ran without the arguments this model was remembered with. Both- // paths that load through the runtime alone now pass the config itself.- assert.match(- HUB,- /\.\.\.\(rememberedConfig \? \{ config: rememberedConfig \} : \{\}\),/,- );+ // another model ran without the arguments this model was remembered with. Chat+ // passes the config itself.assert.match(CHAT_PAGE,/const remembered = rememberedConfigFor\(selection\);/,@@ -354,7 +338,4 @@ test("a launch that only applies the remembered config still carries its argumenCHAT_PAGE,/\.\.\.\(remembered \? \{ config: remembered \} : \{\}\),/,);- // Nothing is invented when there is no remembered config: the field stays absent,- // which is what lets /load keep a resident model's own flags.- assert.doesNotMatch(HUB, /config: rememberedConfig \?\? null/);});diff --git a/studio/frontend/tests/local-path.test.ts b/studio/frontend/tests/local-path.test.tsindex aefaf19405e..61db3a2d90f 100644--- a/studio/frontend/tests/local-path.test.ts+++ b/studio/frontend/tests/local-path.test.ts@@ -3,10 +3,7 @@import assert from "node:assert/strict";import test from "node:test";-import {- looksLikeLocalPath,- routableToMediaPage,-} from "../src/features/hub/lib/local-path.ts";+import { looksLikeLocalPath } from "../src/features/hub/lib/local-path.ts";test("recognizes local paths across supported operating systems", () => {for (const path of [@@ -33,16 +30,3 @@ test("does not classify Hugging Face repository identifiers as paths", () => {assert.equal(looksLikeLocalPath("HuggingFaceH4/ultrachat_200k"), false);assert.equal(looksLikeLocalPath("unsloth/Qwen3-4B"), false);});--test("an HF-cache row routes to the media pages, a filesystem row does not", () => {- // Inventory dedup can leave a complete hf_cache LOCAL row as the only row for a repo, and- // it carries the Hub id. Excluding it by kind sent a diffusion GGUF to the chat loader,- // where the backend refuses it, instead of to Images or Video.- assert.equal(routableToMediaPage("local", "hf_cache"), true);- assert.equal(routableToMediaPage("local", "models_dir"), false);- assert.equal(routableToMediaPage("local", "lmstudio"), false);- assert.equal(routableToMediaPage("local", "ollama"), false);- assert.equal(routableToMediaPage("local", null), false);- assert.equal(routableToMediaPage("cache", null), true);- assert.equal(routableToMediaPage("discover", null), true);-});diff --git a/studio/frontend/tests/model-config-handoff.test.ts b/studio/frontend/tests/model-config-handoff.test.tsnew file mode 100644index 00000000000..0959882c210--- /dev/null+++ b/studio/frontend/tests/model-config-handoff.test.ts@@ -0,0 +1,285 @@+// 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 test from "node:test";++import type { ModelConfigHandoffRequest } from "../src/features/model-picker/model-config/model-config-handoff.ts";+import {+ installLocalStorageFake,+ registerBundlerResolver,+} from "./helpers/kit.ts";++registerBundlerResolver();+const { store } = installLocalStorageFake();++const {+ clearModelConfigHandoff,+ createModelConfigHandoffRequestId,+ modelConfigHandoffForDestination,+ modelConfigTarget,+ modelConfigTargetIsResident,+ modelConfigTargetMatchesSelection,+ requestModelConfigHandoff,+ useModelConfigHandoffStore,+} = await import(+ "../src/features/model-picker/model-config/model-config-handoff.ts"+);+const { DEFAULT_PER_MODEL_CONFIG, resolveInitialConfig, savePerModelConfig } =+ await import("../src/features/model-picker/model-config/per-model-config.ts");++const FALLBACK_REQUEST_ID_RE = /^\d+-[a-z0-9]+$/;++function request(+ requestId: string,+ id: string,+ loadId: string,+): ModelConfigHandoffRequest {+ return {+ requestId,+ id,+ meta: {+ source: "hub",+ isLora: false,+ isDownloaded: true,+ loadId,+ },+ };+}++test("handoff request IDs work without native randomUUID", () => {+ assert.match(createModelConfigHandoffRequestId(null), FALLBACK_REQUEST_ID_RE);+ assert.match(+ createModelConfigHandoffRequestId({+ randomUUID: () => {+ throw new Error("unavailable");+ },+ }),+ FALLBACK_REQUEST_ID_RE,+ );+ assert.equal(+ createModelConfigHandoffRequestId({ randomUUID: () => "native-id" }),+ "native-id",+ );+});++test("only the matching consumer can clear the latest handoff", () => {+ const first = request("first", "org/first", "/cache/first");+ const second = request("second", "org/second", "/cache/second");++ requestModelConfigHandoff(first);+ requestModelConfigHandoff(second);+ clearModelConfigHandoff(first.requestId);+ assert.equal(useModelConfigHandoffStore.getState().request, second);++ clearModelConfigHandoff(second.requestId);+ assert.equal(useModelConfigHandoffStore.getState().request, null);+});++test("only the matching unoccupied active Chat destination receives a handoff", () => {+ const pending = request("run-request", "org/model", "/cache/model");+ assert.equal(+ modelConfigHandoffForDestination(pending, {+ active: true,+ newChatId: "run-request",+ }),+ pending,+ );++ const blockedDestinations = [+ { active: false, newChatId: "run-request" },+ { active: true, newChatId: "another-request" },+ { active: true, newChatId: "run-request", threadId: "thread" },+ { active: true, newChatId: "run-request", compareId: "compare" },+ { active: true, newChatId: "run-request", projectId: "project" },+ ];+ for (const destination of blockedDestinations) {+ assert.equal(modelConfigHandoffForDestination(pending, destination), null);+ }+ assert.equal(+ modelConfigHandoffForDestination(null, {+ active: true,+ newChatId: "run-request",+ }),+ null,+ );+});++test("a Windows model path stays opaque while its display name is portable", () => {+ const id = String.raw`C:\Users\models\Llama-3.gguf`;+ const meta = {+ source: "local" as const,+ isLora: false,+ isDownloaded: true,+ isGguf: true,+ loadId: id,+ };++ const target = modelConfigTarget(id, meta);++ assert.equal(target.id, id);+ assert.equal(target.configId, undefined);+ assert.equal(target.meta.loadId, id);+ assert.equal(target.displayName, "Llama-3");+ assert.equal(target.isGguf, true);+ assert.equal(target.apiLoadable, true);+});++test("a GGUF handoff preserves its public identity and exact variant", () => {+ const id = "unsloth/Llama-GGUF";+ const loadId = "/cache/models--unsloth--Llama-GGUF/snapshots/revision";+ const target = modelConfigTarget(id, {+ source: "hub",+ isLora: false,+ loadId,+ ggufVariant: "Q4_K_M",+ ggufFilename: "llama-q4_k_m.gguf",+ isDownloaded: true,+ isGguf: true,+ });++ assert.equal(target.id, loadId);+ assert.equal(target.configId, id);+ assert.equal(target.displayName, "Llama-GGUF · Q4_K_M");+ assert.equal(target.ggufVariant, "Q4_K_M");+ assert.equal(target.meta.ggufFilename, "llama-q4_k_m.gguf");+});++test("configuration residency follows public, loader, variant, and live state", () => {+ const target = modelConfigTarget("Org/Model", {+ source: "hub",+ isLora: false,+ loadId: String.raw`C:\Users\models\snapshots\revision`,+ ggufVariant: "Q4_K_M",+ isDownloaded: true,+ isGguf: true,+ });++ assert.equal(modelConfigTargetMatchesSelection(target, "org/model"), true);+ assert.equal(+ modelConfigTargetMatchesSelection(+ target,+ String.raw`c:\users\models\snapshots\revision`,+ ),+ true,+ );+ assert.equal(+ modelConfigTargetIsResident({+ target,+ selectedId: "org/model",+ activeGgufVariant: "q4_k_m",+ loaded: true,+ }),+ true,+ );+ assert.equal(+ modelConfigTargetIsResident({+ target,+ selectedId: "org/model",+ activeGgufVariant: "Q8_0",+ loaded: true,+ }),+ false,+ );+ assert.equal(+ modelConfigTargetIsResident({+ target,+ selectedId: "org/model",+ activeGgufVariant: "Q4_K_M",+ loaded: false,+ }),+ false,+ );+});++test("only local GGUF files may ignore a derived active variant", () => {+ const localPath = String.raw`C:\Models\Llama.gguf`;+ const localTarget = modelConfigTarget(localPath, {+ source: "local",+ isLora: false,+ loadId: localPath,+ isDownloaded: true,+ isGguf: true,+ });+ const hubTarget = modelConfigTarget("Org/Model.gguf", {+ source: "hub",+ isLora: false,+ loadId: "Org/Model.gguf",+ isDownloaded: true,+ isGguf: true,+ });++ assert.equal(+ modelConfigTargetIsResident({+ target: localTarget,+ selectedId: String.raw`c:\models\llama.gguf`,+ activeGgufVariant: "Q4_K_M",+ }),+ true,+ );+ assert.equal(+ modelConfigTargetIsResident({+ target: hubTarget,+ selectedId: "Org/Model.gguf",+ activeGgufVariant: "Q4_K_M",+ }),+ false,+ );+});++test("an Ollama load identity never advertises API-loadable settings", () => {+ const id = "ollama-manifest:library/model:latest";+ const target = modelConfigTarget(+ id,+ {+ source: "local",+ isLora: false,+ loadId: id,+ isDownloaded: true,+ isGguf: true,+ },+ "Llama 3.2",+ );++ assert.equal(target.apiLoadable, false);+ assert.equal(target.configId, undefined);+ assert.equal(target.displayName, "Llama 3.2");+ assert.equal(+ modelConfigTargetIsResident({+ target,+ selectedId: id,+ activeGgufVariant: "Q4_K_M",+ loaded: true,+ }),+ true,+ );+});++test("submitting a cached handoff adopts legacy path-keyed settings", () => {+ store.clear();+ const id = "unsloth/Llama-GGUF";+ const loadId = "/cache/models--unsloth--Llama-GGUF/snapshots/legacy";+ const ggufVariant = "Q4_K_M";+ savePerModelConfig(loadId, ggufVariant, {+ ...DEFAULT_PER_MODEL_CONFIG,+ maxSeqLength: 32768,+ });++ requestModelConfigHandoff({+ requestId: "legacy-settings",+ id,+ meta: {+ source: "hub",+ isLora: false,+ loadId,+ ggufVariant,+ isDownloaded: true,+ isGguf: true,+ },+ });++ const adopted = resolveInitialConfig(id, ggufVariant);+ assert.equal(adopted.remembered, true);+ assert.equal(adopted.config.maxSeqLength, 32768);+ assert.equal(resolveInitialConfig(loadId, ggufVariant).remembered, false);+});diff --git a/studio/frontend/tests/model-config-run-selection.test.ts b/studio/frontend/tests/model-config-run-selection.test.tsnew file mode 100644index 00000000000..e1f1f210432--- /dev/null+++ b/studio/frontend/tests/model-config-run-selection.test.ts@@ -0,0 +1,219 @@+// 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 ts from "typescript";++import { isExternalModelId } from "../src/features/chat/external-providers.ts";+import { isLocalModelPath } from "../src/features/chat/utils/model-download-staging.ts";+import type {+ ModelPickTarget,+ ModelSelectorChangeMeta,+} from "../src/features/model-picker/components/model-selector/types.ts";+import {+ installLocalStorageFake,+ registerBundlerResolver,+} from "./helpers/kit.ts";++registerBundlerResolver();+installLocalStorageFake();+const { modelConfigTarget } = await import(+ "../src/features/model-picker/model-config/model-config-handoff.ts"+);+const { DEFAULT_PER_MODEL_CONFIG } = await import(+ "../src/features/model-picker/model-config/per-model-config.ts"+);++function readSource(relativePath: string): ts.SourceFile {+ return ts.createSourceFile(+ relativePath,+ readFileSync(new URL(relativePath, import.meta.url), "utf8"),+ ts.ScriptTarget.Latest,+ true,+ ts.ScriptKind.TSX,+ );+}++function findNode<T extends ts.Node>(+ root: ts.Node,+ predicate: (node: ts.Node) => node is T,+): T {+ let found: T | undefined;+ function visit(node: ts.Node): void {+ if (predicate(node)) {+ found = node;+ }+ if (!found) {+ ts.forEachChild(node, visit);+ }+ }+ visit(root);+ assert.ok(found, "Expected source node was not found");+ return found;+}++// Execute the shipped callback and persistence guard without mounting the UI.+const selector = readSource(+ "../src/features/model-picker/components/model-selector.tsx",+);+const configPage = findNode(+ selector,+ (node): node is ts.JsxSelfClosingElement =>+ ts.isJsxSelfClosingElement(node) &&+ node.tagName.getText() === "ModelConfigPage",+);+const onRun = findNode(+ configPage,+ (node): node is ts.JsxAttribute =>+ ts.isJsxAttribute(node) && node.name.getText() === "onRun",+);+assert.ok(onRun.initializer && ts.isJsxExpression(onRun.initializer));+assert.ok(onRun.initializer.expression);+const runConfiguredModel = new Function(+ "visibleConfigTarget",+ "onSelect",+ "config",+ `return (${onRun.initializer.expression.getText()})(config, false);`,+) as (+ target: ModelPickTarget,+ onSelect: (id: string, meta: ModelSelectorChangeMeta) => void,+ config: typeof DEFAULT_PER_MODEL_CONFIG,+) => void;++const runtime = readSource(+ "../src/features/chat/hooks/use-chat-model-runtime.ts",+);+const declarations = [+ "modelId",+ "loadPath",+ "ggufVariant",+ "nativePathToken",+ "indexedLocalPick",+].map((name) => {+ const declaration = findNode(+ runtime,+ (node): node is ts.VariableDeclaration =>+ ts.isVariableDeclaration(node) && node.name.getText() === name,+ );+ return `const ${declaration.getText()};`;+});+const recordCall = findNode(+ runtime,+ (node): node is ts.CallExpression =>+ ts.isCallExpression(node) &&+ node.expression.getText() === "recordLastLocalModelLoad",+);+const recordGuard = recordCall.parent.parent.parent;+assert.ok(ts.isIfStatement(recordGuard));+type Selection = ModelSelectorChangeMeta & { id: string };+type RememberedModel = {+ id: string;+ kind: "gguf" | "model";+ ggufVariant: string | null;+};+const finishLoad = new Function(+ "selection",+ "loadResponse",+ "isGguf",+ "isLora",+ "recordLastLocalModelLoad",+ "isLocalModelPath",+ "isExternalModelId",+ `${declarations.join("\n")}\n${recordGuard.getText()}\nreturn loadPath;`,+) as (+ selection: Selection,+ response: { is_gguf: boolean; is_lora: boolean },+ isGguf: boolean,+ isLora: boolean,+ record: (model: RememberedModel) => void,+ isLocalPath: typeof isLocalModelPath,+ isExternalId: typeof isExternalModelId,+) => string;++const cases = [+ {+ name: "secondary GGUF cache",+ id: "Org/Model-GGUF",+ loadId: "/cache/models--Org--Model-GGUF/snapshots/revision",+ isGguf: true,+ ggufVariant: "Q4_K_M",+ },+ {+ name: "Windows GGUF cache",+ id: "Org/Model-GGUF",+ loadId: String.raw`C:\Cache\models--Org--Model-GGUF\snapshots\revision`,+ isGguf: true,+ ggufVariant: "Q8_0",+ },+ {+ name: "secondary safetensors cache",+ id: "Org/Model",+ loadId: "/cache/models--Org--Model/snapshots/revision",+ isGguf: false,+ },+ { name: "active Hub cache", id: "Org/Model", isGguf: false },+ {+ name: "indexed local GGUF",+ id: "/models/model.gguf",+ isGguf: true,+ source: "local" as const,+ },+ {+ name: "native file picker",+ id: "/models/picked.gguf",+ isGguf: true,+ source: "local" as const,+ nativePathToken: "signed-path-token",+ },+];++for (const entry of cases) {+ test(`configuration Run preserves loading and remembering for ${entry.name}`, () => {+ const { name: _name, id, ...fields } = entry;+ const meta: ModelSelectorChangeMeta = {+ source: "hub",+ isLora: false,+ isDownloaded: true,+ ...fields,+ };+ const target = modelConfigTarget(id, meta);+ const config = { ...DEFAULT_PER_MODEL_CONFIG, maxSeqLength: 8192 };+ const calls: Selection[] = [];+ runConfiguredModel(+ target,+ (selectedId, selectedMeta) => {+ calls.push({ id: selectedId, ...selectedMeta });+ },+ config,+ );++ assert.deepEqual(calls, [+ { id, ...meta, config, isDiffusion: false, forceReload: true },+ ]);+ const remembered: RememberedModel[] = [];+ const loadPath = finishLoad(+ calls[0],+ { is_gguf: entry.isGguf, is_lora: false },+ entry.isGguf,+ false,+ (model) => remembered.push(model),+ isLocalModelPath,+ isExternalModelId,+ );+ assert.equal(loadPath, meta.loadId ?? id);+ assert.deepEqual(+ remembered,+ meta.nativePathToken+ ? []+ : [+ {+ id,+ kind: entry.isGguf ? "gguf" : "model",+ ggufVariant: meta.ggufVariant ?? null,+ },+ ],+ );+ });+}diff --git a/studio/frontend/tests/model-identity.test.ts b/studio/frontend/tests/model-identity.test.tsindex 2219d622550..6bf6e0de947 100644--- a/studio/frontend/tests/model-identity.test.ts+++ b/studio/frontend/tests/model-identity.test.ts@@ -4,11 +4,6 @@import assert from "node:assert/strict";import test from "node:test";-import { settingsGgufVariantForRow } from "../src/features/hub/inventory/settings-identity.ts";-import type {- CachedInventoryRow,- LocalInventoryRow,-} from "../src/features/hub/inventory/types.ts";import {isOllamaLinkPath,isStandaloneGgufPath,@@ -109,7 +104,7 @@ test("a resident path-loaded model is matched by the id /status reports", () =>),true,);- // A repo in an inactive cache keeps the repo id as its settings identity.+ // A repo in an inactive cache can be reconciled through its public id.assert.equal(residentModelIdMatches("unsloth/Qwen3-8B-GGUF",@@ -118,6 +113,24 @@ test("a resident path-loaded model is matched by the id /status reports", () =>),true,);+ const pinnedSnapshot =+ "/mnt/old-cache/models--unsloth--Qwen3-8B-GGUF/snapshots/abc123";+ assert.equal(+ residentModelIdMatches(+ pinnedSnapshot,+ "unsloth/Qwen3-8B-GGUF",+ "/mnt/old-cache/models--unsloth--Qwen3-8B-GGUF",+ ),+ false,+ );+ assert.equal(+ residentModelIdMatches(+ pinnedSnapshot,+ pinnedSnapshot,+ "unsloth/Qwen3-8B-GGUF",+ ),+ true,+ );// The raw identifier is still matched literally.assert.equal(residentModelIdMatches(@@ -199,35 +212,6 @@ test("Ollama link paths are recognised the way the resolver excludes them", () =assert.equal(isOllamaLinkPath(null), false);});-test("a standalone gguf keeps one settings identity across surfaces", () => {- const loose = {- kind: "local",- path: "/srv/models/Qwen3-8B-Q4_K_M.gguf",- // What hub/services/models/common.py emits for a single scanned file.- formatVariant: "Q4_K_M",- } as LocalInventoryRow;- // The Chat picker opens the same file with no variant, so adopting the filename label would split the config.- assert.equal(settingsGgufVariantForRow(loose), null);-- // A GGUF directory still has a variant slot for the quant lookup to fill.- const repoDir = {- kind: "local",- path: "/srv/models/Qwen3-8B-GGUF",- formatVariant: null,- } as LocalInventoryRow;- assert.equal(settingsGgufVariantForRow(repoDir), null);- const lmStudioDir = {- kind: "local",- path: "/srv/lmstudio/Qwen3-8B-GGUF",- formatVariant: "Q8_0",- } as LocalInventoryRow;- assert.equal(settingsGgufVariantForRow(lmStudioDir), "Q8_0");-- // Cached repo rows are unaffected (cache_inventory.py never sets one).- const cached = { kind: "cache", formatVariant: null } as CachedInventoryRow;- assert.equal(settingsGgufVariantForRow(cached), null);-});-// The backfill matches on the folded identity, unambiguous only because storage holds one record per model.test("importing the legacy load settings never doubles up a model", () => {// The legacy casing names the model the v2 record already holds, so the import must leave it alone.diff --git a/studio/frontend/tests/model-picker-partial-downloads.test.ts b/studio/frontend/tests/model-picker-partial-downloads.test.tsindex 2139db77555..e3b5c6ea51e 100644--- a/studio/frontend/tests/model-picker-partial-downloads.test.ts+++ b/studio/frontend/tests/model-picker-partial-downloads.test.ts@@ -10,6 +10,24 @@ import assert from "node:assert/strict";import { readFileSync } from "node:fs";import test from "node:test";import { fileURLToPath } from "node:url";+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";++import type {+ CachedInventoryRow,+ DiscoverRow,+ LocalInventoryRow,+ SelectedModelView,+} from "../src/features/hub/types.ts";+import { downloadActionLabel } from "../src/features/hub/catalog/use-download-card-state.ts";+import { modelDownloadState } from "../src/features/hub/catalog/model-download-state.ts";+import { registerStoreStubResolver } from "./helpers/kit.ts";++registerStoreStubResolver();++const { useSelectedModelView } = await import(+ "../src/features/hub/hooks/use-selected-model-view.ts"+);function read(path: string): string {return readFileSync(fileURLToPath(new URL(path, import.meta.url)), "utf-8");@@ -152,19 +170,201 @@ test("complete and partial are alternatives, never both dots on one row", () =>);});-test("selecting a partial opens its download instead of claiming the weights", () => {+test("selecting a picker partial opens its download instead of claiming the weights", () => {// isDownloaded is what the load path reads. Hard-coding true on these rows sent a torn snapshot// straight to a load that fails on the missing shards -- the reason they were hidden at all.assert.ok(PICKERS.includes("isDownloaded: !isPartial,"),"the pick reports what is actually on disk",);- // Hub reaches the same answer from the same field.- assert.ok(- read("../src/features/hub/hub-page.tsx").includes(- "isDownloaded: !row.partial",- ),- );+});++test("Hub selections preserve download completeness and continuation state", () => {+ const capabilities = {+ canTrain: false,+ canChat: false,+ canDelete: true,+ canDownload: true,+ requiresVariant: false,+ supportsLora: false,+ supportsVision: false,+ };+ const cached: CachedInventoryRow = {+ kind: "cache",+ id: "cache:safetensors:Org%2FModel",+ loadId: "Org/Model",+ repoId: "Org/Model",+ owner: "Org",+ repo: "Model",+ isGguf: false,+ modelFormat: "safetensors",+ capabilities,+ bytes: 128,+ partial: true,+ partialTransport: "http",+ partialResumable: true,+ };+ const localHfCache: LocalInventoryRow = {+ kind: "local",+ id: "hf_cache:safetensors:Org%2FModel",+ loadId: "Org/Model",+ repoId: "Org/Model",+ owner: "Org",+ title: "Model",+ source: "hf_cache",+ sourceLabel: "Hugging Face cache",+ path: "/cache/models--Org--Model",+ isGguf: false,+ modelFormat: "safetensors",+ capabilities,+ updatedAt: 1,+ partial: true,+ partialTransport: "xet",+ partialResumable: false,+ };+ const discover: DiscoverRow = {+ id: "Org/Model",+ owner: "Org",+ repo: "Model",+ result: {+ id: "Org/Model",+ downloads: 0,+ likes: 0,+ isGguf: false,+ },+ isAvailableOnDevice: false,+ isPartialOnDevice: true,+ summary: "Model",+ capabilities: [],+ };+ const base = {+ selectedDiscoverRow: null,+ selectedCachedRow: null,+ selectedLocalRow: null,+ selectedHfResult: null,+ isDatasetMode: false,+ } satisfies Parameters<typeof useSelectedModelView>[0];++ const cases: Array<{+ name: string;+ input: Parameters<typeof useSelectedModelView>[0];+ kind: SelectedModelView["kind"];+ downloaded: boolean;+ partial: boolean;+ transport: string | null;+ resumable: boolean;+ action: "Download" | "Resume" | "Continue";+ }> = [+ {+ name: "direct cache row",+ input: { ...base, selectedCachedRow: cached },+ kind: "cache",+ downloaded: false,+ partial: true,+ transport: "http",+ resumable: true,+ action: "Resume",+ },+ {+ name: "discovery row backed by a cache row",+ input: { ...base, selectedDiscoverRow: discover, selectedCachedRow: cached },+ kind: "discover",+ downloaded: false,+ partial: true,+ transport: "http",+ resumable: true,+ action: "Resume",+ },+ {+ name: "discovery row backed by a local HF-cache row",+ input: {+ ...base,+ selectedDiscoverRow: discover,+ selectedLocalRow: localHfCache,+ },+ kind: "discover",+ downloaded: false,+ partial: true,+ transport: "xet",+ resumable: false,+ action: "Continue",+ },+ {+ name: "direct local HF-cache row",+ input: { ...base, selectedLocalRow: localHfCache },+ kind: "cache",+ downloaded: false,+ partial: true,+ transport: "xet",+ resumable: false,+ action: "Continue",+ },+ {+ name: "discovery partial awaiting its inventory row",+ input: { ...base, selectedDiscoverRow: discover },+ kind: "discover",+ downloaded: false,+ partial: true,+ transport: null,+ resumable: false,+ action: "Continue",+ },+ {+ name: "complete cache row",+ input: {+ ...base,+ selectedCachedRow: {+ ...cached,+ partial: false,+ partialTransport: null,+ partialResumable: false,+ },+ },+ kind: "cache",+ downloaded: true,+ partial: false,+ transport: null,+ resumable: false,+ action: "Download",+ },+ ];++ for (const entry of cases) {+ const result = { current: null as SelectedModelView | null };+ function Harness() {+ result.current = useSelectedModelView(entry.input);+ return null;+ }+ renderToStaticMarkup(createElement(Harness));+ assert.ok(result.current, entry.name);+ assert.equal(result.current.kind, entry.kind, entry.name);+ assert.equal(result.current.isDownloaded, entry.downloaded, entry.name);+ assert.equal(result.current.isPartial, entry.partial, entry.name);+ assert.equal(result.current.partialTransport, entry.transport, entry.name);+ assert.equal(result.current.partialResumable, entry.resumable, entry.name);+ const downloadState = modelDownloadState(result.current);+ assert.deepEqual(+ downloadState,+ {+ isDownloaded: entry.downloaded,+ isPartial: entry.partial,+ partialTransport: entry.transport,+ partialResumable: entry.resumable,+ },+ entry.name,+ );+ assert.equal(+ downloadActionLabel(+ downloadState.isPartial,+ downloadState.partialResumable,+ ),+ entry.action,+ entry.name,+ );+ }++ const inspector = read("../src/features/hub/catalog/model-inspector.tsx");+ assert.equal(inspector.split("{...downloadState}").length - 1, 2);});test("listing a partial never makes it auto-loadable", () => {@@ -263,7 +463,7 @@ test("configure carries the same rule, because Run replays its metadata", () =>);assert.match(selector,- /onRun=\{\(config, isDiffusion\) =>\n\s*onSelect\(visibleConfigTarget\.id, \{\n\s*\.\.\.visibleConfigTarget\.meta,/,+ /onRun=\{\(config, isDiffusion\) =>\s*onSelect\(\s*visibleConfigTarget\.configId \?\? visibleConfigTarget\.id,\s*\{\s*\.\.\.visibleConfigTarget\.meta,/,);});diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.pyindex 32804efb62d..0df204db67c 100644--- a/tests/studio/test_model_picker_contracts.py+++ b/tests/studio/test_model_picker_contracts.py@@ -476,7 +476,7 @@ def test_diffusion_capability_labeled_image_generation():def test_active_model_config_round_trips_gpu_fields():"""The active model's config must carry the GPU Memory knobs (GGUF only) so a- sidebar/hub-gear reload cannot silently reset manual GPU settings, and "Remember+ sidebar reload cannot silently reset manual GPU settings, and "Remembersettings" cannot persist a GPU-less config over a saved one."""src = _read("features/model-picker/hooks/use-active-model-config.ts")for field in (@@ -494,11 +494,8 @@ def test_active_model_config_round_trips_gpu_fields():assert "export function gpuFieldsSignature" in sharedassert "gpuFieldsSignature(config)," in sharedassert "export function modelConfigInstanceKey" in shared- for rel in (- "features/model-picker/components/sidebar-model-config.tsx",- "features/hub/catalog/hub-model-settings-view.tsx",- ):- assert "modelConfigInstanceKey(" in _read(rel), rel+ sidebar = _read("features/model-picker/components/sidebar-model-config.tsx")+ assert "modelConfigInstanceKey(" in sidebar# apply-per-model-config re-exports it, so its own callers are unchanged.reexport = _read("features/model-picker/model-config/apply-per-model-config.ts")assert "export { gpuFieldsSignature };" in reexport@@ -780,11 +777,7 @@ def test_native_picked_gguf_template_read_through_lease():assert '${nativePathToken ?? ""}' in hook-def test_model_load_guard_is_cross_instance():- """The in-flight load guard must consult the shared store pick (not only the- per-hook ref) and ejectModel must refuse while any instance is loading:- three live useChatModelRuntime instances exist (chat page, hub page, hub- gear dialog)."""+def test_model_load_guard_uses_shared_store_state():src = _read("features/chat/hooks/use-chat-model-runtime.ts")assert "useChatRuntimeStore.getState().loadingModelPick" in srcassert "clearLoadingModelPick" in src@@ -2748,15 +2741,6 @@ def test_monitor_stats_exclude_model_lifecycle_rows():assert 'entry.kind != "lifecycle"' in backend, "the rule this mirrors"-def test_api_reach_copy_is_limited_to_gguf_models():- """The Hub opens this page for every downloaded model, but ModelConfigPage mirrors- settings to the server only when target.isGguf, because API auto-switch indexes- GGUFs only."""- src = " ".join(_read("features/hub/catalog/hub-model-settings-view.tsx").split())- assert "{(target.apiLoadable ?? target.isGguf)" in src- assert "Saved settings apply everywhere Unsloth loads this model." in src--def test_backfill_includes_a_standalone_gguf_with_no_variant():"""A standalone .gguf picked directly has no quant to choose between, so it is storedwith a null variant."""@@ -2810,16 +2794,6 @@ def test_backfill_skips_future_schema_local_records():assert "storedConfigVersion(raw) > STORAGE_SCHEMA_VERSION" in listing[:900]-def test_detail_settings_need_a_resolved_quant():- """The on-device card passes a null variant while its own lookup is pending or after it- failed."""- src = " ".join(_read("features/hub/hub-page.tsx").split())- # `variant`, not the argument: a resident quant may have replaced it, so judge what is saved.- guard = "if (!variant && selectedModel.isGguf && selectedModel.requiresVariant) {"- assert guard in src- assert src.count("Couldn't determine which quant to configure.") == 2--def test_a_failed_detail_fetch_is_retried():"""A terminal row's updated_at never advances and selectedIsMissing stays true, so afetch that failed had nothing left to re-run the effect and the payload stayed@@ -2830,24 +2804,9 @@ def test_a_failed_detail_fetch_is_retried():assert "if (attemptsRef.current.count >= DETAIL_FETCH_ATTEMPTS) { return; }" in src-def test_ollama_models_are_not_advertised_as_api_loadable():- """local_model_resolver skips Ollama's scanner, so an Ollama GGUF is never in the- auto-switch index and no OpenAI request can resolve it."""- types_src = " ".join(_read("features/model-picker/components/model-selector/types.ts").split())- assert "apiLoadable?: boolean;" in types_src- hub = " ".join(_read("features/hub/hub-page.tsx").split())- assert "row.source !== LOCAL_MODEL_SOURCE.OLLAMA" in hub- assert "apiLoadable:" in hub- backend = _read_backend("core/inference/local_model_resolver.py")- assert (- "Ollama's\n scanner is skipped" in backend or "scanner is skipped" in backend- ), "the rule this mirrors"---def test_cached_repo_settings_are_keyed_by_the_repo_id():- """A repo cached outside the active HF cache reports load_id = the snapshot path- (hub/services/cache_inventory.py), while the chat picker and the auto-switch index- key it by repo_id."""+def test_model_config_keeps_storage_and_load_identities_separate():+ """The config target can store settings under a stable repo id while probes use+ the concrete load id supplied by the picker."""config_page = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())assert "const configId = target.configId ?? target.id;" in config_pagefor call in (@@ -2861,17 +2820,6 @@ def test_cached_repo_settings_are_keyed_by_the_repo_id():assert "useDefaultChatTemplate( target.id," in config_pageassert "model_path: target.id," in config_page- hub = " ".join(_read("features/hub/hub-page.tsx").split())- assert 'if (kind !== "cache" && resource.source !== "hub_cache") {' in hub- assert "return resource.repoId ?? resource.runId;" in hub- # Both openers and the Hub's own load resolve through it.- assert hub.count("modelConfigIdentity(") == 3- assert 'const configId = row.kind === "cache" ? row.repoId : id;' in hub- assert hub.count("configId,") >= 2-- backend = _read_backend("hub/tests/test_model_services.py")- assert 'fields["load_id"] == str(snapshot)' in backend, "the rule this mirrors"-def test_backfill_splits_a_quant_suffix_the_way_the_backend_does():"""The backfill compared server keys under an identity taken by splitting on the last@@ -2909,14 +2857,6 @@ def test_backfill_splits_a_quant_suffix_the_way_the_backend_does():assert (WORKDIR / "studio" / "frontend" / "tests" / "model-identity.test.ts").is_file()-def test_the_detail_card_also_gates_ollama_out_of_the_api_promise():- """Settings opens from two places in the Hub."""- hub = " ".join(_read("features/hub/hub-page.tsx").split())- assert hub.count("LOCAL_MODEL_SOURCE.OLLAMA") == 2- assert "selectedModel.localSource !== LOCAL_MODEL_SOURCE.OLLAMA" in hub- assert "row.source !== LOCAL_MODEL_SOURCE.OLLAMA" in hub--def test_the_settings_page_judges_the_config_storage_actually_keeps():"""savePerModelConfig normalizes before deciding, and the runtime hands this pageSpeculative Decoding "auto", which canonicalizes to null."""@@ -2939,8 +2879,8 @@ def test_the_settings_page_judges_the_config_storage_actually_keeps():def test_the_chat_picker_marks_ollama_targets_unloadable_by_the_api():"""A settings target opened from the Chat model picker carried no apiLoadable, so the`??"""- picker = " ".join(_read("features/model-picker/components/model-selector.tsx").split())- assert "apiLoadable: isGguf && !isOllamaLinkPath(id)," in picker+ handoff = " ".join(_read("features/model-picker/model-config/model-config-handoff.ts").split())+ assert "apiLoadable: isGguf && !isOllamaLinkPath(id) && !isOllamaLinkPath(loadId)," in handoffsidebar = " ".join(_read("features/model-picker/components/sidebar-model-config.tsx").split())assert "apiLoadable: isGguf && !isOllamaLinkPath(modelId)," in sidebar# The same classification gates the backfill, or an older config still reaches the server.@@ -2996,29 +2936,11 @@ def test_the_backfill_fills_in_fields_rather_than_skipping_known_keys():assert "BEGIN IMMEDIATE" in db-def test_the_hub_settings_page_matches_a_resident_path_loaded_model():- """A GGUF loaded from an inactive HF cache or straight off disk loads by path, but- /status reports the clean public id, so comparing it to settingsTarget.id said "not- loaded" and the page showed saved or default values instead of the live launch- config."""- hub = " ".join(_read("features/hub/hub-page.tsx").split())- assert (- "residentModelIdMatches( activeCheckpoint, settingsTarget.id, settingsTarget.configId, )"- in hub- )- assert "loadedConfig={settingsTargetIsResident ? activeModelConfig : null}" in hub- assert "settingsTargetIsResident ? activeLoadedContextLength : null" in hub- # The loadable identifier, as every other status reader records it -- except for a- # speech model, which chat cannot adopt at all. speechOnly rides beside the null so- # the helper can tell it from the empty slot the idle-unload rule is about.- assert (- "checkpointId: isSpeechOnlyStatus(status) ? null "- ": resolveInferenceCheckpointId(status), "- "speechOnly: isSpeechOnlyStatus(status)," in hub- )- assert "setCheckpoint(status.active_model" not in hub+def test_public_model_identity_matches_the_backend_for_path_loaded_models():+ """Path-loaded models use the backend's public identity rule wherever a+ resident model is reconciled with a picker entry."""chat = " ".join(_read("features/chat/lib/apply-inference-status-to-store.ts").split())- assert "return status.model_identifier ?? status.active_model;" in chat, "the rule this mirrors"+ assert "return status.model_identifier ?? status.active_model;" in chat# The alias is the backend's own public id rule, not a private heuristic.identity = _read("features/hub/lib/model-identity.ts")assert "export function publicModelId(" in identity@@ -3029,35 +2951,9 @@ def test_the_hub_settings_page_matches_a_resident_path_loaded_model():assert "def public_model_id(" in backend, "the rule this mirrors"-def test_the_hub_hydrates_the_live_settings_before_it_offers_them():- """The Hub builds activeModelConfig out of the chat runtime store, and landing straight- on /hub is the one entry point where nothing has applied /api/inference/status yet:- useChatModelRuntime has no mount sync and the chat page is a different route."""- hub = " ".join(_read("features/hub/hub-page.tsx").split())- assert "adoptResidentModelStatus(" in hub- assert "applyActiveModelStatusToStore(status, {" in hub- assert "previousCheckpoint: previous.checkpoint ?? undefined," in hub- assert "previousGgufVariant: previous.ggufVariant," in hub- assert "modelLoading: store.modelLoading," in hub-- adopt = " ".join(_read("features/hub/lib/adopt-inference-status.ts").split())- # Unconditional: a persisted checkpoint rehydrates without the fields saying how it launched.- assert "actions.applyStatus(previous); return true;" in adopt- # Never fight the owning load, nor describe an external model with the resident's settings.- assert "if (state.checkpointIsExternal) { return false; }" in adopt- assert "if (state.modelLoading) { return false; }" in adopt-- # Same call the chat runtime's own refresh makes, which is the rule this mirrors.- runtime = " ".join(_read("features/chat/hooks/use-chat-model-runtime.ts").split())- assert "applyActiveModelStatusToStore(statusRes, {" in runtime---def test_the_hub_settings_editor_reseeds_when_the_live_config_lands():+def test_the_sidebar_settings_editor_reseeds_when_the_live_config_lands():"""ModelConfigPage reads loadedConfig in a useState initializer, so it seeds once permounted instance."""- view = " ".join(_read("features/hub/catalog/hub-model-settings-view.tsx").split())- assert "key={modelConfigInstanceKey( target.id, target.ggufVariant, loadedConfig, )}" in view- # Same key the sidebar entry uses; that parity is the point.sidebar = " ".join(_read("features/model-picker/components/sidebar-model-config.tsx").split())assert "key={modelConfigInstanceKey(modelId, settingsGgufVariant, loadedConfig)}" in sidebar@@ -3079,46 +2975,7 @@ def test_the_hub_settings_editor_reseeds_when_the_live_config_lands():assert "const [initial] = useState(resolveInitial);" in page, "the rule this mirrors"-def test_a_standalone_gguf_has_one_settings_key():- """The inventory labels a single scanned .gguf from its filename, so the Hub row menu- keyed its settings to `<path>:Q4_K_M` while the Chat picker, the detail card and the- backfill all use the bare path: two surfaces, two configs."""- hub = " ".join(_read("features/hub/hub-page.tsx").split())- assert "let ggufVariant = settingsGgufVariantForRow(row);" in hub- assert "row.formatVariant" not in hub, "the row's raw label is not a settings key"-- helper = " ".join(_read("features/hub/inventory/settings-identity.ts").split())- assert 'row.kind === "local" && row.path.toLowerCase().endsWith(".gguf")' in helper-- common = _read_backend("hub/services/models/common.py")- # The rule this mirrors: a variant is derived only for a single scanned file.- # gguf_variant_key, not the hub's extract_quant_label: for a standalone file there is no- # directory to qualify, so the key IS the quant token -- and it keeps the bpw modifier, which- # is what makes it agree with the loader's own _extract_quant_label (the equality the sibling- # test below depends on). The hub label drops that modifier.- assert "gguf_variant_key(gguf_files[0].name)" in common- assert "if scan_path.is_file() and len(gguf_files) == 1" in common---def test_a_standalone_gguf_is_resident_despite_its_derived_quant():- """A loose .gguf keys its settings by the bare path with no variant, but the loader- derives one from the filename (llama_cpp sets _hf_variant from _extract_quant_label)- and /status reports it, so an equality between the two could never hold and the- settings page withheld the live launch config from the very file that was loaded."""- hub = " ".join(_read("features/hub/hub-page.tsx").split())- assert "const settingsTargetIsStandaloneFile =" in hub- assert 'settingsTarget.id.toLowerCase().endsWith(".gguf")' in hub- assert (- "(settingsTargetIsStandaloneFile || ggufVariantsMatch(activeGgufVariant, settingsTarget.ggufVariant))"- in hub- )- backend = _read_backend("core/inference/llama_cpp.py")- assert (- "self._hf_variant = _extract_quant_label(gguf_path)" in backend- ), "the derived label this accounts for"---def test_a_standalone_gguf_has_one_settings_identity_everywhere():+def test_a_standalone_gguf_has_one_settings_identity_in_the_picker():"""A loose .gguf has no quant to choose between, but llama_cpp falls back to_extract_quant_label(gguf_path) when a load names no variant, and /status echoesthat as gguf_variant."""@@ -3132,15 +2989,11 @@ def test_a_standalone_gguf_has_one_settings_identity_everywhere():# The label still shows the quant; only the identity drops it.assert "displayName: ggufVariant ? `${leaf} · ${ggufVariant}` : leaf," in sidebar- # One rule, one definition: the Hub row applies the same test.identity = _read("features/hub/lib/model-identity.ts")assert "export function isStandaloneGgufPath(" in identity# The suffix, and something that names a file on this machine: see# test_a_repo_id_ending_in_gguf_keeps_its_quant for why the suffix is not enough.assert "GGUF_SUFFIX_RE.test(modelId)" in identity- row_identity = _read("features/hub/inventory/settings-identity.ts")- assert 'row.path.toLowerCase().endsWith(".gguf")' in row_identity-# The precedence that makes the bare path win, asserted on the real function rather than on# inference.py's text: #8702 moved this ladder to utils/openai_auto_switch_settings.py# unchanged, and the grep that used to live here went red for a pure refactor.@@ -3171,30 +3024,9 @@ def test_monitor_unload_clears_only_the_model_it_freed():assert "store.clearCheckpoint();" in page-def test_settings_open_reads_status_before_resolving_the_quant():- """A cache row carries no quant, so opening its settings resolves one from the store's- active variant."""- page = " ".join(_read("features/hub/hub-page.tsx").split())- assert "const refreshResidentModelStatus = useCallback((): Promise<void> => {" in page- assert (- "await refreshResidentModelStatus(); if (settingsOpenSeq.current !== openSeq) return;"- in page- )- # Three: both handlers read on entry, and openModelSettings reads again after the- # variant lookup, whose network round trip is its own window for a switch to land.- assert page.count("await refreshResidentModelStatus();") == 3---def test_a_local_quant_folder_resolves_its_variants_by_path():+def test_a_local_quant_folder_lists_its_variants_by_path():"""A local row carries a repo id only inside the HF cache, so a plain folder of- quants has none while still being marked as needing one, and the row menu's- Settings could then only reach the error toast."""- hub = " ".join(_read("features/hub/hub-page.tsx").split())- assert (- 'const repoId = row.kind === "cache" ? row.repoId : (row.repoId ?? row.path ?? null);'- in hub- )- # The on-device card already lists by path, so both surfaces choose from one set of quants.+ quants has none while still needing a local variant listing."""card = " ".join(_read("features/hub/catalog/local-on-device-card.tsx").split())assert "repoId: modelId, hfToken, preferLocalCache: true, localPath: localGgufPath," in card# The backend scans a path in the repo_id position before the validation that would 400.@@ -3204,50 +3036,6 @@ def test_a_local_quant_folder_resolves_its_variants_by_path():assert "_is_valid_repo_id(repo_id)" in scan[1], "the branch has to come first"-def test_no_settings_target_is_built_on_an_unread_store():- """Every path out of both handlers seeds the editor from the store, and Apply- reloads with what it seeded, so a target built before the status read lands can- persist and launch the settings of the model an API switch displaced."""- page = " ".join(_read("features/hub/hub-page.tsx").split())- # Both handlers read first and drop the open if a newer one started meanwhile, and- # the variant lookup's await gets the same treatment. Every read carries the guard.- assert page.count("await refreshResidentModelStatus();") == 3- assert (- page.count(- "await refreshResidentModelStatus(); if (settingsOpenSeq.current !== openSeq) return;"- )- == 3- )- # Nothing may build a target off a concurrent read instead of an awaited one.- assert "Promise.all([ listGgufVariants(" not in page---def test_an_empty_status_is_read_against_the_idle_unload_setting():- """/status cannot say whether an empty answer is an idle eviction that reloads- or a real unload, so the Hub reads the only endpoint that knows and keeps the- checkpoint only while the loop is armed."""- hub = " ".join(_read("features/hub/hub-page.tsx").split())- adopt = " ".join(_read("features/hub/lib/adopt-inference-status.ts").split())- # Awaited, not raced: the first status read is the one most likely to land on an evicted- # model, and an unresolved default of false would clear a checkpoint that is coming back.- assert (- "Promise.all([getInferenceStatus(), readIdleUnloadArmed()]) "- ".then(([status, idleUnloadArmed]) => {" in hub- )- assert "idleUnloadArmed," in hub- # Read with every status read, not cached for the life of the page: the idle timeout- # is editable from Settings while this page stays mounted.- assert "idleUnloadRead.current ??=" not in hub- assert "idleUnloadArmed.current = settings.idleUnloadActive;" in hub- # A failed read keeps the last answer. The default is disarmed, which is the side- # that clears the checkpoint, so falling back to it would drop a live selection.- assert ".catch(() => idleUnloadArmed.current)" in hub- # An Audio load taking the single slot is not an idle eviction: nothing stashes the- # chat model, so the exemption must not swallow that case.- assert "if (state.idleUnloadArmed && !status.speechOnly) { return false; }" in adopt- assert "actions.clearCheckpoint?.();" in adopt--def test_a_repo_id_ending_in_gguf_keeps_its_quant():"""Repo ids ending in .gguf are real on the Hub, an iMat repo among them, andthose hold every quant. A suffix-only test reads one as a single file, drops@@ -3259,24 +3047,6 @@ def test_a_repo_id_ending_in_gguf_keeps_its_quant():assert "isNativeFileLabel(modelId)" in identity-def test_cached_repo_settings_key_follows_the_row_not_the_view():- """A repo in an inactive HF cache loads by snapshot path while its settings are keyed- by repo id."""- page = " ".join(_read("features/hub/hub-page.tsx").split())- assert 'if (kind !== "cache" && resource.source !== "hub_cache") {' in page---def test_detail_settings_defers_a_derived_quant_to_a_fresh_status_read():- """The on-device card resolves the quant it shows from the store's active variant, and- nothing re-reads status while the window keeps focus, so an API-driven switch leaves- that quant naming the model it displaced."""- page = " ".join(_read("features/hub/hub-page.tsx").split())- card = " ".join(_read("features/hub/catalog/local-on-device-card.tsx").split())- assert "if (!quantIsUserPicked) { const settled = useChatRuntimeStore.getState();" in page- assert "variant = settled.activeGgufVariant;" in page- assert "onOpenSettings(selectedQuant ?? null, quantIsUserPicked)" in card--def test_a_gpu_pin_is_mirrored_to_the_server_with_its_index_space():"""The same integers are Vulkan ordinals under Vulkan and device indices elsewhere, soa pin mirrored without its namespace would, after a backend change, address a different@@ -3290,9 +3060,8 @@ def test_a_gpu_pin_is_mirrored_to_the_server_with_its_index_space():assert 'if (gpuIndexKind !== "physical") { payload.gpu_index_kind = gpuIndexKind; }' in mirror-def test_a_cached_repo_keeps_the_settings_saved_under_its_old_key():- """A cached repo was keyed by the snapshot path it loads from and is now keyed by its- repo id; the server backfill only mirrors what is stored, so nothing else moves it."""+def test_a_cached_repo_moves_legacy_settings_to_the_current_key():+ """A cached repo's legacy snapshot-path settings move to its current repo-id key."""config = " ".join(_read("features/model-picker/model-config/per-model-config.ts").split())assert "export function adoptLegacyConfigKey(" in config# The key is renamed in one write. Saving the second copy first puts a full map one entry@@ -3310,9 +3079,6 @@ def test_a_cached_repo_keeps_the_settings_saved_under_its_old_key():"delete map[legacyKey]; deleteConfigEntriesForModelVariant(map, legacyModelId, ""ggufVariant);" in config)- # Both entry points move it before anything reads the new key.- page = " ".join(_read("features/hub/hub-page.tsx").split())- assert page.count("adoptLegacyConfigKey(") == 2def test_clearing_the_log_keeps_a_request_that_is_still_running():