Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: name a connected model the provider dropped instead of its raw id (#8470)
Daniel Handfae53b53dd1
diff --git a/studio/frontend/src/features/chat/audio-attachment-adapter.ts b/studio/frontend/src/features/chat/audio-attachment-adapter.tsindex 40d4a36a3db..d11290bf2dc 100644--- a/studio/frontend/src/features/chat/audio-attachment-adapter.ts+++ b/studio/frontend/src/features/chat/audio-attachment-adapter.ts@@ -13,6 +13,7 @@ import type {PendingAttachment,} from "@assistant-ui/react";import { toast } from "sonner";+import { externalModelLabel } from "./lib/external-model-label";import { useChatRuntimeStore } from "./stores/chat-runtime-store";// crypto.randomUUID is undefined in non-secure contexts (HTTP over a LAN IP).@@ -44,7 +45,13 @@ export class AudioAttachmentAdapter implements AttachmentAdapter {? "The last model failed to load. Check the server logs, then load a model before adding audio files.": "Load a model before adding audio files.";} else if (!activeModel?.hasAudioInput) {- const label = activeModel?.name || checkpoint || "Current model";+ // A connected provider's model has no row in `models`, so without the parse this+ // named it by its raw `external::…` id (#8405).+ const label =+ activeModel?.name ||+ externalModelLabel(checkpoint) ||+ checkpoint ||+ "Current model";unavailableReason = `${label} cannot accept audio. Load an audio-input model before attaching audio files.`;}if (unavailableReason) {diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsxindex 400fe277577..0281f61f9dc 100644--- a/studio/frontend/src/features/chat/chat-page.tsx+++ b/studio/frontend/src/features/chat/chat-page.tsx@@ -5,6 +5,7 @@ import {applyModelLoadConfigToRuntime,currentRuntimePerModelConfig,type DeletedModelRef,+ type ExternalConnectionRef,type ExternalModelOption,type LoraModelOption,type ModelOption,@@ -539,6 +540,7 @@ const CompareContent = memo(function CompareContent({models,loraModels,externalModels,+ externalConnections,onFoldersChange,onModelsChange,deleteDisabled,@@ -549,6 +551,7 @@ const CompareContent = memo(function CompareContent({models: ModelOption[];loraModels: LoraModelOption[];externalModels: ExternalModelOption[];+ externalConnections: ExternalConnectionRef[];onFoldersChange?: () => void;onModelsChange?: (deletedModel?: DeletedModelRef) => void;deleteDisabled?: boolean;@@ -569,6 +572,7 @@ const CompareContent = memo(function CompareContent({models={models}loraModels={loraModels}externalModels={externalModels}+ externalConnections={externalConnections}onFoldersChange={onFoldersChange}onModelsChange={onModelsChange}deleteDisabled={deleteDisabled}@@ -767,6 +771,7 @@ function GeneralCompareHeader({models,loraModels,externalModels,+ externalConnections,value,selectedConfig,selectedGgufVariant,@@ -779,6 +784,7 @@ function GeneralCompareHeader({models: ModelOption[];loraModels: LoraModelOption[];externalModels: ExternalModelOption[];+ externalConnections: ExternalConnectionRef[];value: string;selectedConfig?: PerModelConfig | null;selectedGgufVariant?: string | null;@@ -811,6 +817,7 @@ function GeneralCompareHeader({models={models}loraModels={loraModels}externalModels={externalModels}+ externalConnections={externalConnections}value={value}selectedConfig={selectedConfig}selectedGgufVariant={selectedGgufVariant}@@ -834,6 +841,7 @@ const GeneralCompareContent = memo(function GeneralCompareContent({models,loraModels,externalModels,+ externalConnections,onFoldersChange,onModelsChange,deleteDisabled,@@ -844,6 +852,7 @@ const GeneralCompareContent = memo(function GeneralCompareContent({models: ModelOption[];loraModels: LoraModelOption[];externalModels: ExternalModelOption[];+ externalConnections: ExternalConnectionRef[];onFoldersChange?: () => void;onModelsChange?: (deletedModel?: DeletedModelRef) => void;deleteDisabled?: boolean;@@ -942,6 +951,7 @@ const GeneralCompareContent = memo(function GeneralCompareContent({models={models}loraModels={loraModels}externalModels={externalModels}+ externalConnections={externalConnections}value={model1.id}selectedConfig={model1.config}selectedGgufVariant={model1.ggufVariant}@@ -973,6 +983,7 @@ const GeneralCompareContent = memo(function GeneralCompareContent({models={models}loraModels={loraModels}externalModels={externalModels}+ externalConnections={externalConnections}value={model2.id}selectedConfig={model2.config}selectedGgufVariant={model2.ggufVariant}@@ -3059,6 +3070,25 @@ export function ChatPage({),[externalProvidersForChat, lastOpenRouterChosenModel],);+ // `externalModels` above is flat-mapped from `provider.models`, the ids the user ticked,+ // so a model unticked in the connection dialog leaves it exactly like one the provider+ // withdrew. The connection also caches the whole fetched catalogue, which tells the two+ // apart, and the picker needs that to avoid blaming the provider for the user's own edit.+ // Depends on the store value and the gate rather than on `externalProvidersForChat`,+ // which is a plain conditional and so hands every hook that reads it a fresh array each+ // render.+ const externalConnections = useMemo<ExternalConnectionRef[]>(+ () =>+ connectionsEnabled+ ? externalProviders.map((provider) => ({+ id: provider.id,+ name: provider.name,+ providerType: provider.providerType,+ availableModels: provider.availableModels,+ }))+ : [],+ [connectionsEnabled, externalProviders],+ );const localModelInventory = useDeviceInventorySources(["localModels"], {enabled: active,@@ -3310,6 +3340,7 @@ export function ChatPage({models={models}loraModels={loraModels}externalModels={externalModels}+ externalConnections={externalConnections}value={inferenceParams.checkpoint}// Resident, not merely picked: an image or video load evicts// the chat model and leaves this selection behind, so the tick@@ -3547,6 +3578,7 @@ export function ChatPage({models={models}loraModels={loraModels}externalModels={externalModels}+ externalConnections={externalConnections}onFoldersChange={refreshLocalModels}onModelsChange={refreshModelLists}deleteDisabled={modelOperationInProgress}diff --git a/studio/frontend/src/features/chat/lib/external-model-label.ts b/studio/frontend/src/features/chat/lib/external-model-label.tsnew file mode 100644index 00000000000..e58c75c66e3--- /dev/null+++ b/studio/frontend/src/features/chat/lib/external-model-label.ts@@ -0,0 +1,34 @@+// 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 { parseExternalModelId } from "../external-providers";++/**+ * The model id a connection was asked for, e.g. `kimi-k2.5`, or null when *id* is not an+ * `external::<connectionId>::<modelId>` selection.+ *+ * A connected model has no row in `store.models`, so every label chain that looks a+ * checkpoint up there falls through to the checkpoint itself. `buildExternalModelId`+ * percent-encodes the model id, so the raw string carries no separator any generic shortener+ * can use and the user is shown `external::6235be0905af4221::kimi-k2.5` (#8405). Put this+ * ahead of the raw id in those chains.+ */+export function externalModelLabel(+ id: string | null | undefined,+): string | null {+ return parseExternalModelId(id)?.modelId ?? null;+}++/**+ * The short label for a compare pane's model id: the trailing segment, as the compare+ * toasts have always shown for a local model.+ *+ * A compare pane takes its id straight from the picker, and the compare header offers+ * connected models, so `external::abc::openai%2Fgpt-5` reached the plain+ * `id.split("/").pop()` this replaced and came back whole. Parsing first yields `gpt-5`.+ */+export function compareModelDisplayName(id: string): string {+ const value = externalModelLabel(id) ?? id;+ const parts = value.split("/");+ return parts[parts.length - 1] || value;+}diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsxindex be979bf8f4f..e055661fd31 100644--- a/studio/frontend/src/features/chat/shared-composer.tsx+++ b/studio/frontend/src/features/chat/shared-composer.tsx@@ -111,6 +111,7 @@ import {parseExternalModelId,providerTypeSupportsVision,} from "./external-providers";+import { compareModelDisplayName } from "./lib/external-model-label";import { useExternalProvidersStore } from "./stores/external-providers-store";import { useComposerPillFit } from "@/hooks/use-composer-pill-fit";import { useIsMobile } from "@/hooks/use-mobile";@@ -1163,11 +1164,6 @@ export function SharedComposer({});let loadedFromConfig = false;- function modelDisplayName(id: string): string {- const parts = id.split("/");- return parts[parts.length - 1] || id;- }-// Warm the device cache before the snapshot below reconciles the GPU// pick: on a cold cache the reconcile passes a stale pick through.try {@@ -1400,7 +1396,7 @@ export function SharedComposer({}if (!upgraded) {throw new Error(- `${modelDisplayName(sel.id)} needs a newer transformers release to load.`,+ `${compareModelDisplayName(sel.id)} needs a newer transformers release to load.`,);}}@@ -1419,7 +1415,7 @@ export function SharedComposer({});if (!approved) {throw new Error(- `${modelDisplayName(sel.id)} needs custom code approval to load.`,+ `${compareModelDisplayName(sel.id)} needs custom code approval to load.`,);}}@@ -1599,8 +1595,8 @@ export function SharedComposer({if (handle1) handle1.appendMessage(content);if (handle2) handle2.appendMessage(content);- const name1 = model1?.id ? modelDisplayName(model1.id) : "";- const name2 = model2?.id ? modelDisplayName(model2.id) : "";+ const name1 = model1?.id ? compareModelDisplayName(model1.id) : "";+ const name2 = model2?.id ? compareModelDisplayName(model2.id) : "";const toastId = toast("Comparing models…", { duration: Infinity });setComparing(true);diff --git a/studio/frontend/src/features/model-picker/components/model-selector.tsx b/studio/frontend/src/features/model-picker/components/model-selector.tsxindex feb17054592..29e0ac0a25e 100644--- a/studio/frontend/src/features/model-picker/components/model-selector.tsx+++ b/studio/frontend/src/features/model-picker/components/model-selector.tsx@@ -43,6 +43,11 @@ import {resolveInitialConfig,} from "../model-config/per-model-config";import { ModelConfigPage } from "./model-config-page";+import { HubModelPicker, hasDownloadedModels } from "./model-selector/pickers";+import {+ type ExternalConnectionRef,+ missingExternalModel,+} from "./model-selector/missing-external-model";import type { CommunityModelPolicy } from "./model-selector/audio-picker-policy";import type { CatalogGroup } from "./model-selector/model-catalog";import { HubModelPicker, hasDownloadedModels } from "./model-selector/pickers";@@ -124,6 +129,7 @@ export type {ModelOption,ModelSelectorChangeMeta,} from "./model-selector/types";+export type { ExternalConnectionRef } from "./model-selector/missing-external-model";interface ModelSelectorProps {models: ModelOption[];@@ -134,6 +140,12 @@ interface ModelSelectorProps {loadedModelIdOverride?: string;loraModels?: LoraModelOption[];externalModels?: ExternalModelOption[];+ /**+ * The connections behind `externalModels`, carrying each one's cached catalogue.+ * `externalModels` lists only the models the user ticked, so it cannot tell a model the+ * user turned off from one the provider withdrew; the catalogue can.+ */+ externalConnections?: ExternalConnectionRef[];value?: string;defaultValue?: string;/**@@ -643,6 +655,7 @@ export function ModelSelector({loadedModelIdOverride,loraModels = [],externalModels = [],+ externalConnections = [],value,defaultValue,activeGgufVariant,@@ -676,6 +689,7 @@ export function ModelSelector({const open = controlledOpen ?? uncontrolledOpen;const setOpen = onOpenChange ?? setUncontrolledOpen;const navigate = useNavigate();+ const t = useT();const [uncontrolled, setUncontrolled] = useState(defaultValue ?? "");const selected = value ?? uncontrolled;@@ -735,18 +749,49 @@ export function ModelSelector({const currentModel = useMemo(() => {if (!selected) return undefined;const found = optionById.get(selected);+ // A pick whose connection no longer offers it takes its option away and leaves the+ // id in the checkpoint, and the generic fallback below cannot shorten an+ // `external::` id. Name the model the user picked, and say why it is unusable: it+ // cannot be loaded, so a tidy name on its own would hide the failure until the next+ // send (#8405). The connections carry the cached catalogue, which is what separates a+ // model the user unticked from one the provider withdrew.+ const missingExternal = found+ ? null+ : missingExternalModel(selected, externalModels, externalConnections);// No catalog entry (yet, or ever); a cached GGUF's checkpoint is a snapshot path.// The leaf, not the namespaced public id (#7966), matches the catalog row that// later replaces this one.- const fallbackName = modelDisplayName(selected);+ const fallbackName = missingExternal?.modelName ?? modelDisplayName(selected);if (activeGgufVariant) {const desc = `GGUF · ${activeGgufVariant}`;return found? { ...found, description: desc }: { id: selected, name: fallbackName, description: desc };}+ if (missingExternal) {+ const disabled = missingExternal.state === "disabled";+ return {+ id: selected,+ name: fallbackName,+ description: missingExternal.providerName+ ? t(+ disabled+ ? "picker.modelDisabledByProvider"+ : "picker.modelDroppedByProvider",+ { provider: missingExternal.providerName },+ )+ : t(disabled ? "picker.modelDisabled" : "picker.modelDropped"),+ };+ }return found ?? { id: selected, name: fallbackName };- }, [selected, optionById, activeGgufVariant]);+ }, [+ selected,+ optionById,+ activeGgufVariant,+ externalModels,+ externalConnections,+ t,+ ]);function handleSelect(id: string, meta: ModelSelectorChangeMeta) {if (onValueChange) {diff --git a/studio/frontend/src/features/model-picker/components/model-selector/missing-external-model.ts b/studio/frontend/src/features/model-picker/components/model-selector/missing-external-model.tsnew file mode 100644index 00000000000..a7ef314120c--- /dev/null+++ b/studio/frontend/src/features/model-picker/components/model-selector/missing-external-model.ts@@ -0,0 +1,130 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// eslint-disable-next-line no-restricted-imports -- Avoid the chat barrel's React exports.+import {+ allowsManualModelIdsWithCatalog,+ parseExternalModelId,+} from "@/features/chat/external-providers";++/** The connection fields the picker carries for every model a connection offers. */+export interface ExternalModelRef {+ id: string;+ providerId: string;+ providerName: string;+ providerType: string;+}++/**+ * The connection-level fields this helper needs beyond the enabled options: a connection+ * caches the provider's whole catalogue in `availableModels`, while `models` holds only the+ * subset the user ticked, and `externalModels` is built from `models` alone.+ */+export interface ExternalConnectionRef {+ id: string;+ name: string;+ providerType?: string;+ /** Cached catalogue from the provider's /models response, when one was ever stored. */+ availableModels?: readonly string[];+}++/**+ * Why the selection has no option behind it.+ *+ * `disabled` is the user's own doing and reversible from the connection dialog; `dropped` is+ * the provider's, and no amount of re-ticking brings the model back.+ */+export type MissingExternalModelState = "disabled" | "dropped";++export interface MissingExternalModel {+ /** The model as the user picked it, e.g. `kimi-k2.5`. */+ modelName: string;+ /** The connection's display name, when one can be read. */+ providerName: string | null;+ /** Registry key (e.g. openai, ollama), from the same source as the name. */+ providerType: string | null;+ /** Which of the two ways the option went away. */+ state: MissingExternalModelState;+}++/**+ * Describes an `external::<connectionId>::<modelId>` selection with no option behind it, or+ * null for any other selection.+ *+ * Fetch Models replaces a connection's model list wholesale, and nothing reconciles the+ * active pick against it, so a model the provider dropped leaves the picker's option list+ * while its id stays in `params.checkpoint`. The picker's generic fallback cannot shorten+ * that id: `modelDisplayName` is an exact identity function for it, since the id is neither+ * path-shaped nor a `org/name` repo id, so the trigger printed the raw `external::…` string+ * for a model that can no longer be loaded (#8405).+ *+ * Parsing recovers the name the user actually picked. The connection's display name comes+ * from any sibling model still listed under the same connection id, and for a disabled pick+ * from the connection itself, which is still there even when every one of its models is+ * unticked.+ *+ * An option can go away two ways, and only one of them is the provider's doing. The+ * connection dialog saves the ticked ids as `models` and the fetched catalogue as+ * `availableModels`, so unticking the active model drops it from `models` while it stays in+ * `availableModels`. Since `externalModels` is flat-mapped from `models`, the enabled list+ * alone cannot tell the two apart and naming the provider there accuses it of a withdrawal+ * the user performed. `dropped` is therefore claimed only on positive evidence: a catalogue+ * that was cached, is non-empty, does not list the model, and could have listed it in the+ * first place. That last clause rules out the connections whose dialog offers a manual+ * model-ID box beside the fetched list, since a typed-in ID is saved to `models` only and a+ * catalogue that never carried it says nothing when the user later deletes it. Anything+ * less, including a connection saved before `availableModels` existed, is reported as+ * `disabled`, whose wording is true whenever the id is absent from `models` and which claims+ * nothing about the provider. A connection that is not in *connections* at all is not a+ * claim we can soften, so it keeps the `dropped` reading it has always had.+ */+export function missingExternalModel(+ selected: string | null | undefined,+ externalModels: readonly ExternalModelRef[],+ connections: readonly ExternalConnectionRef[] = [],+): MissingExternalModel | null {+ const parsed = parseExternalModelId(selected);+ if (!parsed) {+ return null;+ }+ // Still offered: the option carries a real name and never reaches the fallback.+ if (externalModels.some((option) => option.id === selected)) {+ return null;+ }+ const sibling = externalModels.find(+ (option) => option.providerId === parsed.providerId,+ );+ const connection = connections.find(+ (entry) => entry.id === parsed.providerId,+ );+ const catalog = connection?.availableModels;+ // Ollama, vLLM, llama.cpp and OpenRouter take typed-in model IDs beside the fetched list,+ // and the dialog saves those to `models` alone, so their catalogue never carried them and+ // its silence about one is not evidence of anything.+ const catalogCoversEveryId = !allowsManualModelIdsWithCatalog(+ connection?.providerType,+ );+ // `modelId` is decoded and `availableModels` holds raw provider ids, so these compare+ // directly; an empty catalogue is unknown rather than empty, since a connection with no+ // enabled models never gets one written.+ const dropped =+ connection == null ||+ (catalogCoversEveryId &&+ catalog != null &&+ catalog.length > 0 &&+ !catalog.includes(parsed.modelId));+ if (dropped) {+ return {+ modelName: parsed.modelId,+ providerName: sibling?.providerName ?? null,+ providerType: sibling?.providerType ?? null,+ state: "dropped",+ };+ }+ return {+ modelName: parsed.modelId,+ providerName: sibling?.providerName ?? connection.name,+ providerType: sibling?.providerType ?? connection.providerType ?? null,+ state: "disabled",+ };+}diff --git a/studio/frontend/src/features/model-picker/index.ts b/studio/frontend/src/features/model-picker/index.tsindex 8bb912c6834..4f1f771573b 100644--- a/studio/frontend/src/features/model-picker/index.ts+++ b/studio/frontend/src/features/model-picker/index.ts@@ -29,6 +29,7 @@ export {export { useActiveModelConfig } from "./hooks/use-active-model-config";export type {DeletedModelRef,+ ExternalConnectionRef,ExternalModelOption,LoraModelOption,ModelOption,diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex 7d848f853ef..89fd382e3b2 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -18,6 +18,10 @@ export const ar = {modelSourceAriaLabel: "مصدر النموذج",hubSectionAriaLabel: "قسم Hub",pickModelFile: "اختيار ملف نموذج من القرص",+ modelDropped: "لم يعد متاحًا",+ modelDroppedByProvider: "{provider} · لم يعد متاحًا",+ modelDisabled: "غير مُفعَّل",+ modelDisabledByProvider: "{provider} · غير مُفعَّل",multipleMatches:"توجد عدة نتائج مطابقة ضمن {noun}. اختر نتيجة من القائمة.",rateLimitedTitle: "تم بلوغ حد طلبات Hugging Face",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex eca29b61705..b867021ac76 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -18,6 +18,10 @@ export const de = {modelSourceAriaLabel: "Modellquelle",hubSectionAriaLabel: "Hub-Bereich",pickModelFile: "Modelldatei vom Datenträger auswählen",+ modelDropped: "Nicht mehr angeboten",+ modelDroppedByProvider: "{provider} · nicht mehr angeboten",+ modelDisabled: "Nicht aktiviert",+ modelDisabledByProvider: "{provider} · nicht aktiviert",multipleMatches:"Mehrere passende {noun} gefunden. Wählen Sie einen Eintrag aus der Liste aus.",rateLimitedTitle: "Hugging Face-Ratenlimit erreicht",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex dd191d869d4..98001cc5931 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -14,6 +14,10 @@ export const en = {modelSourceAriaLabel: "Model source",hubSectionAriaLabel: "Hub section",pickModelFile: "Pick a model file from disk",+ modelDropped: "No longer offered",+ modelDroppedByProvider: "{provider} · no longer offered",+ modelDisabled: "Not enabled",+ modelDisabledByProvider: "{provider} · not enabled",multipleMatches: "Multiple matching {noun}. Choose one from the list.",rateLimitedTitle: "Hugging Face rate limit reached",rateLimitedBody: "Wait a moment, then retry searching {noun}.",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex 5183275b583..518f27f10e5 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -18,6 +18,10 @@ export const es = {modelSourceAriaLabel: "Origen del modelo",hubSectionAriaLabel: "Sección del Hub",pickModelFile: "Elegir un archivo de modelo del disco",+ modelDropped: "Ya no se ofrece",+ modelDroppedByProvider: "{provider} · ya no se ofrece",+ modelDisabled: "No activado",+ modelDisabledByProvider: "{provider} · no activado",multipleMatches:"Hay varios {noun} coincidentes. Elige uno de la lista.",rateLimitedTitle: "Se alcanzó el límite de solicitudes de Hugging Face",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex b9cb954171d..aa80bd805ea 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -18,6 +18,10 @@ export const fr = {modelSourceAriaLabel: "Source du modèle",hubSectionAriaLabel: "Section du Hub",pickModelFile: "Choisir un fichier de modèle sur le disque",+ modelDropped: "N'est plus proposé",+ modelDroppedByProvider: "{provider} · n'est plus proposé",+ modelDisabled: "Non activé",+ modelDisabledByProvider: "{provider} · non activé",multipleMatches:"Plusieurs {noun} correspondent. Choisissez-en un dans la liste.",rateLimitedTitle: "Limite de requêtes Hugging Face atteinte",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex 9cfec815fbc..913a3ba0a52 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -18,6 +18,10 @@ export const hi = {modelSourceAriaLabel: "मॉडल स्रोत",hubSectionAriaLabel: "Hub सेक्शन",pickModelFile: "डिस्क से मॉडल फ़ाइल चुनें",+ modelDropped: "अब उपलब्ध नहीं",+ modelDroppedByProvider: "{provider} · अब उपलब्ध नहीं",+ modelDisabled: "सक्षम नहीं",+ modelDisabledByProvider: "{provider} · सक्षम नहीं",multipleMatches:"एक से अधिक मेल खाते {noun} मिले। सूची में से एक चुनें।",rateLimitedTitle: "Hugging Face की अनुरोध सीमा पूरी हो गई",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex 9d3221d6bcd..d75b7b990df 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -1200,6 +1200,10 @@ export const it = {modelSourceAriaLabel: "Origine del modello",hubSectionAriaLabel: "Sezione Hub",pickModelFile: "Scegli un file del modello dal disco",+ modelDropped: "Non più offerto",+ modelDroppedByProvider: "{provider} · non più offerto",+ modelDisabled: "Non attivato",+ modelDisabledByProvider: "{provider} · non attivato",multipleMatches:"Sono stati trovati più {noun} corrispondenti. Scegline uno dall'elenco.",rateLimitedTitle: "Limite di richieste di Hugging Face raggiunto",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex 38838f86be4..24f8d0f44f0 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -19,6 +19,10 @@ export const ja = {modelSourceAriaLabel: "モデルのソース",hubSectionAriaLabel: "Hub セクション",pickModelFile: "ディスクからモデルファイルを選択",+ modelDropped: "提供終了",+ modelDroppedByProvider: "{provider} · 提供終了",+ modelDisabled: "無効",+ modelDisabledByProvider: "{provider} · 無効",multipleMatches:"一致する{noun}が複数あります。リストから1つ選択してください。",rateLimitedTitle: "Hugging Face のレート制限に達しました",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex b8d05312eff..1269055eb96 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -17,6 +17,10 @@ export const ko = {modelSourceAriaLabel: "모델 소스",hubSectionAriaLabel: "Hub 섹션",pickModelFile: "디스크에서 모델 파일 선택",+ modelDropped: "더 이상 제공되지 않음",+ modelDroppedByProvider: "{provider} · 더 이상 제공되지 않음",+ modelDisabled: "사용 안 함",+ modelDisabledByProvider: "{provider} · 사용 안 함",multipleMatches:"일치하는 {noun} 항목이 여러 개 있습니다. 목록에서 하나를 선택하세요.",rateLimitedTitle: "Hugging Face 요청 한도에 도달했습니다",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex c1d074f41a8..3062ecb1ff1 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -18,6 +18,10 @@ export const ptBR = {modelSourceAriaLabel: "Origem do modelo",hubSectionAriaLabel: "Seção do Hub",pickModelFile: "Escolher um arquivo de modelo no disco",+ modelDropped: "Não é mais oferecido",+ modelDroppedByProvider: "{provider} · não é mais oferecido",+ modelDisabled: "Não ativado",+ modelDisabledByProvider: "{provider} · não ativado",multipleMatches:"Há vários {noun} correspondentes. Escolha uma opção na lista.",rateLimitedTitle: "Limite de requisições do Hugging Face atingido",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex 1482a253372..c0f44c78ce9 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -18,6 +18,10 @@ export const ru = {modelSourceAriaLabel: "Источник модели",hubSectionAriaLabel: "Раздел Hub",pickModelFile: "Выбрать файл модели на диске",+ modelDropped: "Больше не предлагается",+ modelDroppedByProvider: "{provider} · больше не предлагается",+ modelDisabled: "Не включена",+ modelDisabledByProvider: "{provider} · не включена",multipleMatches:"В категории «{noun}» найдено несколько совпадений. Выберите одно из списка.",rateLimitedTitle: "Достигнут лимит запросов Hugging Face",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex efef1f0ea1d..22be5412f81 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -17,6 +17,10 @@ export const zhCN = {modelSourceAriaLabel: "模型来源",hubSectionAriaLabel: "Hub 分区",pickModelFile: "从磁盘选择模型文件",+ modelDropped: "已不再提供",+ modelDroppedByProvider: "{provider} · 已不再提供",+ modelDisabled: "未启用",+ modelDisabledByProvider: "{provider} · 未启用",multipleMatches: "找到多个匹配的{noun}。请从列表中选择一个。",rateLimitedTitle: "已达到 Hugging Face 速率限制",rateLimitedBody: "请稍候,然后重试搜索{noun}。",diff --git a/studio/frontend/tests/external-model-selection-label.test.ts b/studio/frontend/tests/external-model-selection-label.test.tsnew file mode 100644index 00000000000..c0ff2d8b5c6--- /dev/null+++ b/studio/frontend/tests/external-model-selection-label.test.ts@@ -0,0 +1,504 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// #8405: a connected provider that drops the picked model leaves its+// `external::<connectionId>::<modelId>` id in the checkpoint with no option behind it, and+// every generic shortener in the app is an identity function for that id. These cover the+// three surfaces a raw id was verified to reach: the picker trigger, the compare toasts and+// the audio-attachment toast.++import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import test from "node:test";+import { fileURLToPath } from "node:url";++import ts from "typescript";++import { modelDisplayName } from "../src/features/hub/lib/model-identity.ts";+import type {+ ExternalConnectionRef,+ ExternalModelRef,+} from "../src/features/model-picker/components/model-selector/missing-external-model.ts";+import { registerBundlerResolver } from "./helpers/kit.ts";++// Both helpers reach across the tree the way vite resolves it: the "@/" alias and an+// extensionless relative import.+registerBundlerResolver();+const { compareModelDisplayName, externalModelLabel } = await import(+ "../src/features/chat/lib/external-model-label.ts"+);+const { missingExternalModel } = await import(+ "../src/features/model-picker/components/model-selector/missing-external-model.ts"+);++// The id from the report, built by buildExternalModelId(providerId, "kimi-k2.5").+const CONNECTION_ID = "6235be0905af4221";+const DROPPED_ID = `external::${CONNECTION_ID}::kimi-k2.5`;++const option = (+ modelId: string,+ overrides: Partial<ExternalModelRef> = {},+): ExternalModelRef => ({+ id: `external::${CONNECTION_ID}::${encodeURIComponent(modelId)}`,+ providerId: CONNECTION_ID,+ providerName: "Ollama",+ providerType: "ollama",+ ...overrides,+});++const connection = (+ overrides: Partial<ExternalConnectionRef> = {},+): ExternalConnectionRef => ({+ id: CONNECTION_ID,+ name: "Ollama",+ providerType: "ollama",+ availableModels: ["llama3.2", "kimi-k2.5"],+ ...overrides,+});++// A connection whose dialog has no manual model-ID box beside the fetched list: every id it+// can hold came from the catalogue, so the catalogue is a complete record of what it offers.+const CATALOG_ONLY_ID = "9f1c33d0a7b24e18";+const CATALOG_ONLY_PICK = `external::${CATALOG_ONLY_ID}::gpt-5.4-mini`;++const catalogOnlyOption = (modelId: string): ExternalModelRef => ({+ id: `external::${CATALOG_ONLY_ID}::${encodeURIComponent(modelId)}`,+ providerId: CATALOG_ONLY_ID,+ providerName: "OpenAI",+ providerType: "openai",+});++const catalogOnlyConnection = (+ overrides: Partial<ExternalConnectionRef> = {},+): ExternalConnectionRef => ({+ id: CATALOG_ONLY_ID,+ name: "OpenAI",+ providerType: "openai",+ availableModels: ["gpt-5.4", "gpt-5.4-mini"],+ ...overrides,+});++// The premise: the shared helper cannot shorten this id, which is why the picker's+// fallback printed it verbatim.+test("the generic display helper leaves an external id untouched", () => {+ assert.equal(modelDisplayName(DROPPED_ID), DROPPED_ID);+});++test("a dropped connected model is named, never shown as its raw id", () => {+ // Fetch Models replaced both lists and gpt-5.4-mini is in neither. Nothing but the+ // catalogue can put an id in this connection's `models`, so the catalogue is positive+ // evidence that the provider withdrew it.+ const missing = missingExternalModel(+ CATALOG_ONLY_PICK,+ [catalogOnlyOption("gpt-5.4")],+ [catalogOnlyConnection({ availableModels: ["gpt-5.4"] })],+ );+ assert.deepEqual(missing, {+ modelName: "gpt-5.4-mini",+ providerName: "OpenAI",+ providerType: "openai",+ state: "dropped",+ });+ assert.doesNotMatch(missing?.modelName ?? "", /external::/);+});++test("the pick from the report is named, never shown as its raw id", () => {+ const missing = missingExternalModel(+ DROPPED_ID,+ [option("llama3.2")],+ [connection({ availableModels: ["llama3.2"] })],+ );+ assert.equal(missing?.modelName, "kimi-k2.5");+ assert.equal(missing?.providerName, "Ollama");+ assert.equal(missing?.providerType, "ollama");+ assert.doesNotMatch(missing?.modelName ?? "", /external::/);+});++test("a connection that dropped every model still names the model", () => {+ assert.deepEqual(missingExternalModel(DROPPED_ID, []), {+ modelName: "kimi-k2.5",+ providerName: null,+ providerType: null,+ state: "dropped",+ });+});++test("a sibling under a different connection does not lend its name", () => {+ const other = option("gpt-5", {+ id: "external::other::gpt-5",+ providerId: "other",+ providerName: "OpenAI",+ providerType: "openai",+ });+ assert.deepEqual(missingExternalModel(DROPPED_ID, [other]), {+ modelName: "kimi-k2.5",+ providerName: null,+ providerType: null,+ state: "dropped",+ });+});++// The connection dialog writes the ticked ids to `models` and the fetched catalogue to+// `availableModels`, and the picker's option list is built from `models` alone. Unticking+// the active model therefore looks exactly like a withdrawal unless the catalogue is+// consulted, and blaming the provider for the user's own edit is what these cover.+test("a model the user unticked is reported as disabled, not dropped", () => {+ assert.deepEqual(+ missingExternalModel(DROPPED_ID, [option("llama3.2")], [connection()]),+ {+ modelName: "kimi-k2.5",+ providerName: "Ollama",+ providerType: "ollama",+ state: "disabled",+ },+ );+});++test("unticking every model still names the connection", () => {+ // No sibling option survives, so the connection itself is the only source for the name.+ assert.deepEqual(missingExternalModel(DROPPED_ID, [], [connection()]), {+ modelName: "kimi-k2.5",+ providerName: "Ollama",+ providerType: "ollama",+ state: "disabled",+ });+});++test("a connection saved before availableModels existed is not called dropped", () => {+ // Legacy persisted connections carry no catalogue at all. Absent evidence, the claim the+ // provider withdrew the model is exactly the guess that produced the wrong label, so the+ // neutral reading wins: the id is out of `models`, which is all "not enabled" asserts.+ assert.deepEqual(+ missingExternalModel(+ DROPPED_ID,+ [option("llama3.2")],+ [connection({ availableModels: undefined })],+ ),+ {+ modelName: "kimi-k2.5",+ providerName: "Ollama",+ providerType: "ollama",+ state: "disabled",+ },+ );+});++test("an empty cached catalogue is unknown, not proof of a withdrawal", () => {+ assert.equal(+ missingExternalModel(+ DROPPED_ID,+ [option("llama3.2")],+ [connection({ availableModels: [] })],+ )?.state,+ "disabled",+ );+});++test("another connection's catalogue does not vouch for this one", () => {+ const missing = missingExternalModel(+ CATALOG_ONLY_PICK,+ [catalogOnlyOption("gpt-5.4")],+ [+ catalogOnlyConnection({ availableModels: ["gpt-5.4"] }),+ catalogOnlyConnection({+ id: "other",+ name: "Azure OpenAI",+ availableModels: ["gpt-5.4-mini"],+ }),+ ],+ );+ assert.equal(missing?.state, "dropped");+});++// Ollama, vLLM, llama.cpp and OpenRouter take typed-in model IDs beside the fetched list,+// and chat-providers-dialog.tsx saves those to `models` only: `modelsToSave` unions the+// ticked ids with the manual ones, while `availableModels` is written as the fetched+// catalogue alone. A catalogue that never carried an id cannot report its withdrawal, so+// deleting the id from the manual box has to read as the user's own edit.+test("a manual model ID the user deleted is not blamed on the provider", () => {+ // The state a save leaves behind: llama3.2 stays ticked, the typed-in kimi-k2.5 is gone+ // from `models`, and the catalogue is untouched because it never held it.+ assert.deepEqual(+ missingExternalModel(+ DROPPED_ID,+ [option("llama3.2")],+ [connection({ availableModels: ["llama3.2"] })],+ ),+ {+ modelName: "kimi-k2.5",+ providerName: "Ollama",+ providerType: "ollama",+ state: "disabled",+ },+ );+});++test("no connection that takes manual model IDs reports a withdrawal", () => {+ for (const providerType of ["ollama", "vllm", "llama_cpp", "custom"]) {+ assert.equal(+ missingExternalModel(+ DROPPED_ID,+ [option("llama3.2", { providerType })],+ [connection({ providerType, availableModels: ["llama3.2"] })],+ )?.state,+ "disabled",+ providerType,+ );+ }+});++test("an OpenRouter model list is a shortlist, never proof of a withdrawal", () => {+ // OpenRouter is curated: the dialog saves `availableModels: []` and the sync fills the+ // gap from the registry's `default_models`, so the list the picker sees is a handful of+ // suggestions rather than the 300-odd models the gateway actually serves.+ assert.equal(+ missingExternalModel(+ DROPPED_ID,+ [option("llama3.2", { providerType: "openrouter" })],+ [+ connection({+ name: "OpenRouter",+ providerType: "openrouter",+ availableModels: ["openai/gpt-5.4", "anthropic/claude-sonnet-5"],+ }),+ ],+ )?.state,+ "disabled",+ );+});++test("a catalogue-only connection still reports a real withdrawal", () => {+ // The other half of the rule: OpenAI has no manual model-ID box, so every id in `models`+ // came from a fetch and the catalogue's silence is the provider's own answer.+ assert.equal(+ missingExternalModel(+ CATALOG_ONLY_PICK,+ [catalogOnlyOption("gpt-5.4")],+ [catalogOnlyConnection({ availableModels: ["gpt-5.4"] })],+ )?.state,+ "dropped",+ );+ // An id the catalogue still carries is the user's own untick either way.+ assert.equal(+ missingExternalModel(+ CATALOG_ONLY_PICK,+ [catalogOnlyOption("gpt-5.4")],+ [catalogOnlyConnection()],+ )?.state,+ "disabled",+ );+});++test("a connection with no readable type keeps trusting its catalogue", () => {+ assert.equal(+ missingExternalModel(+ CATALOG_ONLY_PICK,+ [catalogOnlyOption("gpt-5.4")],+ [+ catalogOnlyConnection({+ providerType: undefined,+ availableModels: ["gpt-5.4"],+ }),+ ],+ )?.state,+ "dropped",+ );+});++test("re-ticking the model clears the label entirely", () => {+ const restored = option("kimi-k2.5");+ assert.equal(+ missingExternalModel(restored.id, [restored], [connection()]),+ null,+ );+});++test("a percent-encoded model id is decoded for display", () => {+ const id = "external::conn::openai%2Fgpt-5";+ assert.equal(missingExternalModel(id, [])?.modelName, "openai/gpt-5");+});++test("a model the connection still offers is not treated as missing", () => {+ const listed = option("kimi-k2.5");+ assert.equal(missingExternalModel(listed.id, [listed]), null);+});++test("local and hub selections are left to the generic helper", () => {+ for (const id of [+ "unsloth/gemma-3-4b-it-GGUF",+ "/models/gemma-3-4b-it.gguf",+ "C:\\models\\gemma.gguf",+ "",+ null,+ undefined,+ ]) {+ assert.equal(missingExternalModel(id, []), null);+ }+});++// Compare toasts: reachable because the compare pane headers accept connected models and+// the send path has no external guard.+test("compare toasts name the connected model, not its id", () => {+ assert.equal(compareModelDisplayName(DROPPED_ID), "kimi-k2.5");+ assert.equal(+ compareModelDisplayName("external::conn::openai%2Fgpt-5"),+ "gpt-5",+ );+ // Unchanged for everything else.+ assert.equal(+ compareModelDisplayName("unsloth/gemma-3-4b-it"),+ "gemma-3-4b-it",+ );+ assert.equal(compareModelDisplayName("gemma-3-4b-it"), "gemma-3-4b-it");+});++test("externalModelLabel yields null for a non-external id", () => {+ assert.equal(externalModelLabel("unsloth/gemma-3-4b-it"), null);+ assert.equal(externalModelLabel(null), null);+ assert.equal(externalModelLabel(DROPPED_ID), "kimi-k2.5");+});++// No DOM renderer here, so assert the wiring in the source the way+// artifact-frame-network-access.test.ts does: the fix only reaches the user if these three+// call sites route the checkpoint through the helpers above.+const sourceOf = (relative: string, kind: ts.ScriptKind): ts.SourceFile => {+ const path = fileURLToPath(new URL(relative, import.meta.url));+ return ts.createSourceFile(+ path,+ readFileSync(path, "utf8"),+ ts.ScriptTarget.ESNext,+ true,+ kind,+ );+};++/** The body of the `currentModel` useMemo in the picker, or null if it moved. */+function currentModelMemo(): string | null {+ const source = sourceOf(+ "../src/features/model-picker/components/model-selector.tsx",+ ts.ScriptKind.TSX,+ );+ let body: string | null = null;+ const visit = (node: ts.Node): void => {+ if (+ ts.isVariableDeclaration(node) &&+ node.name.getText() === "currentModel" &&+ node.initializer+ ) {+ body = node.initializer.getText();+ }+ node.forEachChild(visit);+ };+ source.forEachChild(visit);+ return body;+}++test("the picker trigger resolves a dropped connected model before naming it", () => {+ const memo = currentModelMemo();+ assert.ok(memo, "currentModel not found in model-selector.tsx");+ assert.match(+ memo,+ /missingExternalModel\(\s*selected,\s*externalModels,\s*externalConnections,?\s*\)/,+ "the fallback must consult the connections as well as the enabled options",+ );+ // A name alone would hide that the model cannot be loaded, so the trigger says so.+ assert.match(memo, /picker\.modelDroppedByProvider/);+ assert.match(memo, /picker\.modelDropped\b/);+ // The enabled list alone cannot tell a disabled model from a withdrawn one, so both+ // readings must be reachable from here.+ assert.match(memo, /picker\.modelDisabledByProvider/);+ assert.match(memo, /picker\.modelDisabled\b/);+ // A memo that reads these must list them, or the label survives a refresh.+ assert.match(memo, /\[[^\]]*\bexternalModels\b[^\]]*\]\s*\)?\s*$/);+ assert.match(memo, /\[[^\]]*\bexternalConnections\b[^\]]*\]\s*\)?\s*$/);+});++// The catalogue only reaches the picker if chat-page builds it from the connections and+// passes it down both the single-chat and compare paths.+test("the chat page feeds the picker the connections behind the options", () => {+ const page = readFileSync(+ fileURLToPath(new URL("../src/features/chat/chat-page.tsx", import.meta.url)),+ "utf8",+ );+ assert.match(page, /availableModels: provider\.availableModels/);+ // Once for the memo's own type, then every hop from chat-page to the picker.+ assert.ok(+ (page.match(/externalConnections=\{externalConnections\}/g) ?? []).length >=+ 5,+ "externalConnections must reach the picker on both the chat and compare paths",+ );+});++test("the compare and audio toasts use the external-aware labels", () => {+ const composer = readFileSync(+ fileURLToPath(+ new URL("../src/features/chat/shared-composer.tsx", import.meta.url),+ ),+ "utf8",+ );+ assert.match(+ composer,+ /const name1 = model1\?\.id \? compareModelDisplayName\(/,+ );+ assert.match(+ composer,+ /const name2 = model2\?\.id \? compareModelDisplayName\(/,+ );+ // The local split("/") helper that leaked the id must be gone.+ assert.doesNotMatch(composer, /function modelDisplayName\(/);++ const audio = readFileSync(+ fileURLToPath(+ new URL(+ "../src/features/chat/audio-attachment-adapter.ts",+ import.meta.url,+ ),+ ),+ "utf8",+ );+ assert.match(+ audio,+ /activeModel\?\.name \|\|\s*externalModelLabel\(checkpoint\) \|\|/,+ );+});++// The strings the trigger shows must exist in every locale: check-parity treats "picker."+// as a required overlay prefix, so a missing one fails CI rather than falling back.+test("the dropped-model strings are translated everywhere", async () => {+ const locales = [+ "ar",+ "de",+ "en",+ "es",+ "fr",+ "hi",+ "it",+ "ja",+ "ko",+ "pt-br",+ "ru",+ "zh-CN",+ ];+ for (const locale of locales) {+ const module = (await import(`../src/i18n/locales/${locale}.ts`)) as Record<+ string,+ { picker?: Record<string, string> }+ >;+ const picker = Object.values(module).find((value) => value?.picker)?.picker;+ assert.ok(picker, `${locale} has no picker section`);+ assert.equal(typeof picker.modelDropped, "string", locale);+ assert.equal(typeof picker.modelDroppedByProvider, "string", locale);+ assert.match(picker.modelDroppedByProvider, /\{provider\}/, locale);+ assert.equal(typeof picker.modelDisabled, "string", locale);+ assert.equal(typeof picker.modelDisabledByProvider, "string", locale);+ assert.match(picker.modelDisabledByProvider, /\{provider\}/, locale);+ // The two readings make different claims, so a locale that reuses one string for both+ // puts the withdrawal wording back on the user's own edit.+ assert.notEqual(picker.modelDisabled, picker.modelDropped, locale);+ assert.notEqual(+ picker.modelDisabledByProvider,+ picker.modelDroppedByProvider,+ locale,+ );+ }+});