Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: label the chat model bar by repo, not the HF cache path (#8090)

Daniel Han7cc26914c0e9
diff --git a/studio/backend/core/inference/model_ids.py b/studio/backend/core/inference/model_ids.py
index 3886307ae2b..c768858e3dd 100644
--- a/studio/backend/core/inference/model_ids.py
+++ b/studio/backend/core/inference/model_ids.py
@@ -79,6 +79,34 @@ def public_model_id(identifier: Optional[str]) -> Optional[str]:
return name or identifier
+def _is_hub_repo_id(identifier: str) -> bool:
+ """``org/name``, including Hub repos named ``org/name.gguf``. A file reference
+ carries a repo id plus a filename, so two or more slashes."""
+ if identifier.count("/") != 1:
+ return False
+ stem = (
+ identifier[: -len(_GGUF_SUFFIX)]
+ if identifier.lower().endswith(_GGUF_SUFFIX)
+ else identifier
+ )
+ return not _looks_like_path(stem)
+
+
+def display_model_name(identifier: Optional[str]) -> Optional[str]:
+ """The short label a UI should show for *identifier*.
+
+ Trailing segment of the public id, so a HF cache snapshot reads as ``X-GGUF`` and
+ not its commit sha. Splitting the raw identifier instead leaks the host layout on
+ Windows, where ``C:\\Users\\...`` has no ``/`` to split on.
+ """
+ if not identifier:
+ return identifier
+ if _is_hub_repo_id(identifier):
+ return identifier.split("/")[1]
+ clean = public_model_id(identifier)
+ return clean.rsplit("/", 1)[-1] or clean
+
+
def model_id_matches(requested: Optional[str], internal: Optional[str]) -> bool:
"""Whether a client-supplied *requested* id refers to *internal*.
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index d9e2916fb83..fbbebc13221 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -2015,7 +2015,7 @@ def _request_used_api_key(request: Any) -> bool:
from state.tool_approvals import resolve_tool_decision
from core.inference.key_exchange import decrypt_api_key
-from core.inference.model_ids import model_id_matches, public_model_id
+from core.inference.model_ids import display_model_name, model_id_matches, public_model_id
from core.inference.api_monitor import api_monitor
from core.inference.llama_http import nonstreaming_client
from core.inference.tool_call_parser import (
@@ -3704,7 +3704,9 @@ def _gguf_load_response(
return LoadResponse(
status = status,
model = model,
- display_name = display_name or model,
+ # Not the bare identifier: the already-resident path leaves display_name unset,
+ # and a cached repo loads from its snapshot dir, so clients label it by path.
+ display_name = display_name or display_model_name(model) or model,
is_lora = False,
is_gguf = True,
is_local_model = is_local_model,
diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.py
index 0bb86ad5430..f37c8eece35 100644
--- a/studio/backend/routes/models.py
+++ b/studio/backend/routes/models.py
@@ -20,6 +20,9 @@ from pydantic import BaseModel
from typing import List, Optional
import structlog
from loggers import get_logger
+
+# Dependency-light leaf (PEP 562 package init): no llama.cpp / torch import chain.
+from core.inference.model_ids import display_model_name
from utils.utils import canonical_model_repo_id, log_and_http_error
import re as _re
@@ -1806,7 +1809,7 @@ async def list_models(current_subject: str = Depends(get_current_subject)):
_audio_type = model_data.get("audio_type")
model_info = ModelDetails(
id = model_name,
- name = model_name.split("/")[-1] if "/" in model_name else model_name,
+ name = display_model_name(model_name),
is_vision = _is_vision,
is_lora = model_data.get("is_lora", False),
is_mlx = model_data.get("is_mlx", False),
@@ -1817,15 +1820,17 @@ async def list_models(current_subject: str = Depends(get_current_subject)):
)
loaded_models.append(model_info)
- # Include active GGUF model (loaded via llama-server).
- from routes.inference import get_llama_cpp_backend
+ # Active GGUF model (llama-server), labelled from the display id
+ # /api/inference/status publishes; the id stays raw for agents-tab's path filter.
+ from routes.inference import _llama_status_model_ids, get_llama_cpp_backend
llama_backend = get_llama_cpp_backend()
if llama_backend.is_loaded and llama_backend.model_identifier:
+ display_id, _reported_identifier = _llama_status_model_ids(llama_backend)
loaded_models.append(
ModelDetails(
id = llama_backend.model_identifier,
- name = llama_backend.model_identifier.split("/")[-1],
+ name = display_model_name(display_id or llama_backend.model_identifier),
is_gguf = True,
is_vision = llama_backend.is_vision,
is_audio = getattr(llama_backend, "_is_audio", False),
@@ -1842,7 +1847,7 @@ async def list_models(current_subject: str = Depends(get_current_subject)):
if model_id not in seen_ids:
model_info = loaded_by_id.get(model_id) or ModelDetails(
id = model_id,
- name = model_id.split("/")[-1] if "/" in model_id else model_id,
+ name = display_model_name(model_id),
is_gguf = model_id.upper().endswith("-GGUF"),
is_mlx = _looks_like_mlx_repo(model_id),
)
diff --git a/studio/backend/tests/test_model_ids.py b/studio/backend/tests/test_model_ids.py
index 38392c3906c..a4f84d92b03 100644
--- a/studio/backend/tests/test_model_ids.py
+++ b/studio/backend/tests/test_model_ids.py
@@ -77,3 +77,43 @@ def test_matches_clean_and_legacy():
assert not model_id_matches("other", path)
assert not model_id_matches(None, path)
assert not model_id_matches("x", None)
+
+
+def test_display_model_name_uses_the_repo_leaf_not_the_snapshot_sha():
+ from core.inference.model_ids import display_model_name
+
+ posix = (
+ "/home/u/.cache/huggingface/hub/models--unsloth--DeepSeek-V4-Flash-0731-GGUF"
+ "/snapshots/57326b941c4603e24d1a5e71c22520c66e086eb8"
+ )
+ assert display_model_name(posix) == "DeepSeek-V4-Flash-0731-GGUF"
+ # Reported case: a Windows cache path has no "/", so a raw rsplit labels the
+ # model with the whole home directory.
+ windows = (
+ "C:\\Users\\An\\.cache\\huggingface\\hub"
+ "\\models--unsloth--DeepSeek-V4-Flash-0731-GGUF"
+ "\\snapshots\\57326b941c4603e24d1a5e71c22520c66e086eb8"
+ )
+ assert display_model_name(windows) == "DeepSeek-V4-Flash-0731-GGUF"
+
+
+def test_display_model_name_leaves_ordinary_ids_alone():
+ from core.inference.model_ids import display_model_name
+
+ assert display_model_name("unsloth/Qwen3-30B-A3B-GGUF") == "Qwen3-30B-A3B-GGUF"
+ assert display_model_name("Qwen3-30B-A3B") == "Qwen3-30B-A3B"
+ assert display_model_name("/srv/models/Qwen3-30B-A3B-Q4_K_M.gguf") == ("Qwen3-30B-A3B-Q4_K_M")
+ assert display_model_name(None) is None
+ assert display_model_name("") == ""
+
+
+def test_display_model_name_keeps_gguf_on_hub_repo_ids():
+ from core.inference.model_ids import display_model_name
+
+ # A real Hub repo: the suffix is part of the leaf, not an extension to strip.
+ assert display_model_name("lex-au/Orpheus-3b-FT-Q8_0.gguf") == "Orpheus-3b-FT-Q8_0.gguf"
+ # A file inside a repo (>= 2 slashes) is still a file reference.
+ assert display_model_name("lex-au/Orpheus-3b-FT/Q8_0.gguf") == "Q8_0"
+ # An anchored one-slash id is a path, not a repo id.
+ assert display_model_name("/srv/Qwen3-Q4.gguf") == "Qwen3-Q4"
+ assert display_model_name("C:\\models\\Qwen3-Q4.gguf") == "Qwen3-Q4"
diff --git a/studio/backend/tests/test_models_list_resident_gguf_label.py b/studio/backend/tests/test_models_list_resident_gguf_label.py
new file mode 100644
index 00000000000..996fe16f5f2
--- /dev/null
+++ b/studio/backend/tests/test_models_list_resident_gguf_label.py
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""GET /api/models/list must label the resident GGUF the way the chat model bar reads it.
+
+The bar renders the ``name`` of the models[] entry whose ``id`` is the client's
+``params.checkpoint``, which for a cached GGUF is the snapshot directory. Splitting that
+raw identifier on "/" showed the commit sha on POSIX and the whole home dir on Windows.
+"""
+
+import asyncio
+import sys
+from pathlib import Path
+
+_BACKEND = Path(__file__).resolve().parents[1]
+if str(_BACKEND) not in sys.path:
+ sys.path.insert(0, str(_BACKEND))
+
+import routes.inference as inf # noqa: E402
+import routes.models as models_route # noqa: E402
+
+_POSIX_SNAPSHOT = (
+ "/home/u/.cache/huggingface/hub/models--unsloth--DeepSeek-V4-Flash-0731-GGUF"
+ "/snapshots/57326b941c4603e24d1a5e71c22520c66e086eb8"
+)
+_WINDOWS_SNAPSHOT = (
+ "C:\\Users\\An\\.cache\\huggingface\\hub"
+ "\\models--unsloth--DeepSeek-V4-Flash-0731-GGUF"
+ "\\snapshots\\57326b941c4603e24d1a5e71c22520c66e086eb8"
+)
+
+
+class _FakeLlama:
+ is_vision = False
+
+ def __init__(
+ self,
+ identifier,
+ *,
+ native_grant_backed = False,
+ display_label = None,
+ ):
+ self.is_loaded = True
+ self.model_identifier = identifier
+ self._native_grant_backed = native_grant_backed
+ self._native_display_label = display_label
+
+
+class _FakeUnsloth:
+ default_models: list = []
+ models: dict = {}
+
+
+def _list_models(monkeypatch, llama):
+ monkeypatch.setattr(models_route, "get_inference_backend", lambda: _FakeUnsloth())
+ monkeypatch.setattr(inf, "get_llama_cpp_backend", lambda: llama)
+ return asyncio.run(models_route.list_models(current_subject = "unsloth")).models
+
+
+def test_hf_cache_snapshot_is_labelled_by_its_repo_leaf(monkeypatch):
+ for snapshot in (_POSIX_SNAPSHOT, _WINDOWS_SNAPSHOT):
+ entries = _list_models(monkeypatch, _FakeLlama(snapshot))
+
+ assert len(entries) == 1
+ entry = entries[0]
+ # The id stays the checkpoint the client holds, so the picker still finds
+ # this entry; only the label is cleaned up.
+ assert entry.id == snapshot
+ assert entry.name == "DeepSeek-V4-Flash-0731-GGUF"
+ assert entry.is_gguf is True
+
+
+def test_standalone_gguf_is_labelled_by_its_file_stem(monkeypatch):
+ entries = _list_models(monkeypatch, _FakeLlama("/srv/models/Qwen3-30B-A3B-Q4_K_M.gguf"))
+
+ assert entries[0].name == "Qwen3-30B-A3B-Q4_K_M"
+
+
+def test_native_lease_keeps_the_path_shaped_id_agents_tab_filters_on(monkeypatch):
+ # agents-tab's discoverGgufModels drops path-shaped ids so a native lease's label,
+ # which cannot reload the file, never lands in a --model command. Only the label
+ # is cleaned here.
+ entries = _list_models(
+ monkeypatch,
+ _FakeLlama(
+ "/private/var/leases/xyz/Qwen3-4B-Q4_K_M.gguf",
+ native_grant_backed = True,
+ display_label = "Qwen3-4B-Q4_K_M.gguf",
+ ),
+ )
+
+ assert entries[0].id == "/private/var/leases/xyz/Qwen3-4B-Q4_K_M.gguf"
+ assert entries[0].name == "Qwen3-4B-Q4_K_M"
+
+
+def test_plain_repo_ids_are_unchanged(monkeypatch):
+ class _Backend(_FakeUnsloth):
+ default_models = ["unsloth/Qwen3-4B-Instruct-2507", "Qwen3-4B"]
+
+ monkeypatch.setattr(models_route, "get_inference_backend", lambda: _Backend())
+ monkeypatch.setattr(inf, "get_llama_cpp_backend", lambda: _FakeLlama(None))
+
+ entries = asyncio.run(models_route.list_models(current_subject = "unsloth")).models
+
+ assert [(e.id, e.name) for e in entries] == [
+ ("unsloth/Qwen3-4B-Instruct-2507", "Qwen3-4B-Instruct-2507"),
+ ("Qwen3-4B", "Qwen3-4B"),
+ ]
+
+
+def test_already_resident_load_response_never_echoes_the_snapshot_path(monkeypatch):
+ # The already-loaded fast path leaves display_name unset, so the response fell back
+ # to the identifier the GGUF loaded from, and the client labelled the model with it.
+ import routes.inference as inf_route
+
+ monkeypatch.setattr(inf_route, "_llama_runtime_fields", lambda backend: {})
+ monkeypatch.setattr(inf_route, "load_inference_config", lambda identifier: {})
+
+ resp = inf_route._gguf_load_response(
+ _FakeLlama(_POSIX_SNAPSHOT),
+ "already_loaded",
+ _POSIX_SNAPSHOT,
+ is_local_model = True,
+ )
+
+ assert resp.display_name == "DeepSeek-V4-Flash-0731-GGUF"
+ # The loadable identifier itself is unchanged.
+ assert resp.model == _POSIX_SNAPSHOT
+
+
+def test_an_explicit_display_name_still_wins(monkeypatch):
+ import routes.inference as inf_route
+
+ monkeypatch.setattr(inf_route, "_llama_runtime_fields", lambda backend: {})
+ monkeypatch.setattr(inf_route, "load_inference_config", lambda identifier: {})
+
+ resp = inf_route._gguf_load_response(
+ _FakeLlama(_POSIX_SNAPSHOT),
+ "loaded",
+ _POSIX_SNAPSHOT,
+ display_name = "DeepSeek-V4-Flash-0731 (UD-IQ2_M)",
+ is_local_model = True,
+ )
+
+ assert resp.display_name == "DeepSeek-V4-Flash-0731 (UD-IQ2_M)"
+
+
+def test_a_hub_repo_id_ending_in_gguf_keeps_its_suffix(monkeypatch):
+ # These are real repo ids, not file paths, so the label is the whole repo leaf;
+ # only a >= 2-slash id names a file inside a repo.
+ class _Backend(_FakeUnsloth):
+ default_models = ["lex-au/Orpheus-3b-FT-Q8_0.gguf"]
+
+ monkeypatch.setattr(models_route, "get_inference_backend", lambda: _Backend())
+ monkeypatch.setattr(inf, "get_llama_cpp_backend", lambda: _FakeLlama(None))
+
+ entries = asyncio.run(models_route.list_models(current_subject = "unsloth")).models
+
+ assert entries[0].name == "Orpheus-3b-FT-Q8_0.gguf"
diff --git a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
index 342facfcdd0..c7688ef64d2 100644
--- a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
+++ b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
@@ -10,6 +10,8 @@ import {
useTransformersUpgradeDialogStore,
} from "@/features/transformers-upgrade";
import { consumeNativePathToken } from "@/features/native-intents/api";
+// eslint-disable-next-line no-restricted-imports -- Avoid the hub barrel's React and download-manager exports.
+import { modelDisplayName } from "@/features/hub/lib/model-identity";
import { prepareHfTokenForUse } from "@/features/hf-auth";
import {
notifyNative,
@@ -234,7 +236,9 @@ export function syncModelCapabilities(
...models,
{
id: modelId,
- name: resp.display_name || modelId,
+ // Label like the catalog entry that replaces this on the next /api/models/list;
+ // the fallback keeps a cached GGUF's snapshot path out of the bar.
+ name: modelDisplayName(resp.display_name || modelId),
isLora: Boolean(resp.is_lora),
...synced,
},
diff --git a/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts b/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
index 3238a8ee4ec..2f8e211a43c 100644
--- a/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
+++ b/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
@@ -4,6 +4,8 @@
// Barrel import (lint rule); the model-picker cycle is fine because the call
// happens at runtime, not module eval.
import { resolveResidentInitialConfig } from "@/features/model-picker";
+// eslint-disable-next-line no-restricted-imports -- Avoid the hub barrel's React and download-manager exports.
+import { modelDisplayName } from "@/features/hub/lib/model-identity";
import { getInferenceStatus } from "../api/chat-api";
import {
mergeBackendRecommendedInference,
@@ -110,7 +112,9 @@ function ensureActiveModelInStoreList(
}
const summary: ChatModelSummary = {
id: checkpointId,
- name: status.active_model ?? checkpointId,
+ // active_model is already the clean public id; its leaf matches the catalog rows,
+ // and the fallback keeps a snapshot path out of the trigger.
+ name: modelDisplayName(status.active_model ?? checkpointId),
isVision: status.is_vision ?? false,
isLora: false,
isGguf: status.is_gguf ?? false,
diff --git a/studio/frontend/src/features/hub/lib/model-identity.ts b/studio/frontend/src/features/hub/lib/model-identity.ts
index 6cebe5477d9..01bdb8d578f 100644
--- a/studio/frontend/src/features/hub/lib/model-identity.ts
+++ b/studio/frontend/src/features/hub/lib/model-identity.ts
@@ -128,6 +128,30 @@ export function publicModelId(identifier: string): string {
return name.replace(GGUF_SUFFIX_RE, "") || trimmed;
}
+/** `org/name`, including Hub repos named `org/name.gguf`. A file reference carries a
+* repo id plus a filename, so two or more slashes. */
+function isHubRepoId(identifier: string): boolean {
+ if (identifier.split("/").length - 1 !== 1) {
+ return false;
+ }
+ return !looksLikeModelPath(identifier.replace(GGUF_SUFFIX_RE, ""));
+}
+
+/**
+* The short label for a model id with no catalog entry to take a name from. Mirrors
+* ``display_model_name`` in core/inference/model_ids.py: the public id's trailing
+* segment, so a repo id and the HF cache snapshot it loads from read alike. Splitting
+* the raw id leaks the host layout on Windows, where ``C:\\Users\\...`` holds no ``/``.
+*/
+export function modelDisplayName(identifier: string): string {
+ const trimmed = identifier.trim();
+ if (isHubRepoId(trimmed)) {
+ return trimmed.slice(trimmed.indexOf("/") + 1);
+ }
+ const clean = publicModelId(trimmed);
+ return clean.slice(clean.lastIndexOf("/") + 1) || clean;
+}
+
/**
* Whether the model the backend reports as loaded is one of *candidates*.
*
diff --git a/studio/frontend/src/features/model-picker/components/model-selector.tsx b/studio/frontend/src/features/model-picker/components/model-selector.tsx
index 43f8108b308..5a439d1447f 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector.tsx
+++ b/studio/frontend/src/features/model-picker/components/model-selector.tsx
@@ -38,7 +38,7 @@ import {
import type { HfTaskFilter } from "@/features/hub/hooks/use-hub-model-search";
import {
isOllamaLinkPath,
- publicModelId,
+ modelDisplayName,
} from "../model-config/model-identity";
import {
type PerModelConfig,
@@ -757,16 +757,17 @@ export function ModelSelector({
const currentModel = useMemo(() => {
if (!selected) return undefined;
const found = optionById.get(selected);
- // A model loaded by path is absent from the list, and its raw id fills the
- // header; label it with the public id the backend reports as active_model.
- const name = publicModelId(selected);
+ // 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);
if (activeGgufVariant) {
const desc = `GGUF · ${activeGgufVariant}`;
return found
? { ...found, description: desc }
- : { id: selected, name, description: desc };
+ : { id: selected, name: fallbackName, description: desc };
}
- return found ?? { id: selected, name };
+ return found ?? { id: selected, name: fallbackName };
}, [selected, optionById, activeGgufVariant]);
function handleSelect(id: string, meta: ModelSelectorChangeMeta) {
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.ts
index c16e72e4396..cf28569096c 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
@@ -12,6 +12,7 @@ export {
isNativeFileLabel,
isOllamaLinkPath,
isStandaloneGgufPath,
+ modelDisplayName,
normalizeGgufVariantIdentity,
normalizeModelIdentity,
publicModelId,
diff --git a/studio/frontend/tests/model-identity.test.ts b/studio/frontend/tests/model-identity.test.ts
index 3412fe9e567..267da1e04aa 100644
--- a/studio/frontend/tests/model-identity.test.ts
+++ b/studio/frontend/tests/model-identity.test.ts
@@ -12,6 +12,7 @@ import type {
import {
isOllamaLinkPath,
isStandaloneGgufPath,
+ modelDisplayName,
modelIdsMatch,
normalizeModelIdentity,
publicModelId,
@@ -427,3 +428,40 @@ test("preserves existing platform and Hub identity rules", () => {
);
assert.equal(normalizeModelIdentity("Org/Model"), "org/model");
});
+
+
+test("labels a model id with the repo leaf, never the raw path", () => {
+ // Reported case: a Windows HF cache path holds no "/", so splitting the raw id
+ // puts the whole home directory in the chat model bar.
+ assert.equal(
+ modelDisplayName(
+ String.raw`C:\Users\An\.cache\huggingface\hub\models--unsloth--DeepSeek-V4-Flash-0731-GGUF\snapshots\57326b941c4603e24d1a5e71c22520c66e086eb8`,
+ ),
+ "DeepSeek-V4-Flash-0731-GGUF",
+ );
+ assert.equal(
+ modelDisplayName(
+ "/home/u/.cache/huggingface/hub/models--unsloth--DeepSeek-V4-Flash-0731-GGUF/snapshots/57326b941c4603e24d1a5e71c22520c66e086eb8",
+ ),
+ "DeepSeek-V4-Flash-0731-GGUF",
+ );
+ assert.equal(
+ modelDisplayName("/srv/models/Qwen3-30B-A3B-Q4_K_M.gguf"),
+ "Qwen3-30B-A3B-Q4_K_M",
+ );
+ assert.equal(modelDisplayName("unsloth/Qwen3-30B-A3B-GGUF"), "Qwen3-30B-A3B-GGUF");
+ assert.equal(modelDisplayName("Qwen3-30B-A3B"), "Qwen3-30B-A3B");
+ assert.equal(modelDisplayName(""), "");
+});
+
+test("keeps .gguf on Hub repo ids, which are not file paths", () => {
+ // These are real repos; the suffix is part of the leaf. Only a >= 2-slash id
+ // names a file inside a repo.
+ assert.equal(
+ modelDisplayName("lex-au/Orpheus-3b-FT-Q8_0.gguf"),
+ "Orpheus-3b-FT-Q8_0.gguf",
+ );
+ assert.equal(modelDisplayName("lex-au/Orpheus-3b-FT/Q8_0.gguf"), "Q8_0");
+ assert.equal(modelDisplayName("/srv/Qwen3-Q4.gguf"), "Qwen3-Q4");
+ assert.equal(modelDisplayName(String.raw`C:\models\Qwen3-Q4.gguf`), "Qwen3-Q4");
+});