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 Hub: On Device filters and sort, Exports & Fine-tunes, unsloth.ai links (#14083)

Michael Han2b0ad0c8f0e4
diff --git a/studio/backend/hub/routes/inventory.py b/studio/backend/hub/routes/inventory.py
index 939581b4dc5..7b5a5c9f6a3 100644
--- a/studio/backend/hub/routes/inventory.py
+++ b/studio/backend/hub/routes/inventory.py
@@ -81,6 +81,16 @@ async def list_local_models(
return redact_inventory_host_paths(payload, via_api_key = via_api_key)
[email protected]("/unsloth-models", response_model = LocalModelListResponse)
+async def list_unsloth_models(
+ current_subject: str = Depends(get_current_subject),
+ via_api_key: bool = Depends(authenticated_via_api_key),
+):
+ """Models fine-tuned or exported in Studio, for the Hub's On Device list."""
+ payload = await local_inventory.list_unsloth_models_response()
+ return redact_inventory_host_paths(payload, via_api_key = via_api_key)
+
+
# Plain def, not async: synchronous SQLite and filesystem work runs in FastAPI's thread pool instead
# of blocking the event loop.
@router.get("/scan-folders", response_model = ScanFoldersResponse)
diff --git a/studio/backend/hub/schemas/inventory.py b/studio/backend/hub/schemas/inventory.py
index dd75ddcbb2e..000883287b5 100644
--- a/studio/backend/hub/schemas/inventory.py
+++ b/studio/backend/hub/schemas/inventory.py
@@ -15,7 +15,7 @@ from core.inference.audio_workflows import inventory_audio_workflows
ModelFormat = Literal["gguf", "safetensors", "adapter", "checkpoint", "unknown"]
ModelRuntime = Literal["llama_cpp", "transformers", "adapter", "unknown"]
LocalModelSource = Literal[
- "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom"
+ "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom", "unsloth"
]
LocalArtifactKind = Literal[
"diffusers_pipeline",
diff --git a/studio/backend/hub/services/models/common.py b/studio/backend/hub/services/models/common.py
index cf3d23be6cf..afada9dbb12 100644
--- a/studio/backend/hub/services/models/common.py
+++ b/studio/backend/hub/services/models/common.py
@@ -32,7 +32,7 @@ from utils.paths.path_utils import drop_appledouble_metadata, is_appledouble_met
ModelType = Literal["text", "vision", "audio", "embeddings"]
LocalModelSource = Literal[
- "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom"
+ "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom", "unsloth"
]
diff --git a/studio/backend/hub/services/models/local_inventory.py b/studio/backend/hub/services/models/local_inventory.py
index 6b3149e179a..1b398b7f125 100644
--- a/studio/backend/hub/services/models/local_inventory.py
+++ b/studio/backend/hub/services/models/local_inventory.py
@@ -1459,6 +1459,53 @@ async def _scan_local_models_response(
)
+def _scan_unsloth_models() -> List[LocalModelInfo]:
+ """Studio's own fine-tunes (outputs/) and exports (exports/), found the way the Library finds them."""
+ from utils.models.model_config import scan_exported_models, scan_trained_models
+ from utils.paths.storage_roots import exports_root, outputs_root
+
+ found = [(name, path) for name, path, _ in scan_trained_models(str(outputs_root()))]
+ found += [(name, path) for name, path, _, _ in scan_exported_models(str(exports_root()))]
+ rows: List[LocalModelInfo] = []
+ for name, raw_path in found:
+ path = Path(raw_path)
+ # A GGUF export is named by its largest quant; its folder lists every quant it holds.
+ if path.suffix.lower() == ".gguf":
+ path = path.parent
+ try:
+ updated_at = path.stat().st_mtime
+ except OSError:
+ continue
+ classified = _classify_local_path(path, "unsloth", display_name = name, updated_at = updated_at)
+ rows.extend(_apply_payload_partial(path, classified))
+ return _classify_unsloth_models(rows)
+
+
+def _classify_unsloth_models(models: List[LocalModelInfo]) -> List[LocalModelInfo]:
+ try:
+ from hub.services.models import catalog_classification
+
+ classified = []
+ for model in models:
+ task, audio_type = catalog_classification._local_model_classification(model)
+ classified.append(model.model_copy(update = {"task": task, "audio_type": audio_type}))
+ return classified
+ except Exception as e: # noqa: BLE001 -- classification never breaks the listing
+ logger.warning("Could not classify Unsloth model tasks: %s", scrub_paths(e))
+ return models
+
+
+async def list_unsloth_models_response() -> LocalModelListResponse:
+ # Off the loop with the scan: classifying a GGUF reads its header.
+ try:
+ models = await asyncio.to_thread(_scan_unsloth_models)
+ except Exception as e:
+ logger.error("Error listing Unsloth models: %s", scrub_paths(e), exc_info = True)
+ raise _http_error(status_code = 500, detail = f"Failed to list Unsloth models: {str(e)}")
+ response = LocalModelListResponse(models_dir = str(outputs_root()), models = models)
+ return await _account_local_response(response)
+
+
async def _account_local_response(response):
if not _account_access().managed_account():
return response
diff --git a/studio/backend/hub/utils/host_paths.py b/studio/backend/hub/utils/host_paths.py
index ae2eef9d5f6..b3ebef32743 100644
--- a/studio/backend/hub/utils/host_paths.py
+++ b/studio/backend/hub/utils/host_paths.py
@@ -116,7 +116,7 @@ HOST_PATH_ENCODED_IDENTITY_FIELD = "inventory_id"
HOST_PATH_ROW_SOURCE_FIELD = "source"
# `hf_cache` is absent: those rows are named by repo id, and otherwise value decides.
HOST_PATH_LOCAL_SOURCES = frozenset(
- {"models_dir", "lmstudio", "omlx", "ollama", "hermes", "custom"}
+ {"models_dir", "lmstudio", "omlx", "ollama", "hermes", "custom", "unsloth"}
)
diff --git a/studio/backend/models/models.py b/studio/backend/models/models.py
index caa895a48d6..0ebdd2515ad 100644
--- a/studio/backend/models/models.py
+++ b/studio/backend/models/models.py
@@ -267,7 +267,7 @@ class GgufVariantsResponse(BaseModel):
LocalModelSource = Literal[
- "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom"
+ "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom", "unsloth"
]
diff --git a/studio/backend/tests/test_hub_unsloth_models.py b/studio/backend/tests/test_hub_unsloth_models.py
new file mode 100644
index 00000000000..4dd5a287d93
--- /dev/null
+++ b/studio/backend/tests/test_hub_unsloth_models.py
@@ -0,0 +1,75 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""The Hub's On Device list takes Studio's own fine-tunes and exports as source "unsloth"."""
+
+import json
+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))
+
+from hub.services.models import local_inventory # noqa: E402
+from hub.utils.host_paths import HOST_PATH_LOCAL_SOURCES # noqa: E402
+
+
+def _roots(tmp_path, monkeypatch):
+ from utils.paths import storage_roots
+
+ outputs, exports = tmp_path / "outputs", tmp_path / "exports"
+ outputs.mkdir()
+ exports.mkdir()
+ monkeypatch.setattr(storage_roots, "outputs_root", lambda: outputs)
+ monkeypatch.setattr(storage_roots, "exports_root", lambda: exports)
+ import utils.models.model_config as model_config
+
+ monkeypatch.setattr(model_config, "within_account", lambda _path: True)
+ return outputs, exports
+
+
+def test_fine_tunes_and_exports_are_listed_as_unsloth(tmp_path, monkeypatch):
+ outputs, exports = _roots(tmp_path, monkeypatch)
+ run = outputs / "my-run"
+ run.mkdir()
+ (run / "adapter_config.json").write_text(
+ json.dumps({"base_model_name_or_path": "unsloth/Qwen3-0.6B", "peft_type": "LORA"})
+ )
+ (run / "adapter_model.safetensors").write_bytes(b"x" * 16)
+ gguf = exports / "my-run-finetune-gguf"
+ gguf.mkdir()
+ (gguf / "model-Q4_K_M.gguf").write_bytes(b"GGUF" + b"\0" * 64)
+
+ rows = local_inventory._scan_unsloth_models()
+
+ assert {row.source for row in rows} == {"unsloth"}
+ by_path = {Path(row.path).resolve(): row for row in rows}
+ adapter = by_path[run.resolve()]
+ assert adapter.model_format == "adapter"
+ assert adapter.base_model == "unsloth/Qwen3-0.6B"
+ assert any(Path(row.path).resolve().is_relative_to(gguf.resolve()) for row in rows)
+
+
+def test_nothing_trained_lists_nothing(tmp_path, monkeypatch):
+ _roots(tmp_path, monkeypatch)
+ assert local_inventory._scan_unsloth_models() == []
+
+
+def test_unsloth_rows_have_their_host_paths_redacted():
+ assert "unsloth" in HOST_PATH_LOCAL_SOURCES
+
+
+def test_a_gguf_export_with_several_quants_offers_all_of_them(tmp_path, monkeypatch):
+ _, exports = _roots(tmp_path, monkeypatch)
+ export = exports / "my-run-finetune-gguf"
+ export.mkdir()
+ (export / "my-run-Q4_K_M.gguf").write_bytes(b"GGUF" + b"\0" * 64)
+ (export / "my-run-Q8_0.gguf").write_bytes(b"GGUF" + b"\0" * 128)
+
+ rows = local_inventory._scan_unsloth_models()
+
+ # The folder, so the card offers every quant, not just the largest file.
+ [row] = rows
+ assert Path(row.path).resolve() == export.resolve()
+ assert row.capabilities.requires_variant
diff --git a/studio/frontend/src/features/hub/catalog/external-link-confirm-dialog.tsx b/studio/frontend/src/features/hub/catalog/external-link-confirm-dialog.tsx
index b17898a8e0a..85cc31d24bc 100644
--- a/studio/frontend/src/features/hub/catalog/external-link-confirm-dialog.tsx
+++ b/studio/frontend/src/features/hub/catalog/external-link-confirm-dialog.tsx
@@ -9,7 +9,6 @@ import {
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
- AlertDialogMedia,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { openLink } from "@/lib/open-link";
@@ -37,23 +36,25 @@ export function ExternalLinkConfirmDialog() {
if (!next) dismiss();
}}
>
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogMedia>
- <HugeiconsIcon
- icon={LinkSquare02Icon}
- strokeWidth={1.75}
- className="text-muted-foreground"
- />
- </AlertDialogMedia>
- <AlertDialogTitle>Open external link</AlertDialogTitle>
+ <AlertDialogContent className="gap-5 sm:max-w-[calc(400px*var(--ui-space-scale,1))]">
+ <AlertDialogHeader className="place-items-stretch gap-2 text-left">
+ <div className="flex items-center gap-3">
+ <span className="inline-flex size-9 shrink-0 items-center justify-center rounded-full bg-muted">
+ <HugeiconsIcon
+ icon={LinkSquare02Icon}
+ strokeWidth={1.75}
+ className="size-4.5 text-muted-foreground"
+ />
+ </span>
+ <AlertDialogTitle>Open external link</AlertDialogTitle>
+ </div>
<AlertDialogDescription>
You are about to leave Unsloth and open this page in your browser.
Only continue if you trust the destination.
</AlertDialogDescription>
</AlertDialogHeader>
{pendingUrl && (
- <div className="min-w-0 rounded-[12px] bg-muted/50 px-3 py-2.5 text-left">
+ <div className="min-w-0 rounded-[12px] bg-muted/50 px-3.5 py-3 text-left">
<p className="truncate text-ui-13 font-medium text-foreground">
{hostOf(pendingUrl)}
</p>
diff --git a/studio/frontend/src/features/hub/catalog/inventory-sort.ts b/studio/frontend/src/features/hub/catalog/inventory-sort.ts
index dd5932b07af..79f343005ca 100644
--- a/studio/frontend/src/features/hub/catalog/inventory-sort.ts
+++ b/studio/frontend/src/features/hub/catalog/inventory-sort.ts
@@ -1,6 +1,7 @@
// 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 { FormatFilterModelFormat } from "../lib/format-filters";
import type { CachedInventoryRow, LocalInventoryRow } from "../types";
export type InventoryItem =
@@ -12,7 +13,35 @@ export function inventoryItemTitle(item: InventoryItem): string {
}
export function inventoryItemSize(item: InventoryItem): number {
- return item.variant === "cached" ? item.row.bytes : 0;
+ return item.variant === "cached" ? item.row.bytes : (item.row.bytes ?? 0);
+}
+
+/** The scan never reports "mlx"; an MLX folder says so in its library, tags or oMLX source. */
+export function inventoryRowFormat(
+ row: CachedInventoryRow | LocalInventoryRow,
+): FormatFilterModelFormat {
+ if (row.modelFormat === "gguf") {
+ return "gguf";
+ }
+ const mlx =
+ row.libraryName?.toLowerCase() === "mlx" ||
+ (row.tags ?? []).some((tag) => tag.toLowerCase() === "mlx") ||
+ (row.kind === "local" && row.source === "omlx");
+ return mlx ? "mlx" : row.modelFormat;
+}
+
+const FORMAT_RANK: Record<FormatFilterModelFormat, number> = {
+ gguf: 0,
+ safetensors: 1,
+ checkpoint: 1,
+ mlx: 2,
+ adapter: 3,
+ unknown: 4,
+};
+
+/** The format dropdown's order: GGUF, Safetensors, MLX, then adapters and the rest. */
+export function inventoryItemFormatRank(item: InventoryItem): number {
+ return FORMAT_RANK[inventoryRowFormat(item.row)];
}
/** row timestamp in epoch milliseconds, or null when unknown. */
diff --git a/studio/frontend/src/features/hub/catalog/model-search-filters.tsx b/studio/frontend/src/features/hub/catalog/model-search-filters.tsx
index d9236677542..040a1721515 100644
--- a/studio/frontend/src/features/hub/catalog/model-search-filters.tsx
+++ b/studio/frontend/src/features/hub/catalog/model-search-filters.tsx
@@ -49,6 +49,14 @@ import {
} from "../lib/dataset-filters";
import { CAPABILITY_FILTER_OPTIONS } from "../lib/view-models";
+/** On Device's own capability picks, kept apart from Discover's. */
+export interface OnDeviceFilters {
+ capabilities: HubCapabilityFilter[];
+ onCapabilitiesChange: (value: HubCapabilityFilter[]) => void;
+ isolateFirstCapability: boolean;
+ onReset: () => void;
+}
+
const CAPABILITY_ICONS: Record<HubCapabilityFilter, IconSvgElement | null> = {
text: TextFontIcon,
// The composer's thinking bulb, which isn't a Hugeicons glyph.
@@ -513,6 +521,75 @@ function HoverInfo({ label, children }: { label: string; children: string }) {
);
}
+/** Capability ticks: none picked means every box ticked; a model with any pick is listed. */
+function CapabilityTiles({
+ capabilities,
+ onChange,
+ isolateFirst,
+}: {
+ capabilities: HubCapabilityFilter[];
+ onChange: (value: HubCapabilityFilter[]) => void;
+ /** The first pick from the defaults keeps just that one. */
+ isolateFirst: boolean;
+}) {
+ return (
+ <fieldset>
+ <legend className={SECTION_LABEL}>
+ Capabilities
+ {capabilities.length > 0 && (
+ <button
+ type="button"
+ onClick={() => onChange([])}
+ className="cursor-pointer transition-colors hover:text-foreground"
+ >
+ Select all
+ </button>
+ )}
+ </legend>
+ <div className="grid grid-cols-2 gap-1.5 px-3">
+ {CAPABILITY_FILTER_OPTIONS.map((option) => {
+ const ticked = (key: HubCapabilityFilter) =>
+ capabilities.length === 0 || capabilities.includes(key);
+ const checked = ticked(option.value);
+ const glyph = CAPABILITY_ICONS[option.value];
+ // Kept in the list's order, so it doesn't depend on click order.
+ const next = CAPABILITY_FILTER_OPTIONS.map((o) => o.value).filter(
+ (key) => (key === option.value ? !checked : ticked(key)),
+ );
+ return (
+ <OptionTile
+ key={option.value}
+ icon={
+ glyph ? (
+ <HugeiconsIcon
+ icon={glyph}
+ strokeWidth={2}
+ className="size-4 shrink-0"
+ />
+ ) : (
+ <BulbIcon className="size-4 shrink-0" />
+ )
+ }
+ label={option.label}
+ checked={checked}
+ locked={next.length === 0}
+ onToggle={() =>
+ onChange(
+ capabilities.length === 0 && isolateFirst
+ ? [option.value]
+ : next.length === CAPABILITY_FILTER_OPTIONS.length
+ ? []
+ : next,
+ )
+ }
+ />
+ );
+ })}
+ </div>
+ </fieldset>
+ );
+}
+
/** The Hub's filter popover: capabilities, then (where the Hub search takes them) size and
* context limits and the uploader. Ticks apply at once; the limits on release. */
export function ModelSearchFiltersControl({
@@ -532,6 +609,7 @@ export function ModelSearchFiltersControl({
datasetSections,
modalities,
onModalitiesChange,
+ onDevice,
className,
}: {
value: ModelSearchFilters;
@@ -557,15 +635,19 @@ export function ModelSearchFiltersControl({
modalities: DatasetModality[];
onModalitiesChange: (value: DatasetModality[]) => void;
onDatasetsChange: (value: boolean) => void;
+ /** Set on On Device, whose sections replace the Hub search's. */
+ onDevice?: OnDeviceFilters;
className?: string;
}) {
const [open, setOpen] = useState(false);
const unslothOnly = uploaders.length === 1 && uploaders[0] === "unsloth";
- const filtered =
- modalities.length > 0 ||
- (modelSections && capabilities.length > 0) ||
- uploadersChanged ||
- ((showModelFilters || datasetSections) && hasModelSearchFilters(value));
+ const onDeviceModels = onDevice !== undefined && !datasets;
+ const filtered = onDevice
+ ? onDeviceModels && onDevice.capabilities.length > 0
+ : modalities.length > 0 ||
+ (modelSections && capabilities.length > 0) ||
+ uploadersChanged ||
+ ((showModelFilters || datasetSections) && hasModelSearchFilters(value));
return (
<Popover open={open} onOpenChange={setOpen}>
{/* Icon-sized so the Discover toolbar keeps its existing single-row layout. */}
@@ -602,64 +684,20 @@ export function ModelSearchFiltersControl({
className="hub-menu-instant hub-composer-menu menu-soft-surface gap-0 overflow-hidden w-[calc(392px*var(--ui-space-scale,1))] max-w-[calc(100vw-1rem)] ring-0"
>
<div className="flex min-h-0 flex-1 flex-col gap-4.25 overflow-y-auto overscroll-contain pt-2.25 pb-4.25 [scrollbar-width:thin]">
+ {onDeviceModels && (
+ <CapabilityTiles
+ capabilities={onDevice.capabilities}
+ onChange={onDevice.onCapabilitiesChange}
+ isolateFirst={onDevice.isolateFirstCapability}
+ />
+ )}
{modelSections && (
<>
- <fieldset>
- <legend className={SECTION_LABEL}>
- Capabilities
- {capabilities.length > 0 && (
- <button
- type="button"
- onClick={() => onCapabilitiesChange([])}
- className="cursor-pointer transition-colors hover:text-foreground"
- >
- Select all
- </button>
- )}
- </legend>
- <div className="grid grid-cols-2 gap-1.5 px-3">
- {CAPABILITY_FILTER_OPTIONS.map((option) => {
- const ticked = (key: HubCapabilityFilter) =>
- capabilities.length === 0 || capabilities.includes(key);
- const checked = ticked(option.value);
- const glyph = CAPABILITY_ICONS[option.value];
- // Kept in the list's order, so it doesn't depend on click order.
- const next = CAPABILITY_FILTER_OPTIONS.map(
- (o) => o.value,
- ).filter((key) =>
- key === option.value ? !checked : ticked(key),
- );
- return (
- <OptionTile
- key={option.value}
- icon={
- glyph ? (
- <HugeiconsIcon
- icon={glyph}
- strokeWidth={2}
- className="size-4 shrink-0"
- />
- ) : (
- <BulbIcon className="size-4 shrink-0" />
- )
- }
- label={option.label}
- checked={checked}
- locked={next.length === 0}
- onToggle={() =>
- onCapabilitiesChange(
- capabilities.length === 0 && isolateFirstCapability
- ? [option.value]
- : next.length === CAPABILITY_FILTER_OPTIONS.length
- ? []
- : next,
- )
- }
- />
- );
- })}
- </div>
- </fieldset>
+ <CapabilityTiles
+ capabilities={capabilities}
+ onChange={onCapabilitiesChange}
+ isolateFirst={isolateFirstCapability}
+ />
{showModelFilters &&
RANGES.map((spec) => (
<RangeStops
@@ -762,7 +800,7 @@ export function ModelSearchFiltersControl({
// "Reset all" has no descenders: its ink sits 0.25em inside the text box on each side.
className={cn(TEXT_BOX, "-my-[0.25em]")}
disabled={!filtered}
- onClick={onReset}
+ onClick={onDevice ? onDevice.onReset : onReset}
>
Reset all
</Button>
diff --git a/studio/frontend/src/features/hub/catalog/models-catalog-lists.tsx b/studio/frontend/src/features/hub/catalog/models-catalog-lists.tsx
index 6431d8aa70e..dac93aaa9a5 100644
--- a/studio/frontend/src/features/hub/catalog/models-catalog-lists.tsx
+++ b/studio/frontend/src/features/hub/catalog/models-catalog-lists.tsx
@@ -29,6 +29,7 @@ import type {
import {
compareInventoryItemsByRecent,
type InventoryItem,
+ inventoryItemFormatRank,
inventoryItemSize,
inventoryItemTitle,
} from "./inventory-sort";
@@ -351,12 +352,16 @@ export function DownloadedList({
.sort(
(a, b) =>
pinRank(a.item) - pinRank(b.item) ||
- (sort === "name"
- ? inventoryItemTitle(a.item).localeCompare(
- inventoryItemTitle(b.item),
- ) || a.index - b.index
- : inventoryItemSize(b.item) - inventoryItemSize(a.item) ||
- a.index - b.index),
+ (sort === "size"
+ ? inventoryItemSize(b.item) - inventoryItemSize(a.item)
+ : sort === "format"
+ ? inventoryItemFormatRank(a.item) -
+ inventoryItemFormatRank(b.item)
+ : 0) ||
+ inventoryItemTitle(a.item).localeCompare(
+ inventoryItemTitle(b.item),
+ ) ||
+ a.index - b.index,
)
.map((entry) => entry.item);
}, [cachedRows, localRows, inventoryTokens, sort, pinnedIds]);
diff --git a/studio/frontend/src/features/hub/catalog/models-table.tsx b/studio/frontend/src/features/hub/catalog/models-table.tsx
index c04918896df..3a9c23c737b 100644
--- a/studio/frontend/src/features/hub/catalog/models-table.tsx
+++ b/studio/frontend/src/features/hub/catalog/models-table.tsx
@@ -12,17 +12,12 @@ import {
formatRelativeLong,
formatRelativeShort,
} from "@/features/hub/lib/format";
-import {
- MODEL_TYPE_FILTER_OPTIONS,
- type ModelTypeFilter,
-} from "@/features/hub/lib/model-type-filter";
import {
formatModelParamLabel,
formatPipelineTag,
} from "@/features/hub/lib/view-models";
import { cn, formatCompact } from "@/lib/utils";
import {
- ArrowUpDownIcon,
Download01Icon,
FavouriteIcon,
LayoutTwoColumnIcon,
@@ -36,7 +31,6 @@ import type { IconSvgElement } from "@hugeicons/react";
import { HugeiconsIcon } from "@hugeicons/react";
import { type ReactNode, memo, useMemo } from "react";
import type { DiscoverRow } from "../types";
-import { HubOptionMenu } from "./hub-option-menu";
import {
DOWNLOADING_DOT_CLASS,
buildRowStatusTooltip,
@@ -98,73 +92,7 @@ function ViewToggleButton({
);
}
-export type InventorySort = "recent" | "name" | "size";
-
-const INVENTORY_SORTS: { value: InventorySort; label: string }[] = [
- { value: "recent", label: "Recent" },
- { value: "name", label: "Name" },
- { value: "size", label: "Size" },
-];
-
-// Sort picker as a compact dropdown pill so it sits beside the view-mode tabs.
-export function InventorySortControl({
- value,
- onChange,
-}: {
- value: InventorySort;
- onChange: (value: InventorySort) => void;
-}) {
- const selected = INVENTORY_SORTS.find((option) => option.value === value);
- return (
- <HubOptionMenu<InventorySort>
- value={value}
- options={INVENTORY_SORTS}
- onValueChange={onChange}
- ariaLabel="Sort downloads"
- align="end"
- title={selected?.label}
- // Capped and shrinkable so a long label truncates instead of wrapping
- // the "On device" heading beside these pills in the narrow split pane.
- className="h-8 min-w-[calc(72px*var(--ui-space-scale,1))] max-w-[calc(124px*var(--ui-space-scale,1))] shrink text-ui-11p5"
- triggerContent={
- <span className="flex min-w-0 items-center gap-1">
- <HugeiconsIcon
- icon={ArrowUpDownIcon}
- strokeWidth={1.75}
- className="size-3.5 shrink-0 text-muted-foreground"
- />
- <span className="truncate">{selected?.label ?? value}</span>
- </span>
- }
- />
- );
-}
-
-// Model-type filter pill (Text / Vision / Embedding / …) beside the sort pill.
-export function InventoryTypeFilterControl({
- value,
- onChange,
-}: {
- value: ModelTypeFilter;
- onChange: (value: ModelTypeFilter) => void;
-}) {
- const selected = MODEL_TYPE_FILTER_OPTIONS.find(
- (option) => option.value === value,
- );
- return (
- <HubOptionMenu<ModelTypeFilter>
- value={value}
- options={MODEL_TYPE_FILTER_OPTIONS}
- onValueChange={onChange}
- ariaLabel="Filter by model type"
- align="end"
- title={selected?.label}
- // Capped and shrinkable so a long label ("Speech to text") truncates
- // instead of wrapping the "On device" heading beside these pills.
- className="h-8 min-w-[calc(72px*var(--ui-space-scale,1))] max-w-[calc(124px*var(--ui-space-scale,1))] shrink text-ui-11p5"
- />
- );
-}
+export type InventorySort = "recent" | "name" | "size" | "format";
export function HubListHeader({
title,
diff --git a/studio/frontend/src/features/hub/catalog/models-toolbar.tsx b/studio/frontend/src/features/hub/catalog/models-toolbar.tsx
index 211a6c49abc..65e77bb7a92 100644
--- a/studio/frontend/src/features/hub/catalog/models-toolbar.tsx
+++ b/studio/frontend/src/features/hub/catalog/models-toolbar.tsx
@@ -42,7 +42,11 @@ import type {
ResourceTypeFilter,
} from "../types";
import { type HubOption, HubOptionMenu } from "./hub-option-menu";
-import { ModelSearchFiltersControl } from "./model-search-filters";
+import {
+ ModelSearchFiltersControl,
+ type OnDeviceFilters,
+} from "./model-search-filters";
+import type { InventorySort } from "./models-table";
import { RecentSearches } from "./recent-searches";
// Widened so the format dropdown can carry the "Fine-tune ready" pseudo-option,
@@ -61,6 +65,13 @@ const SORT_OPTIONS: ReadonlyArray<{
{ value: "likes", label: "Most likes" },
];
+const INVENTORY_SORT_OPTIONS: HubOption<InventorySort>[] = [
+ { value: "recent", label: "Recent" },
+ { value: "name", label: "Name" },
+ { value: "size", label: "Size" },
+ { value: "format", label: "Format" },
+];
+
export const ModelsToolbar = memo(function ModelsToolbar({
tab,
onTabChange,
@@ -90,6 +101,12 @@ export const ModelsToolbar = memo(function ModelsToolbar({
uploadersChanged,
onUploadersChange,
onResetFilters,
+ inventorySort,
+ onInventorySortChange,
+ inventoryCapabilities,
+ onInventoryCapabilitiesChange,
+ isolateFirstInventoryCapability,
+ onResetInventoryFilters,
}: {
searchFilters: ModelSearchFilters;
onSearchFiltersChange: (value: ModelSearchFilters) => void;
@@ -98,6 +115,12 @@ export const ModelsToolbar = memo(function ModelsToolbar({
uploadersChanged: boolean;
onUploadersChange: (value: HubUploader[]) => void;
onResetFilters: () => void;
+ inventorySort: InventorySort;
+ onInventorySortChange: (value: InventorySort) => void;
+ inventoryCapabilities: HubCapabilityFilter[];
+ onInventoryCapabilitiesChange: (value: HubCapabilityFilter[]) => void;
+ isolateFirstInventoryCapability: boolean;
+ onResetInventoryFilters: () => void;
tab: ModelsTab;
onTabChange: (tab: ModelsTab) => void;
query: string;
@@ -170,8 +193,9 @@ export const ModelsToolbar = memo(function ModelsToolbar({
const formatOptions = useMemo<HubOption<FormatMenuValue>[]>(() => {
const options: HubOption<FormatMenuValue>[] = FORMAT_FILTER_OPTIONS.filter(
(option) =>
- (option.value !== "mlx" && option.value !== "recommended") ||
- tab === "discover",
+ option.value === "unsloth"
+ ? tab === "downloaded"
+ : option.value !== "recommended" || tab === "discover",
).map((option) => ({
value: option.value,
triggerLabel: option.label,
@@ -194,6 +218,9 @@ export const ModelsToolbar = memo(function ModelsToolbar({
{option.value === "mlx" && (
<span className="size-1.5 rounded-full bg-format-mlx" />
)}
+ {option.value === "unsloth" && (
+ <span className="size-1.5 rounded-full bg-primary" />
+ )}
</span>
{option.label}
</>
@@ -233,6 +260,24 @@ export const ModelsToolbar = memo(function ModelsToolbar({
}
return options;
}, [tab, npuAvailable]);
+ const onDeviceFilters = useMemo<OnDeviceFilters | undefined>(
+ () =>
+ tab === "downloaded"
+ ? {
+ capabilities: inventoryCapabilities,
+ onCapabilitiesChange: onInventoryCapabilitiesChange,
+ isolateFirstCapability: isolateFirstInventoryCapability,
+ onReset: onResetInventoryFilters,
+ }
+ : undefined,
+ [
+ tab,
+ inventoryCapabilities,
+ onInventoryCapabilitiesChange,
+ isolateFirstInventoryCapability,
+ onResetInventoryFilters,
+ ],
+ );
const hubSource = useHubSource();
const showCapabilities = isDiscover && !isDataset && !npuList;
// The size and context limits read Hugging Face metadata, so only there.
@@ -410,6 +455,7 @@ export const ModelsToolbar = memo(function ModelsToolbar({
onDatasetsChange={(on) =>
onResourceTypeChange(on ? "datasets" : "models")
}
+ onDevice={onDeviceFilters}
className={cn(
triggerBase,
"relative inline-flex size-9 shrink-0 items-center justify-center rounded-full p-0",
@@ -421,21 +467,21 @@ export const ModelsToolbar = memo(function ModelsToolbar({
<button
type="button"
onClick={onManageLocalFolders}
+ aria-label="Add folder"
className={cn(
triggerBase,
- "field-filter inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full px-3 text-ui-12p5",
+ "field-filter relative inline-flex size-9 shrink-0 items-center justify-center rounded-full p-0",
)}
>
<HugeiconsIcon
icon={FolderSearchIcon}
strokeWidth={1.75}
- className="size-3.5"
+ className="size-[calc(18px*var(--ui-space-scale,1))]"
/>
- Add folder
</button>
</TooltipTrigger>
<TooltipContent side="bottom" sideOffset={6}>
- Manage local model folders
+ Add folder
</TooltipContent>
</Tooltip>
)}
@@ -447,21 +493,21 @@ export const ModelsToolbar = memo(function ModelsToolbar({
type="button"
onClick={onFreeUpSpace}
data-testid="free-up-space-trigger"
+ aria-label="Free up space"
className={cn(
triggerBase,
- "field-filter inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full px-3 text-ui-12p5",
+ "field-filter relative inline-flex size-9 shrink-0 items-center justify-center rounded-full p-0",
)}
>
<HugeiconsIcon
icon={Delete02Icon}
strokeWidth={1.75}
- className="size-3.5"
+ className="size-[calc(18px*var(--ui-space-scale,1))]"
/>
- Free up space
</button>
</TooltipTrigger>
<TooltipContent side="bottom" sideOffset={6}>
- Remove shared model assets no installed model needs
+ Free up space: remove shared assets no installed model needs
</TooltipContent>
</Tooltip>
)}
@@ -485,6 +531,33 @@ export const ModelsToolbar = memo(function ModelsToolbar({
/>
)}
+ {tab === "downloaded" && (
+ <HubOptionMenu<InventorySort>
+ value={inventorySort}
+ options={INVENTORY_SORT_OPTIONS}
+ onValueChange={onInventorySortChange}
+ ariaLabel="Sort on-device models"
+ className={cn(
+ triggerBase,
+ "w-[calc(160px*var(--ui-space-scale,1))]",
+ )}
+ triggerContent={
+ <span className="flex items-center gap-1">
+ <HugeiconsIcon
+ icon={ArrowUpDownIcon}
+ strokeWidth={1.75}
+ className="size-3.5 shrink-0"
+ />
+ <span className="truncate">
+ {INVENTORY_SORT_OPTIONS.find(
+ (option) => option.value === inventorySort,
+ )?.label ?? inventorySort}
+ </span>
+ </span>
+ }
+ />
+ )}
+
{tab === "discover" && !npuList && (
<HubOptionMenu
value={sortBy}
diff --git a/studio/frontend/src/features/hub/hub-page.tsx b/studio/frontend/src/features/hub/hub-page.tsx
index f71086da9c4..4db752d2a51 100644
--- a/studio/frontend/src/features/hub/hub-page.tsx
+++ b/studio/frontend/src/features/hub/hub-page.tsx
@@ -68,8 +68,6 @@ import {
type AllModelsView,
HubListHeader,
type InventorySort,
- InventorySortControl,
- InventoryTypeFilterControl,
} from "./catalog/models-table";
import {
HUB_UPLOADERS,
@@ -117,10 +115,8 @@ import {
hubAudioRunRefused,
hubAudioTask,
} from "./lib/model-run-selection";
-import {
- type ModelTypeFilter,
- matchesModelType,
-} from "./lib/model-type-filter";
+import { inventoryRowFormat } from "./catalog/inventory-sort";
+import { matchesInventoryCapabilities } from "./lib/model-type-filter";
import { resolveOwnerProviderLogo } from "./lib/provider-logos";
import { subscribeResidentStatusRefresh } from "./lib/resident-status-refresh";
import {
@@ -266,7 +262,10 @@ function readInventorySortPreference(): InventorySort {
}
try {
const value = window.localStorage.getItem(INVENTORY_SORT_STORAGE_KEY);
- return value === "name" || value === "size" || value === "recent"
+ return value === "name" ||
+ value === "size" ||
+ value === "format" ||
+ value === "recent"
? value
: "recent";
} catch {
@@ -673,8 +672,17 @@ export function ModelsPage() {
setInventorySortState(sort);
writeInventorySortPreference(sort);
}, []);
- const [inventoryTypeFilter, setInventoryTypeFilter] =
- useState<ModelTypeFilter>("all");
+ const [inventoryCapabilities, setInventoryCapabilities] = useState<
+ HubCapabilityFilter[]
+ >([]);
+ const [inventoryFirstPickArmed, setInventoryFirstPickArmed] = useState(true);
+ const handleInventoryCapabilitiesChange = useCallback(
+ (next: HubCapabilityFilter[]) => {
+ setInventoryFirstPickArmed(false);
+ setInventoryCapabilities(next);
+ },
+ [],
+ );
const [foldersDialogOpen, setFoldersDialogOpen] = useState(false);
const [freeUpSpaceOpen, setFreeUpSpaceOpen] = useState(false);
const [discoverFetchIntent, setDiscoverFetchIntent] = useState(0);
@@ -994,7 +1002,10 @@ export function ModelsPage() {
inventoryError,
inventoryWarning,
refreshInventory,
- } = useHubInventory({ kind: isDatasetMode ? "datasets" : "models" });
+ } = useHubInventory({
+ kind: isDatasetMode ? "datasets" : "models",
+ includeUnslothModels: true,
+ });
const reloadReadySent = useRef(false);
useEffect(() => {
@@ -1240,8 +1251,9 @@ export function ModelsPage() {
// Hidden-model filtering is model-only; datasets bypass it (and the format filter) as Discover
// does, so a dataset whose id/title/path contains an infra needle is not dropped.
isDatasetMode ||
- (matchesFormat(row.modelFormat, deferredFormatFilter) &&
- matchesModelType(row, inventoryTypeFilter) &&
+ (deferredFormatFilter !== "unsloth" &&
+ matchesFormat(inventoryRowFormat(row), deferredFormatFilter) &&
+ matchesInventoryCapabilities(row, inventoryCapabilities) &&
isVisibleInventoryRow(row)),
),
inventoryTokens,
@@ -1250,7 +1262,7 @@ export function ModelsPage() {
effectiveCachedRows,
isDatasetMode,
deferredFormatFilter,
- inventoryTypeFilter,
+ inventoryCapabilities,
inventoryTokens,
isVisibleInventoryRow,
],
@@ -1264,8 +1276,10 @@ export function ModelsPage() {
// Hidden-model filtering is model-only; datasets bypass it (and the format filter) as Discover
// does, so a dataset whose id/title/path contains an infra needle is not dropped.
isDatasetMode ||
- (matchesFormat(row.modelFormat, deferredFormatFilter) &&
- matchesModelType(row, inventoryTypeFilter) &&
+ ((deferredFormatFilter === "unsloth"
+ ? row.source === "unsloth"
+ : matchesFormat(inventoryRowFormat(row), deferredFormatFilter)) &&
+ matchesInventoryCapabilities(row, inventoryCapabilities) &&
isVisibleInventoryRow(row)),
),
inventoryTokens,
@@ -1274,7 +1288,7 @@ export function ModelsPage() {
effectiveLocalRows,
isDatasetMode,
deferredFormatFilter,
- inventoryTypeFilter,
+ inventoryCapabilities,
inventoryTokens,
isVisibleInventoryRow,
],
@@ -1310,7 +1324,7 @@ export function ModelsPage() {
// ModelScope drops searchFilters, but the dataset rows are filtered here either way.
minRows,
maxRows,
- inventoryTypeFilter,
+ inventoryCapabilities,
effectiveSort,
effectiveDirection,
activeChannelId,
@@ -1325,7 +1339,7 @@ export function ModelsPage() {
searchFilters,
minRows,
maxRows,
- inventoryTypeFilter,
+ inventoryCapabilities,
effectiveSort,
effectiveDirection,
activeChannelId,
@@ -1344,7 +1358,8 @@ export function ModelsPage() {
}
} else {
setDownloadedFormat("all");
- setInventoryTypeFilter("all");
+ setInventoryCapabilities([]);
+ setInventoryFirstPickArmed(true);
}
setCapabilityFilters([]);
setDatasetModalities([]);
@@ -1352,6 +1367,10 @@ export function ModelsPage() {
setUploaderPick(null);
setFirstPickArmed(true);
}, [isDiscoverTab, urlSection, navigate]);
+ const handleResetInventoryFilters = useCallback(() => {
+ setInventoryCapabilities([]);
+ setInventoryFirstPickArmed(true);
+ }, []);
const handleResetPopoverFilters = useCallback(() => {
setCapabilityFilters([]);
setDatasetModalities([]);
@@ -1828,7 +1847,7 @@ export function ModelsPage() {
const catalogState = useMemo<ModelsCatalogState>(
() => {
const typeFilterActive =
- !isDatasetMode && inventoryTypeFilter !== "all";
+ !isDatasetMode && inventoryCapabilities.length > 0;
return {
tab,
discoverRows: listRows,
@@ -1902,7 +1921,7 @@ export function ModelsPage() {
uploaderPick,
ownerScope,
debouncedQuery,
- inventoryTypeFilter,
+ inventoryCapabilities,
],
);
@@ -2021,28 +2040,12 @@ export function ModelsPage() {
]);
const downloadedHeader = useMemo(() => {
- // Compact pills so they stay beside the view-mode tabs even in the narrow split pane.
- const controls = (
- <div className="flex min-w-0 items-center gap-1.5">
- {!isDatasetMode && (
- <InventoryTypeFilterControl
- value={inventoryTypeFilter}
- onChange={setInventoryTypeFilter}
- />
- )}
- <InventorySortControl
- value={inventorySort}
- onChange={setInventorySort}
- />
- </div>
- );
return (
<HubListHeader
title="On device"
count={filteredCachedRows.length + filteredLocalRows.length}
view={allModelsView}
onViewChange={setAllModelsView}
- actions={controls}
/>
);
}, [
@@ -2050,10 +2053,6 @@ export function ModelsPage() {
filteredLocalRows,
allModelsView,
setAllModelsView,
- inventorySort,
- setInventorySort,
- inventoryTypeFilter,
- isDatasetMode,
]);
// NPU rows have no detail view; one left open would cover their list.
@@ -2113,6 +2112,12 @@ export function ModelsPage() {
onFreeUpSpace={handleFreeUpSpace}
onOpenFineTune={() => handleOpenList("finetune")}
npuAvailable={npuSource !== undefined}
+ inventorySort={inventorySort}
+ onInventorySortChange={setInventorySort}
+ inventoryCapabilities={inventoryCapabilities}
+ onInventoryCapabilitiesChange={handleInventoryCapabilitiesChange}
+ isolateFirstInventoryCapability={inventoryFirstPickArmed}
+ onResetInventoryFilters={handleResetInventoryFilters}
/>
</HubTopBar>
diff --git a/studio/frontend/src/features/hub/inventory/api.ts b/studio/frontend/src/features/hub/inventory/api.ts
index 63078feab06..51ef742da8a 100644
--- a/studio/frontend/src/features/hub/inventory/api.ts
+++ b/studio/frontend/src/features/hub/inventory/api.ts
@@ -273,6 +273,13 @@ export async function listLocalModels(): Promise<LocalModelListResponse> {
return parseJsonOrThrow<LocalModelListResponse>(response);
}
+export async function listUnslothModels(): Promise<LocalModelListResponse> {
+ const response = await withHubTimeout(INVENTORY_TIMEOUT_MS, (signal) =>
+ authFetch("/api/hub/unsloth-models", { signal }),
+ );
+ return parseJsonOrThrow<LocalModelListResponse>(response);
+}
+
export async function fetchCachedGgufInventory(
hfToken?: string | null,
): Promise<CachedInventoryResponse<CachedGgufRepo>> {
diff --git a/studio/frontend/src/features/hub/inventory/constants.ts b/studio/frontend/src/features/hub/inventory/constants.ts
index c9b4fac0172..6c2c61a321a 100644
--- a/studio/frontend/src/features/hub/inventory/constants.ts
+++ b/studio/frontend/src/features/hub/inventory/constants.ts
@@ -9,6 +9,7 @@ export const LOCAL_MODEL_SOURCE = {
OLLAMA: "ollama",
HERMES: "hermes",
CUSTOM: "custom",
+ UNSLOTH: "unsloth",
} as const;
export const LOCAL_MODEL_SOURCES = [
@@ -19,6 +20,7 @@ export const LOCAL_MODEL_SOURCES = [
LOCAL_MODEL_SOURCE.OLLAMA,
LOCAL_MODEL_SOURCE.HERMES,
LOCAL_MODEL_SOURCE.CUSTOM,
+ LOCAL_MODEL_SOURCE.UNSLOTH,
] as const;
export type LocalSource = (typeof LOCAL_MODEL_SOURCES)[number];
diff --git a/studio/frontend/src/features/hub/inventory/types.ts b/studio/frontend/src/features/hub/inventory/types.ts
index 1c95a28e894..c186f87d11e 100644
--- a/studio/frontend/src/features/hub/inventory/types.ts
+++ b/studio/frontend/src/features/hub/inventory/types.ts
@@ -85,6 +85,7 @@ export interface LocalInventoryRow {
modelId?: string | null;
displayName?: string;
path: string;
+ bytes?: number | null;
isGguf: boolean;
modelFormat: ModelInventoryFormat;
artifact: LocalArtifactKind;
diff --git a/studio/frontend/src/features/hub/inventory/use-device-inventory.ts b/studio/frontend/src/features/hub/inventory/use-device-inventory.ts
index 7fc937612e2..236d64b680a 100644
--- a/studio/frontend/src/features/hub/inventory/use-device-inventory.ts
+++ b/studio/frontend/src/features/hub/inventory/use-device-inventory.ts
@@ -12,6 +12,7 @@ import {
listCachedDatasets,
listLocalDatasets,
listLocalModels,
+ listUnslothModels,
} from "./api";
import { useDebouncedValue } from "@/hooks/use-debounced-value";
import { ensureHiddenModelMatchers } from "../lib/hidden-models";
@@ -30,6 +31,7 @@ export type DeviceInventorySource =
| "cachedModels"
| "cachedDatasets"
| "localModels"
+ | "unslothModels"
| "localDatasets";
export type DeviceInventoryRows = {
@@ -37,6 +39,7 @@ export type DeviceInventoryRows = {
cachedModels: CachedModelRepo[];
cachedDatasets: CachedDatasetRepo[];
localModels: LocalModelInfo[];
+ unslothModels: LocalModelInfo[];
localDatasets: LocalDatasetInfo[];
};
@@ -110,6 +113,7 @@ export const useDeviceInventoryStore = create<DeviceInventoryState>(() => ({
cachedModels: emptySource<CachedModelRepo[]>(),
cachedDatasets: emptySource<CachedDatasetRepo[]>(),
localModels: emptySource<LocalModelInfo[]>(),
+ unslothModels: emptySource<LocalModelInfo[]>(),
localDatasets: emptySource<LocalDatasetInfo[]>(),
}));
@@ -140,6 +144,8 @@ function fetchErrorMessage(
return "Couldn't scan cached datasets";
case "localModels":
return "Couldn't scan local models";
+ case "unslothModels":
+ return "Couldn't scan trained and exported models";
case "localDatasets":
return "Couldn't scan local datasets";
default:
@@ -190,6 +196,11 @@ async function runSourceFetch<K extends DeviceInventorySource>(
scanConfirmed: true,
};
}
+ case "unslothModels":
+ return {
+ rows: (await listUnslothModels()).models as DeviceInventoryRows[K],
+ scanConfirmed: true,
+ };
case "localDatasets":
return {
rows: (await listLocalDatasets()).datasets as DeviceInventoryRows[K],
diff --git a/studio/frontend/src/features/hub/inventory/use-hub-inventory.ts b/studio/frontend/src/features/hub/inventory/use-hub-inventory.ts
index dd0873445f5..7e606604f3c 100644
--- a/studio/frontend/src/features/hub/inventory/use-hub-inventory.ts
+++ b/studio/frontend/src/features/hub/inventory/use-hub-inventory.ts
@@ -9,7 +9,7 @@ import {
} from "@/features/hub/download-manager";
import { useHfTokenStore } from "@/features/hub/stores/hf-token-store";
import { useCallback, useEffect, useMemo, useRef } from "react";
-import type { LocalDatasetInfo } from "./api";
+import type { LocalDatasetInfo, LocalModelInfo } from "./api";
import {
activeDownloadRepoKeys,
dedupeSameSourceHubCacheRows,
@@ -75,6 +75,8 @@ type HubInventoryOptions = {
kind?: HubInventoryKind;
enabled?: boolean;
includeLocal?: boolean;
+ /** Also list Studio's own fine-tunes and exports (the Hub's On Device list). */
+ includeUnslothModels?: boolean;
includeUmbrellaFolders?: boolean;
};
@@ -91,6 +93,12 @@ const LOCAL_MODEL_INVENTORY_SOURCE = [
"localModels",
] as const satisfies readonly DeviceInventorySource[];
+const EMPTY_UNSLOTH_ROWS: LocalModelInfo[] = [];
+
+const UNSLOTH_MODEL_INVENTORY_SOURCE = [
+ "unslothModels",
+] as const satisfies readonly DeviceInventorySource[];
+
const LOCAL_DATASET_INVENTORY_SOURCE = [
"localDatasets",
] as const satisfies readonly DeviceInventorySource[];
@@ -313,6 +321,16 @@ export function useHubInventory(
enabled: enabled && !isDatasetMode && includeLocal,
},
);
+ const includeUnslothModels = options.includeUnslothModels ?? false;
+ // Best effort: a failed scan of Studio's outputs never holds back or fails the rest.
+ const unslothModelInventory = useDeviceInventorySources(
+ UNSLOTH_MODEL_INVENTORY_SOURCE,
+ {
+ hfToken,
+ enabled:
+ enabled && !isDatasetMode && includeLocal && includeUnslothModels,
+ },
+ );
const localDatasetInventory = useDeviceInventorySources(
LOCAL_DATASET_INVENTORY_SOURCE,
{
@@ -329,6 +347,15 @@ export function useHubInventory(
const refreshDatasetInventory = datasetInventory.refresh;
const refreshLocalModelInventory = localModelInventory.refresh;
const refreshLocalDatasetInventory = localDatasetInventory.refresh;
+ const refreshUnslothModelInventory = unslothModelInventory.refresh;
+ // Training and export finish elsewhere without bumping the inventory version, so each visit rescans.
+ const unslothModelsEnabled =
+ enabled && !isDatasetMode && includeLocal && includeUnslothModels;
+ useEffect(() => {
+ if (unslothModelsEnabled) {
+ refreshUnslothModelInventory().catch(() => undefined);
+ }
+ }, [unslothModelsEnabled, refreshUnslothModelInventory]);
const refreshModelInventoryIfOlderThan = modelInventory.refreshIfOlderThan;
const refreshDatasetInventoryIfOlderThan =
datasetInventory.refreshIfOlderThan;
@@ -532,9 +559,17 @@ export function useHubInventory(
[cachedDatasets, isDatasetMode, liveDownloadRows],
);
+ const unslothModelRows = includeUnslothModels
+ ? unslothModelInventory.unslothModels.rows
+ : EMPTY_UNSLOTH_ROWS;
const localRows = useMemo(
- () => buildLocalInventoryRows(localModelsSource.rows),
- [localModelsSource.rows],
+ () =>
+ buildLocalInventoryRows(
+ unslothModelRows.length > 0
+ ? [...localModelsSource.rows, ...unslothModelRows]
+ : localModelsSource.rows,
+ ),
+ [localModelsSource.rows, unslothModelRows],
);
const localDatasetRows = useMemo<LocalInventoryRow[]>(() => {
@@ -680,9 +715,14 @@ export function useHubInventory(
await Promise.all([
refreshModelInventory(),
...(includeLocal ? [refreshLocalModelInventory()] : []),
+ ...(includeLocal && includeUnslothModels
+ ? [refreshUnslothModelInventory().catch(() => undefined)]
+ : []),
]);
}, [
includeLocal,
+ includeUnslothModels,
+ refreshUnslothModelInventory,
isDatasetMode,
refreshDatasetInventory,
refreshLocalDatasetInventory,
diff --git a/studio/frontend/src/features/hub/inventory/view-models.ts b/studio/frontend/src/features/hub/inventory/view-models.ts
index ecf0eb58951..d15278ab91c 100644
--- a/studio/frontend/src/features/hub/inventory/view-models.ts
+++ b/studio/frontend/src/features/hub/inventory/view-models.ts
@@ -28,6 +28,8 @@ export function localSourceLabel(source: LocalModelInfo["source"]): string {
return "Hermes";
case "custom":
return "Custom folder";
+ case "unsloth":
+ return "Unsloth";
case "models_dir":
return "Models folder";
case "hf_cache":
@@ -315,6 +317,7 @@ export function buildLocalInventoryRows(
adapterType: model.adapter_type ?? null,
trainingMethod: model.training_method ?? null,
updatedAt: normalizeTimestamp(model.updated_at),
+ bytes: model.size_bytes ?? null,
partial: model.partial ?? false,
partialTransport: model.partial_transport ?? null,
partialResumable: model.partial_resumable === true,
diff --git a/studio/frontend/src/features/hub/lib/format-filters.ts b/studio/frontend/src/features/hub/lib/format-filters.ts
index c566cb0a747..5e3d8315722 100644
--- a/studio/frontend/src/features/hub/lib/format-filters.ts
+++ b/studio/frontend/src/features/hub/lib/format-filters.ts
@@ -17,7 +17,8 @@ export type FormatFilterValue =
| "gguf"
| "checkpoint"
| "mlx"
- | "npu";
+ | "npu"
+ | "unsloth";
export function matchesFormat(
modelFormat: boolean | FormatFilterModelFormat | null | undefined,
@@ -37,6 +38,8 @@ export function matchesFormat(
if (formatFilter === "mlx") return normalized === "mlx";
// NPU models come from Lemonade's catalog, never from a Hub repo or the disk scan.
if (formatFilter === "npu") return false;
+ // Where a model came from, not its format: the On Device list checks the row's source.
+ if (formatFilter === "unsloth") return false;
return normalized === "safetensors" || normalized === "checkpoint";
}
diff --git a/studio/frontend/src/features/hub/lib/model-type-filter.ts b/studio/frontend/src/features/hub/lib/model-type-filter.ts
index 564acbe740c..06d6f70977c 100644
--- a/studio/frontend/src/features/hub/lib/model-type-filter.ts
+++ b/studio/frontend/src/features/hub/lib/model-type-filter.ts
@@ -1,34 +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
-// Type filter for the On Device list. Mirrors the hub Discover capability
-// options and shares its detection, so both dropdowns behave the same.
+// Capability filter for the On Device list. Takes Discover's capability picks and
+// shares its detection, so both filter panels behave the same.
import type {
CachedInventoryRow,
LocalInventoryRow,
} from "@/features/hub/inventory/types";
-import { type CapabilityKey, detectCapabilities } from "./model-capabilities";
-
-export type ModelTypeFilter =
- | "all"
- | "reasoning"
- | "vision"
- | "audio"
- | "embedding"
- | "diffusion";
-
-export const MODEL_TYPE_FILTER_OPTIONS: ReadonlyArray<{
- value: ModelTypeFilter;
- label: string;
-}> = [
- { value: "all", label: "All types" },
- { value: "reasoning", label: "Reasoning" },
- { value: "vision", label: "Vision" },
- { value: "audio", label: "Audio" },
- { value: "embedding", label: "Embeddings" },
- { value: "diffusion", label: "Image/video gen" },
-];
+import {
+ type HubCapabilityFilter,
+ detectCapabilities,
+} from "./model-capabilities";
+import { matchesHubCapability } from "./view-models";
function rowName(row: CachedInventoryRow | LocalInventoryRow): string {
return row.kind === "local"
@@ -36,17 +20,24 @@ function rowName(row: CachedInventoryRow | LocalInventoryRow): string {
: `${row.id} ${row.repoId}`;
}
-export function matchesModelType(
+/** No picks means every capability. */
+export function matchesInventoryCapabilities(
row: CachedInventoryRow | LocalInventoryRow,
- filter: ModelTypeFilter,
+ picks: readonly HubCapabilityFilter[],
): boolean {
- if (filter === "all") return true;
+ if (picks.length === 0) {
+ return true;
+ }
// Honor the row's own vision flag before falling back to tag detection.
- if (filter === "vision" && row.capabilities.supportsVision) return true;
- const caps = detectCapabilities(
- row.tags ?? undefined,
- row.pipelineTag ?? undefined,
- rowName(row),
- );
- return caps.some((cap: { key: CapabilityKey }) => cap.key === filter);
+ if (picks.includes("vision") && row.capabilities.supportsVision) {
+ return true;
+ }
+ const tags = row.tags ?? undefined;
+ const pipelineTag = row.pipelineTag ?? undefined;
+ const id = rowName(row);
+ const view = {
+ capabilities: detectCapabilities(tags, pipelineTag, id),
+ result: { tags, pipelineTag, id },
+ };
+ return picks.some((key) => matchesHubCapability(view, key));
}
diff --git a/studio/frontend/src/features/hub/lib/view-models.ts b/studio/frontend/src/features/hub/lib/view-models.ts
index ee132ae58be..6dcd11216c1 100644
--- a/studio/frontend/src/features/hub/lib/view-models.ts
+++ b/studio/frontend/src/features/hub/lib/view-models.ts
@@ -59,6 +59,7 @@ export const FORMAT_FILTER_OPTIONS: ReadonlyArray<{
{ value: "gguf", label: "GGUF" },
{ value: "checkpoint", label: "Safetensors" },
{ value: "mlx", label: "MLX" },
+ { value: "unsloth", label: "Exports & Fine-tunes" },
];
const BILLION = 1_000_000_000;
diff --git a/studio/frontend/src/features/hub/stores/external-link-confirm.ts b/studio/frontend/src/features/hub/stores/external-link-confirm.ts
index bcd3980362a..6ae18738746 100644
--- a/studio/frontend/src/features/hub/stores/external-link-confirm.ts
+++ b/studio/frontend/src/features/hub/stores/external-link-confirm.ts
@@ -1,6 +1,7 @@
// 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 { openLink } from "@/lib/open-link";
import { create } from "zustand";
interface ExternalLinkConfirmStore {
@@ -15,6 +16,19 @@ export const useExternalLinkConfirm = create<ExternalLinkConfirmStore>((set) =>
dismiss: () => set({ pendingUrl: null }),
}));
+export function isUnslothSiteUrl(url: string): boolean {
+ try {
+ const { protocol, hostname } = new URL(url);
+ const host = hostname.toLowerCase();
+ return (
+ (protocol === "https:" || protocol === "http:") &&
+ (host === "unsloth.ai" || host.endsWith(".unsloth.ai"))
+ );
+ } catch {
+ return false;
+ }
+}
+
export function confirmExternalLink(url: string): boolean {
const trimmed = url?.trim() ?? "";
if (!trimmed || trimmed.startsWith("#")) return false;
@@ -26,6 +40,9 @@ export function confirmExternalLink(url: string): boolean {
) {
return false;
}
+ if (isUnslothSiteUrl(trimmed)) {
+ return openLink(trimmed);
+ }
useExternalLinkConfirm.getState().request(trimmed);
return true;
}
diff --git a/studio/frontend/src/features/hub/types.ts b/studio/frontend/src/features/hub/types.ts
index b1764511128..7b11ecbe9ee 100644
--- a/studio/frontend/src/features/hub/types.ts
+++ b/studio/frontend/src/features/hub/types.ts
@@ -29,7 +29,9 @@ export type ModelFormatFilter =
| "gguf"
| "checkpoint"
| "mlx"
- | "npu";
+ | "npu"
+ /** On Device only: models fine-tuned or exported in Studio. */
+ | "unsloth";
export type CapabilityFilter = "all" | CapabilityKey;
diff --git a/studio/frontend/tests/hub-capability-split.test.ts b/studio/frontend/tests/hub-capability-split.test.ts
index b053ae7e4b5..0089ba179eb 100644
--- a/studio/frontend/tests/hub-capability-split.test.ts
+++ b/studio/frontend/tests/hub-capability-split.test.ts
@@ -81,7 +81,8 @@ test("every capability starts ticked, and the last tick can't be removed", () =>
test("the first pick from the default keeps just that capability", () => {
const popover = readSrc("features/hub/catalog/model-search-filters.tsx");
- assert.match(popover, /capabilities\.length === 0 && isolateFirstCapability\s*\? \[option\.value\]/);
+ assert.match(popover, /capabilities\.length === 0 && isolateFirst\s*\? \[option\.value\]/);
+ assert.match(popover, /isolateFirst=\{isolateFirstCapability\}/);
// Armed once, until the first change from the defaults; the resets arm it again.
const page = readSrc("features/hub/hub-page.tsx");
assert.match(page, /setFirstPickArmed\(false\);\s*setCapabilityFilters\(next\);/);
diff --git a/studio/frontend/tests/hub-external-link-unsloth-site.test.ts b/studio/frontend/tests/hub-external-link-unsloth-site.test.ts
new file mode 100644
index 00000000000..10510a06c06
--- /dev/null
+++ b/studio/frontend/tests/hub-external-link-unsloth-site.test.ts
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// Links to unsloth.ai open without the external-link warning; every other site still asks.
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { readSrc, registerStoreStubResolver } from "./helpers/kit.ts";
+
+registerStoreStubResolver();
+
+const { isUnslothSiteUrl } = await import(
+ "../src/features/hub/stores/external-link-confirm.ts"
+);
+
+test("unsloth.ai and its subdomains are Unsloth's own site", () => {
+ for (const url of [
+ "https://unsloth.ai/docs/models/nemotron-3.5-bolt",
+ "https://docs.unsloth.ai/get-started",
+ "http://UNSLOTH.AI",
+ ]) {
+ assert.equal(isUnslothSiteUrl(url), true, url);
+ }
+});
+
+test("look-alikes and other schemes still get the warning", () => {
+ for (const url of [
+ "https://unsloth.ai.evil.example/docs",
+ "https://evil.example/unsloth.ai",
+ "https://[email protected]/",
+ "https://notunsloth.ai/",
+ "javascript:alert('unsloth.ai')",
+ "mailto:[email protected]",
+ "not a url",
+ ]) {
+ assert.equal(isUnslothSiteUrl(url), false, url);
+ }
+});
+
+test("the trusted path opens through openLink, the rest through the dialog", () => {
+ const store = readSrc("features/hub/stores/external-link-confirm.ts");
+ assert.match(store, /if \(isUnslothSiteUrl\(trimmed\)\) \{\s*return openLink\(trimmed\);\s*\}\s*useExternalLinkConfirm\.getState\(\)\.request\(trimmed\);/);
+});
diff --git a/studio/frontend/tests/hub-on-device-filters.test.ts b/studio/frontend/tests/hub-on-device-filters.test.ts
new file mode 100644
index 00000000000..a01a13a2b41
--- /dev/null
+++ b/studio/frontend/tests/hub-on-device-filters.test.ts
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// On Device takes Discover's filter panel for capabilities, keeps format and sort as
+// dropdowns (with MLX and Studio's own trained and exported models), and icon-only folder and cleanup buttons.
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { readSrc, registerStoreStubResolver } from "./helpers/kit.ts";
+
+registerStoreStubResolver();
+
+const { matchesInventoryCapabilities } = await import(
+ "../src/features/hub/lib/model-type-filter.ts"
+);
+const { matchesFormat } = await import("../src/features/hub/lib/format-filters.ts");
+
+function cachedRow(id: string, pipelineTag: string | null, tags: string[] = []) {
+ return {
+ kind: "cached",
+ id,
+ repoId: id,
+ tags,
+ pipelineTag,
+ capabilities: { supportsVision: false },
+ } as never;
+}
+
+test("no picks keeps every on-device row", () => {
+ assert.equal(matchesInventoryCapabilities(cachedRow("a/b", "text-generation"), []), true);
+});
+
+test("on-device rows match Discover's capability picks", () => {
+ const video = cachedRow("Wan-AI/Wan2.2-T2V-GGUF", "text-to-video", ["diffusers"]);
+ const image = cachedRow("black-forest-labs/FLUX.1-dev-GGUF", "text-to-image", ["diffusers"]);
+ const text = cachedRow("unsloth/Qwen3-8B-GGUF", "text-generation");
+ assert.equal(matchesInventoryCapabilities(video, ["video-gen"]), true);
+ assert.equal(matchesInventoryCapabilities(video, ["image-gen"]), false);
+ assert.equal(matchesInventoryCapabilities(image, ["image-gen"]), true);
+ assert.equal(matchesInventoryCapabilities(text, ["text"]), true);
+ assert.equal(matchesInventoryCapabilities(text, ["image-gen", "video-gen"]), false);
+});
+
+test("a row's own vision flag counts as Vision", () => {
+ const row = {
+ ...(cachedRow("someone/plain", null) as object),
+ capabilities: { supportsVision: true },
+ } as never;
+ assert.equal(matchesInventoryCapabilities(row, ["vision"]), true);
+});
+
+test("Add folder and Free up space are icon buttons with labels", () => {
+ const toolbar = readSrc("features/hub/catalog/models-toolbar.tsx");
+ for (const label of ["Add folder", "Free up space"]) {
+ assert.match(toolbar, new RegExp(`aria-label="${label}"`));
+ assert.doesNotMatch(toolbar, new RegExp(`/>\\s*${label}\\s*</button>`));
+ }
+});
+
+test("On Device keeps format and sort as dropdowns, with MLX and Exports & Fine-tunes", () => {
+ const toolbar = readSrc("features/hub/catalog/models-toolbar.tsx");
+ assert.match(toolbar, /\{!isDataset && \(\s*<HubOptionMenu<FormatMenuValue>/);
+ assert.match(toolbar, /tab === "downloaded" && \(\s*<HubOptionMenu<InventorySort>/);
+ assert.match(toolbar, /option\.value === "unsloth"\s*\? tab === "downloaded"\s*: option\.value !== "recommended" \|\| tab === "discover"/);
+ const panel = readSrc("features/hub/catalog/model-search-filters.tsx");
+ assert.doesNotMatch(panel, /label="Format"|label="Sort by"/);
+ const page = readSrc("features/hub/hub-page.tsx");
+ assert.doesNotMatch(page, /InventorySortControl|InventoryTypeFilterControl/);
+ assert.match(page, /deferredFormatFilter === "unsloth"\s*\? row\.source === "unsloth"/);
+ assert.match(page, /includeUnslothModels: true/);
+});
+
+test("Exports & Fine-tunes is where a model came from, never a file format", () => {
+ assert.equal(matchesFormat("gguf", "unsloth"), false);
+ assert.equal(matchesFormat("safetensors", "unsloth"), false);
+ assert.equal(matchesFormat("mlx", "mlx"), true);
+});
+
+test("Size sorts local folders by their scanned size, and Format follows the format dropdown", async () => {
+ const { inventoryItemFormatRank, inventoryItemSize } = await import(
+ "../src/features/hub/catalog/inventory-sort.ts"
+ );
+ const local = (modelFormat: string, extra: object = {}) =>
+ ({ variant: "local", row: { modelFormat, source: "custom", ...extra } }) as never;
+ assert.equal(inventoryItemSize(local("gguf", { bytes: 5_000 })), 5_000);
+ assert.equal(inventoryItemSize(local("gguf")), 0);
+ const ranks = [
+ local("adapter"),
+ local("safetensors", { libraryName: "mlx" }),
+ local("safetensors"),
+ local("gguf"),
+ ].map(inventoryItemFormatRank);
+ assert.deepEqual(ranks, [3, 2, 1, 0]);
+ const toolbar = readSrc("features/hub/catalog/models-toolbar.tsx");
+ assert.match(toolbar, /\{ value: "format", label: "Format" \}/);
+ const view = readSrc("features/hub/inventory/view-models.ts");
+ assert.match(view, /bytes: model\.size_bytes \?\? null/);
+});
+
+test("the MLX format finds MLX folders, which the scan reports as safetensors", async () => {
+ const { inventoryRowFormat } = await import(
+ "../src/features/hub/catalog/inventory-sort.ts"
+ );
+ const row = (extra: object) =>
+ ({ kind: "local", modelFormat: "safetensors", source: "custom", ...extra }) as never;
+ const mlxByLibrary = row({ libraryName: "MLX" });
+ const mlxByTag = row({ tags: ["mlx"] });
+ const omlx = row({ source: "omlx" });
+ const plain = row({});
+ for (const mlx of [mlxByLibrary, mlxByTag, omlx]) {
+ assert.equal(matchesFormat(inventoryRowFormat(mlx), "mlx"), true);
+ assert.equal(matchesFormat(inventoryRowFormat(mlx), "checkpoint"), false);
+ }
+ assert.equal(matchesFormat(inventoryRowFormat(plain), "mlx"), false);
+ assert.equal(matchesFormat(inventoryRowFormat(plain), "checkpoint"), true);
+ const page = readSrc("features/hub/hub-page.tsx");
+ assert.doesNotMatch(page, /matchesFormat\(row\.modelFormat, deferredFormatFilter\)/);
+});
+
+test("each Hub visit rescans Studio's trained and exported models", () => {
+ const inventory = readSrc("features/hub/inventory/use-hub-inventory.ts");
+ assert.match(inventory, /if \(unslothModelsEnabled\) \{\s*refreshUnslothModelInventory\(\)/);
+});