diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogDiscoverModels.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogDiscoverModels.svelte
deleted file mode 100644
index a1eeb46a449f..000000000000
--- a/ui/apps/chat/src/lib/components/app/dialogs/DialogDiscoverModels.svelte
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
- event.preventDefault()}
- >
-
-
-
-
- Discover
-
-
-
- Find models on Hugging Face and download them to the server.
-
-
-
-
-
-
-
-
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
index d7a531dce1d3..17b8b3606986 100644
--- a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
+++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
@@ -3,16 +3,26 @@
import { ArrowDown, ArrowUp, CornerDownLeft, MessageSquare, Pin, X } from '@lucide/svelte';
import { ActionIcon, KeyboardShortcutInfo } from '#lib/components/app/index.ts';
import {
+ DISCOVER_ICON,
ICON_CLASS_DEFAULT,
ICON_CLASS_SM,
ICON_CLASS_XS,
+ MODELS_DISCOVER_SEARCH_DEBOUNCE_MS,
PROJECT_ICON,
SIDEBAR_ACTIONS_ITEMS
} from '#lib/constants/index.ts';
import { KeyboardKey, SidebarAction } from '#lib/enums/index.ts';
import { extensions, type NavigationItem } from '#lib/extensions/index.ts';
+ import { HuggingFaceService } from '#lib/services/index.ts';
import { RouterService } from '#lib/services/router.service.ts';
- import { conversationsStore, deviceStore, projectsStore, uiStore } from '#lib/stores/index.ts';
+ import {
+ conversationsStore,
+ deviceStore,
+ modelsDiscoverStore,
+ projectsStore,
+ uiStore
+ } from '#lib/stores/index.ts';
+ import type { HfModelInfo } from '#lib/types/huggingface.js';
import { formatRelativeTime, isIMEComposing, sidebarFooterItems } from '#lib/utils/index.ts';
import { goto } from '$app/navigation';
import type { Component } from 'svelte';
@@ -39,6 +49,8 @@
interface SearchSection {
entries: SearchEntry[];
+ /** Shown in place of the entries a section is still waiting for, or failed to get. */
+ note?: string;
title: string;
}
@@ -46,6 +58,8 @@
const RECENT_LIMIT = 5;
/** Matches kept while typing; the rest stays reachable by typing more. */
const MATCH_LIMIT = 50;
+ /** Hub models listed; the models page shows the whole search. */
+ const HUB_LIMIT = 6;
let query = $state('');
let highlighted = $state(0);
@@ -118,12 +132,63 @@
.filter((entry) => matches(entry.label))
);
+ // Hub models answer the typed term wherever the models page searches the Hub
+ const searchesHub = $derived(open && uiStore.isDiscoverEnabled && needle.length > 0);
+
+ let hubModels = $state([]);
+ let hubNote = $state();
+
+ $effect(() => {
+ hubModels = [];
+ hubNote = undefined;
+
+ if (!searchesHub) return;
+
+ const term = needle;
+
+ let cancelled = false;
+
+ hubNote = 'Searching Hugging Face...';
+
+ // the same debounce the models page waits for after the last keystroke
+ const timer = setTimeout(async () => {
+ try {
+ // the models page's own search, so the first matches here lead its list too
+ const models = await modelsDiscoverStore.searchHub(term);
+
+ if (cancelled) return;
+
+ hubModels = models.slice(0, HUB_LIMIT);
+ hubNote = undefined;
+ } catch {
+ if (!cancelled) hubNote = 'Could not search Hugging Face';
+ }
+ }, MODELS_DISCOVER_SEARCH_DEBOUNCE_MS);
+
+ return () => {
+ cancelled = true;
+ clearTimeout(timer);
+ };
+ });
+
+ const hubEntries = $derived.by((): SearchEntry[] =>
+ hubModels.map((model) => ({
+ icon: DISCOVER_ICON,
+ id: `hub-${model.id}`,
+ label: model.id,
+ meta: `${HuggingFaceService.formatDownloads(model.downloads)} downloads`,
+ run: () => close(() => openHubModel(model.id))
+ }))
+ );
+
+ // last, so matches arriving from the Hub never move the rows above them
const sections = $derived(
[
{ entries: chatEntries, title: needle ? 'Chats' : 'Recents' },
{ entries: projectEntries, title: 'Projects' },
- { entries: actionEntries, title: 'Actions' }
- ].filter((section) => section.entries.length > 0)
+ { entries: actionEntries, title: 'Actions' },
+ { entries: hubEntries, note: hubNote, title: 'Models on Hugging Face' }
+ ].filter((section) => section.entries.length > 0 || section.note)
);
const entries = $derived(sections.flatMap((section) => section.entries));
@@ -131,6 +196,16 @@
const emptyMessage = $derived(needle ? 'No results found' : 'No chats yet');
+ /**
+ * Shows a Hub model's details over the models page; a phone, which has no models
+ * page in its navigation, opens them over the page it is on.
+ */
+ function openHubModel(repo: string) {
+ if (!deviceStore.isMobile) uiStore.openModelsManager();
+
+ uiStore.openHubModelDetails(repo);
+ }
+
/** Closes the search first, so a dialog opened by `next` takes the focus. */
function close(next: () => void) {
handleOpenChange(false);
@@ -270,6 +345,10 @@
: 'opacity-0'}"
/>
+ {:else}
+
+ {section.note}
+
{/each}
{:else}
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/index.ts b/ui/apps/chat/src/lib/components/app/dialogs/index.ts
index 6d6ad0d2ab56..b7c75e30a8f9 100644
--- a/ui/apps/chat/src/lib/components/app/dialogs/index.ts
+++ b/ui/apps/chat/src/lib/components/app/dialogs/index.ts
@@ -93,11 +93,11 @@ export { default as DialogExportSettings } from './DialogExportSettings.svelte';
export { default as DialogConfirmation } from './DialogConfirmation.svelte';
/**
- * **DialogSearch** - Spotlight-style search over chats and sidebar actions
+ * **DialogSearch** - Spotlight-style search over chats, projects, sidebar actions and Hub models
*
* Opens over the app with a focused input and a keyboard-driven result list:
- * arrow keys move the highlight, Enter opens, Escape closes. A phone shows it full screen, like
- * every dialog.
+ * arrow keys move the highlight, Enter opens, Escape closes. With Discover on, the typed
+ * term also searches Hugging Face. A phone shows it full screen, like every dialog.
*/
export { default as DialogSearch } from './DialogSearch.svelte';
@@ -479,6 +479,3 @@ export { default as DialogConversationSelection } from './DialogConversationSele
* ```
*/
export { default as DialogMermaidPreview } from './DialogMermaidPreview.svelte';
-
-/** **DialogDiscoverModels** - shell for the Hugging Face model discovery view. */
-export { default as DialogDiscoverModels } from './DialogDiscoverModels.svelte';
diff --git a/ui/apps/chat/src/lib/components/app/models/ModelCapabilities.svelte b/ui/apps/chat/src/lib/components/app/models/ModelCapabilities.svelte
index cc978351d6e2..774fc14622fc 100644
--- a/ui/apps/chat/src/lib/components/app/models/ModelCapabilities.svelte
+++ b/ui/apps/chat/src/lib/components/app/models/ModelCapabilities.svelte
@@ -13,13 +13,15 @@
} from '#lib/utils/index.ts';
interface Props {
+ /** Name every capability in an outline badge instead of a bare icon. */
+ asBadges?: boolean;
class?: string;
/** Hide the modality icons, keeping the capability ones. */
hideModalities?: boolean;
option: ModelOption;
}
- let { class: className = '', hideModalities = false, option }: Props = $props();
+ let { asBadges = false, class: className = '', hideModalities = false, option }: Props = $props();
// a listing that declares its capabilities (Ollama-compatible servers) needs no lookup
let declared = $derived(option.capabilities);
@@ -61,6 +63,7 @@
(isNearViewport = true))} class={className}>
+ import * as Card from '@ggml-org/llama-ui/ui/card';
+ import type { Snippet } from 'svelte';
+
+ interface Props {
+ /** Avatar at the card's top left. */
+ avatar: Snippet;
+ /** The model's name and badges, beside the avatar; the card's one button. */
+ title: Snippet;
+ /** Controls at the top right, e.g. an actions menu. */
+ actions?: Snippet;
+ /** Body between the header and the footer: capabilities, a description. */
+ children?: Snippet;
+ class?: string;
+ /** Faded, e.g. a hidden model. */
+ dimmed?: boolean;
+ /** Muted facts at the bottom left. */
+ footer?: Snippet;
+ /** Bottom right of the footer, e.g. a load control. */
+ footerEnd?: Snippet;
+ onSelect: () => void;
+ /** Laid over the card's edge, e.g. a download progress bar. */
+ overlay?: Snippet;
+ /** `aria-pressed` of the card's button; undefined leaves it a plain button. */
+ pressed?: boolean;
+ selected?: boolean;
+ /** Native title of the card's button, e.g. the full model id. */
+ tooltip?: string;
+ }
+
+ let {
+ actions,
+ avatar,
+ children,
+ class: className = '',
+ dimmed = false,
+ footer,
+ footerEnd,
+ onSelect,
+ overlay,
+ pressed,
+ selected = false,
+ title,
+ tooltip
+ }: Props = $props();
+
+
+
+
+
+ import ModelsDiscoverDetailsContainer from './ModelsDiscoverDetailsContainer.svelte';
+ import * as Drawer from '@ggml-org/llama-ui/ui/drawer';
+ import { X } from '@lucide/svelte';
+ import { ActionIcon } from '#lib/components/app/index.ts';
+ import { DISCOVER_ICON } from '#lib/constants/index.ts';
+ import { deviceStore, uiStore } from '#lib/stores/index.ts';
+ import { untrack } from 'svelte';
+
+ let focus = $derived(uiStore.hubModelFocus);
+ // keep the last repo on screen while the drawer closes
+ let shownId = $state(null);
+
+ $effect(() => {
+ const repo = focus;
+
+ if (!repo) return;
+
+ untrack(() => (shownId = repo));
+ });
+
+ // the setting can be turned off while the drawer is open: it closes with it
+ $effect(() => {
+ if (focus && !uiStore.isDiscoverEnabled) untrack(() => uiStore.closeHubModelDetails());
+ });
+
+
+
+ focus !== null,
+ (open) => {
+ if (!open) uiStore.closeHubModelDetails();
+ }
+ }
+ direction={deviceStore.isMobile ? 'bottom' : 'right'}
+ shouldScaleBackground={false}
+>
+
+
+
+
+ Hugging Face
+
+
+ Details of a Hugging Face model and the files it can be downloaded as.
+
+
+ uiStore.closeHubModelDetails()}
+ tooltip="Close"
+ tooltipAsTitle
+ />
+
diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/index.ts b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/index.ts
index 91d5c89065d6..507fb4d81461 100644
--- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/index.ts
+++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/index.ts
@@ -10,9 +10,12 @@
/** Detail pane of the selected model; fetches its own details and GGUF file list. */
export { default as ModelsDiscoverDetails } from './ModelsDiscoverDetails.svelte';
-/** Fetches one repo's details, files and readme for hosts outside Discover. */
+/** Fetches one repo's details, files and readme, then renders the detail pane. */
export { default as ModelsDiscoverDetailsContainer } from './ModelsDiscoverDetailsContainer.svelte';
+/** Detail pane in a drawer, mounted once and opened through `uiStore.openHubModelDetails`. */
+export { default as ModelsDiscoverDetailsDrawer } from './ModelsDiscoverDetailsDrawer.svelte';
+
/** Header of the detail pane. */
export { default as ModelsDiscoverDetailsHeader } from './ModelsDiscoverDetailsHeader.svelte';
diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverList/ModelsDiscoverListItem.svelte b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverList/ModelsDiscoverListItem.svelte
index b33ca55f0b9b..1d8c49034171 100644
--- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverList/ModelsDiscoverListItem.svelte
+++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverList/ModelsDiscoverListItem.svelte
@@ -1,160 +1,23 @@
diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverList/index.ts b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverList/index.ts
index c3025c0b2601..6eb6482fa8f5 100644
--- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverList/index.ts
+++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverList/index.ts
@@ -2,15 +2,14 @@
*
* MODELS DISCOVER - LIST
*
- * The discover sidebar column: a debounced search field above a navigable list of
- * HuggingFace GGUF models, with skeleton rows while loading.
+ * Lists of HuggingFace GGUF models: the Hub search results on the models page, with
+ * skeleton rows while loading.
*
*/
export { default as ModelsDiscoverList } from './ModelsDiscoverList.svelte';
-export { default as ModelsDiscoverListSearch } from './ModelsDiscoverListSearch.svelte';
-/** One model entry; also the row of a tracked download, with its own controls. */
+/** One model entry. */
export { default as ModelsDiscoverListItem } from './ModelsDiscoverListItem.svelte';
export { default as ModelsDiscoverListItemSkeleton } from './ModelsDiscoverListItemSkeleton.svelte';
diff --git a/ui/apps/chat/src/lib/components/app/models/discover/index.ts b/ui/apps/chat/src/lib/components/app/models/discover/index.ts
index bb353c72dfa8..4a113bf4cc60 100644
--- a/ui/apps/chat/src/lib/components/app/models/discover/index.ts
+++ b/ui/apps/chat/src/lib/components/app/models/discover/index.ts
@@ -2,15 +2,17 @@
*
* MODELS DISCOVER
*
- * Components for the Models Discover view: a sidebar search + list of HuggingFace GGUF
- * models and a detail view for the selected model, used as the body of the discovery
- * dialog. The list and detail trees live in their own subfolders; this barrel re-exports
- * them alongside the shared leaves.
+ * Components for browsing HuggingFace GGUF models on the models page: the suggested
+ * models carousel, the Hub search results and the details drawer a repo opens in. The
+ * list and detail trees live in their own subfolders; this barrel re-exports them.
*
*/
-/** The whole view: sidebar list on the left, detail pane on the right. */
-export { default as ModelsDiscover } from './ModelsDiscover.svelte';
+/** Suggested catalog models, a horizontal row of cards above the installed models. */
+export { default as ModelsDiscoverCarousel } from './ModelsDiscoverCarousel.svelte';
+
+/** One Hub repo as a card: the carousel's, and the grid view's search results. */
+export { default as ModelsDiscoverCard } from './ModelsDiscoverCard.svelte';
export * from './ModelsDiscoverList';
export * from './ModelsDiscoverDetails';
diff --git a/ui/apps/chat/src/lib/components/app/models/index.ts b/ui/apps/chat/src/lib/components/app/models/index.ts
index 19f043b6b1b5..3d2cfc5ab79f 100644
--- a/ui/apps/chat/src/lib/components/app/models/index.ts
+++ b/ui/apps/chat/src/lib/components/app/models/index.ts
@@ -54,6 +54,10 @@ export { default as ModelOrgAvatar } from './ModelOrgAvatar.svelte';
export { default as ModelRowActions } from './ModelRowActions.svelte';
export { default as ModelsSection } from './ModelsSection.svelte';
+/** Card surface of a model, local or on the Hub, styled like the MCP server cards. */
+export { default as ModelCard } from './ModelCard.svelte';
+export { default as ModelCardSkeleton } from './ModelCardSkeleton.svelte';
+
/** Capability and modality icon row, shared by every model-id surface. */
export { ModelCapabilityIcons } from '@ggml-org/llama-ui/models';
diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
index c49b09ed5f9f..57af8de0a107 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
@@ -4,7 +4,6 @@
ActionIcon,
DialogConversationDelete,
DialogConversationRename,
- DialogDiscoverModels,
DialogGroup,
DialogGroupPicker,
DialogProject,
@@ -18,6 +17,7 @@
SidebarNavigationConversationList,
SidebarNavigationFooter
} from '#lib/components/app/index.ts';
+ import { ModelsDiscoverDetailsDrawer } from '#lib/components/app/models/discover/index.ts';
import {
ROUTES,
SIDEBAR_ACTIONS_ITEMS,
@@ -802,7 +802,7 @@
{/if}
{/each}
-
+
diff --git a/ui/apps/chat/src/lib/constants/css-classes.constants.ts b/ui/apps/chat/src/lib/constants/css-classes.constants.ts
index aade305d2ab1..2346736715a9 100644
--- a/ui/apps/chat/src/lib/constants/css-classes.constants.ts
+++ b/ui/apps/chat/src/lib/constants/css-classes.constants.ts
@@ -58,6 +58,12 @@ export const SELECTOR_GROUP_STICKY_OFFSET =
/** Column grid shared by every row of the models manager table. Below md the context,
* status and actions columns are dropped, so a phone gives the whole width to the
* model id and floats the row's last cell at the row's end. */
+/** Responsive grid of model cards; the minimum matches a carousel card's width. */
+export const MODEL_CARD_GRID_CLASS = 'grid grid-cols-[repeat(auto-fill,minmax(18rem,1fr))] gap-3';
+
+/** Width of a model card in a horizontal carousel. */
+export const MODEL_CARD_CAROUSEL_CLASS = 'w-72 shrink-0 snap-start';
+
export const MODEL_ROW_GRID_CLASS =
'grid grid-cols-[minmax(0,1fr)] items-center gap-3 md:grid-cols-[minmax(0,1fr)_11rem_3rem_4.5rem] md:gap-4';
diff --git a/ui/apps/chat/src/lib/constants/models-discover.constants.ts b/ui/apps/chat/src/lib/constants/models-discover.constants.ts
index b0a0abc568d7..12f61352f231 100644
--- a/ui/apps/chat/src/lib/constants/models-discover.constants.ts
+++ b/ui/apps/chat/src/lib/constants/models-discover.constants.ts
@@ -1,7 +1,7 @@
/**
* Models discover constants.
*
- * Endpoints and settings for the Models Discover dialog.
+ * Endpoints and settings for browsing Hugging Face models on the models page.
*/
/** llama.app model catalog used as the default model list. Online-only source; the discover feature requires an internet connection anyway. */
@@ -12,3 +12,9 @@ export const MODELS_DISCOVER_CATALOG_URL = 'https://llama.app/v1/catalog.json';
* is not hit with the whole catalog at once.
*/
export const MODELS_DISCOVER_CATALOG_BATCH = 4;
+
+/** Quiet time after the last keystroke before a search field searches the Hub. */
+export const MODELS_DISCOVER_SEARCH_DEBOUNCE_MS = 300;
+
+/** Matches one Hub search asks for. */
+export const MODELS_DISCOVER_SEARCH_LIMIT = 50;
diff --git a/ui/apps/chat/src/lib/constants/settings.constants.ts b/ui/apps/chat/src/lib/constants/settings.constants.ts
index ebd784129840..9977e1de9bd8 100644
--- a/ui/apps/chat/src/lib/constants/settings.constants.ts
+++ b/ui/apps/chat/src/lib/constants/settings.constants.ts
@@ -166,7 +166,7 @@ export const SETTINGS_REGISTRY: SettingsSectionEntry[] = [
},
{
defaultValue: false,
- help: 'Show Discover Models on the Models page, to browse and download HuggingFace GGUF models. Turns Models and the Hugging Face Hub API on while it is enabled. Only available in router mode.',
+ help: 'Show suggested models and Hugging Face search results on the models page, to browse and download HuggingFace GGUF models. Turns Models and the Hugging Face Hub API on while it is enabled. Only available in router mode.',
key: SETTINGS_KEYS.ENABLE_DISCOVER_MODELS,
label: 'Enable Discover Models',
type: SettingsFieldType.CHECKBOX
diff --git a/ui/apps/chat/src/lib/constants/storage.constants.ts b/ui/apps/chat/src/lib/constants/storage.constants.ts
index 31cd6d0b9f04..093eb6389b6e 100644
--- a/ui/apps/chat/src/lib/constants/storage.constants.ts
+++ b/ui/apps/chat/src/lib/constants/storage.constants.ts
@@ -56,6 +56,7 @@ export const REASONING_EFFORT_DEFAULT_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.re
export const SIDEBAR_SECTION_ORDER_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.sidebarSectionOrder`;
export const SIDEBAR_COLLAPSED_SECTIONS_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.sidebarCollapsedSections`;
export const CONVERSATION_TABS_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.conversationTabs`;
+export const MODELS_VIEW_MODE_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.modelsViewMode`;
export const SIDEBAR_EXPANDED_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.sidebarExpanded`;
export const SIDEBAR_WIDTH_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.sidebarWidth`;
export const USER_OVERRIDES_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.userOverrides`;
diff --git a/ui/apps/chat/src/lib/enums/index.ts b/ui/apps/chat/src/lib/enums/index.ts
index baba49379eb0..86f6d957cdc3 100644
--- a/ui/apps/chat/src/lib/enums/index.ts
+++ b/ui/apps/chat/src/lib/enums/index.ts
@@ -87,7 +87,8 @@ export {
ModelRowDownloadState,
ModelsTableGroupKind,
ModelsTableServerKind,
- ModelsTableSortKey
+ ModelsTableSortKey,
+ ModelsViewMode
} from './model.enums';
export {
diff --git a/ui/apps/chat/src/lib/enums/model.enums.ts b/ui/apps/chat/src/lib/enums/model.enums.ts
index faceb6e5fe72..33beb908837f 100644
--- a/ui/apps/chat/src/lib/enums/model.enums.ts
+++ b/ui/apps/chat/src/lib/enums/model.enums.ts
@@ -74,3 +74,9 @@ export enum ModelsTableServerKind {
COMPAT = 'compat',
SERVER = 'server'
}
+
+/** How the models manager lays out the installed models. */
+export enum ModelsViewMode {
+ GRID = 'grid',
+ TABLE = 'table'
+}
diff --git a/ui/apps/chat/src/lib/hooks/use-hub-model-summary.svelte.ts b/ui/apps/chat/src/lib/hooks/use-hub-model-summary.svelte.ts
new file mode 100644
index 000000000000..14903f2c3de3
--- /dev/null
+++ b/ui/apps/chat/src/lib/hooks/use-hub-model-summary.svelte.ts
@@ -0,0 +1,140 @@
+import { HF_MMPROJ_FILENAME_TOKEN, MODEL_ID } from '#lib/constants/index.ts';
+import { ModelDraftSidecar } from '#lib/enums/index.ts';
+import { HuggingFaceService } from '#lib/services/index.ts';
+import { modelsDiscoverStore } from '#lib/stores/index.ts';
+import type { ModelsDiscoverSizeRange } from '#lib/stores/models-discover/index.svelte.ts';
+import type { HfModelInfo, HfModelSiblingRef } from '#lib/types/huggingface.js';
+import type { ModelModalities } from '#lib/types/models.js';
+import {
+ detectThinkingSupport,
+ detectToolUseSupport,
+ directoryOf,
+ isDraftSidecar,
+ isServerSidecarFile,
+ orgOf
+} from '#lib/utils/index.ts';
+import { SvelteSet } from 'svelte/reactivity';
+
+/**
+ * True when a file of the weights sits in the draft's directory: the server
+ * resolves a sidecar against the model file beside it, never across directories.
+ */
+function hasWeightsBeside(siblings: HfModelSiblingRef[], draftPath: string): boolean {
+ const directory = directoryOf(draftPath);
+
+ return siblings.some(
+ (sibling) =>
+ MODEL_ID.WEIGHT_EXTENSION_REGEX.test(sibling.rfilename) &&
+ directoryOf(sibling.rfilename) === directory &&
+ !HuggingFaceService.extractQuantMeta(sibling.rfilename)?.sidecar
+ );
+}
+
+/**
+ * What a Hub row or card shows of one repo record: avatar orgs, context, capabilities,
+ * modalities, draft kinds and size range. Shared so every Hub surface reads a record
+ * the same way; a repo the catalog did not measure is measured once here.
+ */
+export function useHubModelSummary(
+ getModel: () => HfModelInfo,
+ /** Show the original (base) model's org avatar instead of the repo's org. */
+ getShowBaseModelAvatar: () => boolean = () => false
+) {
+ const org = $derived(orgOf(getModel().id));
+ // the base model's org when asked (e.g. the Qwen logo for ggml-org/Qwen3.8-27B-GGUF),
+ // else the repo's org
+ const avatarOrg = $derived.by(() => {
+ if (!getShowBaseModelAvatar()) return org;
+
+ return orgOf(HuggingFaceService.getBaseModels(getModel())[0]) || org;
+ });
+ const contextLength = $derived(getModel().gguf?.context_length);
+ // Reasoning support from the chat template, matching the details view.
+ const supportsThinking = $derived(detectThinkingSupport(getModel().gguf?.chat_template ?? ''));
+ const supportsToolUse = $derived(detectToolUseSupport(getModel().gguf?.chat_template ?? ''));
+ const mmprojPath = $derived(
+ getModel().siblings?.find((s) => s.rfilename.toLowerCase().includes(HF_MMPROJ_FILENAME_TOKEN))
+ ?.rfilename
+ );
+ // Modalities derived from HF metadata: the pipeline tag and the mmproj.
+ const modalities = $derived(
+ HuggingFaceService.getModalities(getModel().id, getModel().pipeline_tag, mmprojPath)
+ );
+
+ // the mmproj's header says whether it also hears; read once per repo
+ $effect(() => {
+ if (mmprojPath) void HuggingFaceService.getMmprojEncoders(getModel().id, mmprojPath);
+ });
+ // Draft sidecars (mtp, dflash, dspark, eagle3) the repo offers, badged with no
+ // quant: the list does not know how the server configures them. Only the drafts
+ // the server can actually pull are shown, so a badge never outlives the file
+ // find_best_sibling would resolve.
+ const draftKinds = $derived.by(() => {
+ const siblings = getModel().siblings ?? [];
+ const kinds = new SvelteSet();
+
+ for (const sibling of siblings) {
+ const sidecar = HuggingFaceService.extractQuantMeta(sibling.rfilename)?.sidecar;
+
+ if (!sidecar || !isDraftSidecar(sidecar)) continue;
+
+ if (!isServerSidecarFile(sibling.rfilename, sidecar)) continue;
+
+ if (!hasWeightsBeside(siblings, sibling.rfilename)) continue;
+
+ kinds.add(sidecar);
+ }
+
+ return Object.values(ModelDraftSidecar).filter((kind) => kinds.has(kind));
+ });
+
+ // Min/max size across the repo's quants, draft sidecars included. The store
+ // has catalog repos covered already; any other one (a search hit) is measured
+ // once and the result is cached per repo.
+ let measuredSize = $state(null);
+
+ const sizeRange = $derived(modelsDiscoverStore.cachedSizeRangeFor(getModel().id) ?? measuredSize);
+
+ $effect(() => {
+ const id = getModel().id;
+
+ if (modelsDiscoverStore.cachedSizeRangeFor(id)) return;
+
+ let cancelled = false;
+
+ void modelsDiscoverStore.sizeRange(id).then((range) => {
+ if (!cancelled) measuredSize = range ?? null;
+ });
+
+ return () => {
+ cancelled = true;
+ };
+ });
+
+ return {
+ get avatarOrg() {
+ return avatarOrg;
+ },
+ get contextLength() {
+ return contextLength;
+ },
+ get draftKinds() {
+ return draftKinds;
+ },
+ get modalities() {
+ return modalities;
+ },
+ get org() {
+ return org;
+ },
+ get sizeRange() {
+ return sizeRange;
+ },
+ get supportsThinking() {
+ return supportsThinking;
+ },
+ get supportsToolUse() {
+ return supportsToolUse;
+ }
+ };
+}
diff --git a/ui/apps/chat/src/lib/stores/models-discover/index.svelte.ts b/ui/apps/chat/src/lib/stores/models-discover/index.svelte.ts
index c7acb104c2b9..92bf27c28090 100644
--- a/ui/apps/chat/src/lib/stores/models-discover/index.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/models-discover/index.svelte.ts
@@ -1,12 +1,16 @@
/**
* modelsDiscoverStore - Models Discover browse state
*
- * Owns the HuggingFace GGUF list shown in the discover sidebar. The default list is
- * the curated catalog set; a search replaces it with matches across all of HuggingFace.
- * Both paths fetch the same fields, so a row renders the same either way.
+ * Owns the HuggingFace GGUF lists shown on the models page: the curated catalog set the
+ * suggestions carousel shows, and the matches a search finds across all of HuggingFace.
+ * The two are kept apart so a search never hides the suggestions. Both paths fetch the
+ * same fields, so a card or row renders the same either way.
*/
-import { MODELS_DISCOVER_CATALOG_BATCH } from '#lib/constants/index.ts';
+import {
+ MODELS_DISCOVER_CATALOG_BATCH,
+ MODELS_DISCOVER_SEARCH_LIMIT
+} from '#lib/constants/index.ts';
import { HuggingFaceService } from '#lib/services/index.ts';
import type {
HfCatalogBuild,
@@ -24,19 +28,24 @@ export interface ModelsDiscoverSizeRange {
}
class ModelsDiscoverStore {
+ /** Error of the catalog fetch. */
error = $state(null);
- models = $state([]);
- /** First model in the list - discover auto-opens this one. */
- firstModel = $derived(this.models[0] ?? null);
-
loading = $state(false);
+ /** Trimmed query the search results answer; empty while no search runs. */
+ query = $state('');
+ /** Error of the newest search. */
+ searchError = $state(null);
/** True while a search is in flight; only the newest request owns this flag. */
searching = $state(false);
+ /** Matches of the newest search. */
+ searchResults = $state([]);
+ /** Curated catalog repos, filled batch by batch as they land. */
+ suggested = $state([]);
+
private catalog: HfCatalogEntry[] = [];
/** Repo id -> size range, for catalog rows and lazily measured search rows. */
private catalogSizeRanges = new SvelteMap();
- private defaultModels: HfModelInfo[] = [];
private fetched = false;
private searchRequestId = 0;
/** In-flight `sizeRange()` lookups, keyed by repo id. */
@@ -50,15 +59,16 @@ class ModelsDiscoverStore {
return this.catalogSizeRanges.get(modelId);
}
- /** Catalog family description; undefined for a repo outside the curated catalog. */
+ /**
+ * Catalog family description, emphasis markers dropped since every surface renders it
+ * as plain text; undefined for a repo outside the curated catalog.
+ */
descriptionFor(modelId: string): string | undefined {
- return this.catalog.find((entry) =>
- entry.sizes.some((size) => size.builds.some((build) => build.repo === modelId))
- )?.description;
+ return this.catalogEntryFor(modelId)?.description?.replace(/(\*\*|__)(.+?)\1/g, '$2');
}
/**
- * Fill the list from the llama.app catalog, one repo per catalog size. Every repo
+ * Fill the suggestions from the llama.app catalog, one repo per catalog size. Every repo
* is fetched with its file tree, so a catalog row carries the same data a search
* result does. No-op when already loaded or in flight.
*/
@@ -75,8 +85,7 @@ class ModelsDiscoverStore {
const builds = this.catalogBuilds();
const failedBuilds: HfCatalogBuild[] = [];
-
- this.defaultModels = [];
+ const suggested: HfModelInfo[] = [];
// fetch in small batches: not every repo hits the HF API at once,
// and the rows land as they arrive instead of all at the end
@@ -102,13 +111,11 @@ class ModelsDiscoverStore {
this.catalogSizeRanges.set(build.repo, this.sizeRangeFor(build, tree));
// the catalog repo id, not the HF response `id`, drives selection
- this.defaultModels.push({ ...info, id: build.repo, modelId: build.repo });
+ suggested.push({ ...info, id: build.repo, modelId: build.repo });
}
- // show what has landed, unless a search owns the list right now
- if (!this.searching) {
- this.models = [...this.defaultModels];
- }
+ // show what has landed
+ this.suggested = [...suggested];
}
// stay incomplete when some repos failed, so the next mount retries
@@ -121,15 +128,30 @@ class ModelsDiscoverStore {
}
}
- /** Replace the list with search results; an empty query restores the default list. */
+ /** Release month of a catalog family, e.g. `Aug 2025`; undefined outside the catalog. */
+ releasedFor(modelId: string): string | undefined {
+ const [year, month] = (this.catalogEntryFor(modelId)?.released ?? '').split('-').map(Number);
+
+ if (!year || !month) return undefined;
+
+ return new Date(Date.UTC(year, month - 1)).toLocaleDateString('en-US', {
+ month: 'short',
+ timeZone: 'UTC',
+ year: 'numeric'
+ });
+ }
+
+ /** Search all of HuggingFace; an empty query clears the results. */
async search(query: string): Promise {
const trimmed = query.trim();
const requestId = ++this.searchRequestId;
+ this.query = trimmed;
+
if (!trimmed) {
this.searching = false;
- this.models = this.defaultModels;
- this.error = null;
+ this.searchResults = [];
+ this.searchError = null;
return;
}
@@ -137,21 +159,32 @@ class ModelsDiscoverStore {
this.searching = true;
try {
- const results = await HuggingFaceService.searchByQuery(trimmed, { limit: 50 });
+ const results = await this.searchHub(trimmed);
if (requestId !== this.searchRequestId) return;
- this.models = this.baseOrgFirst(results);
- this.error = null;
+ this.searchResults = results;
+ this.searchError = null;
} catch (err) {
if (requestId !== this.searchRequestId) return;
- this.error = err instanceof Error ? err.message : 'Search failed';
+ this.searchResults = [];
+ this.searchError = err instanceof Error ? err.message : 'Search failed';
} finally {
if (requestId === this.searchRequestId) this.searching = false;
}
}
+ /**
+ * One Hub search in the order every search surface lists it. Keeps no state, so a
+ * second surface (the search dialog) never disturbs the models page's results.
+ */
+ async searchHub(query: string): Promise {
+ return this.baseOrgFirst(
+ await HuggingFaceService.searchByQuery(query.trim(), { limit: MODELS_DISCOVER_SEARCH_LIMIT })
+ );
+ }
+
/**
* Size range for a repo not measured yet, fetched once and cached: a search result
* never goes through fetch(), and a row can be remounted while scrolling.
@@ -228,6 +261,12 @@ class ModelsDiscoverStore {
);
}
+ private catalogEntryFor(modelId: string): HfCatalogEntry | undefined {
+ return this.catalog.find((entry) =>
+ entry.sizes.some((size) => size.builds.some((build) => build.repo === modelId))
+ );
+ }
+
/** Byte sizes of every non-sidecar quant file in a tree, shards collapsed. */
private quantSizesOf(tree: HfModelSibling[]): number[] {
return HuggingFaceService.collapseGgufShards(
diff --git a/ui/apps/chat/src/lib/stores/ui.svelte.ts b/ui/apps/chat/src/lib/stores/ui.svelte.ts
index 62f702cba6f0..49563d2667ef 100644
--- a/ui/apps/chat/src/lib/stores/ui.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/ui.svelte.ts
@@ -6,6 +6,7 @@
* controls and the chat tab bar reacts to).
*/
import {
+ MODELS_VIEW_MODE_LOCALSTORAGE_KEY,
ROUTES,
SETTINGS_KEYS,
SIDEBAR_COLLAPSED_SECTIONS_LOCALSTORAGE_KEY,
@@ -15,7 +16,7 @@ import {
SIDEBAR_SECTION_ORDER_LOCALSTORAGE_KEY,
SIDEBAR_WIDTH_LOCALSTORAGE_KEY
} from '#lib/constants/index.ts';
-import { SidebarAction } from '#lib/enums/index.ts';
+import { ModelsViewMode, SidebarAction } from '#lib/enums/index.ts';
import { deviceStore } from '#lib/stores/device.svelte.ts';
import { settingsStore } from '#lib/stores/settings/index.svelte.ts';
import type { Group } from '#lib/types/groups.js';
@@ -89,12 +90,6 @@ class UiStore {
/** Set when a flow outside the chat wants the composer focused once it can take it. */
composerFocusRequested = $state(false);
- /** Repo the Discover dialog selects when it opens, set by a model row. */
- discoverModelFocus = $state(null);
-
- /** Open state of the Discover dialog. */
- discoverModelsOpen = $state(false);
-
/** Sidebar sections showing all their chats past the preview, for this session. */
expandedSidebarSections = new SvelteSet();
@@ -104,6 +99,9 @@ class UiStore {
/** Open state of the group picker, a phone's stand-in for the group submenus. */
groupPicker = $state(null);
+ /** Hugging Face repo the Hub details drawer shows, e.g. `ggml-org/gemma-3-4b-it-GGUF`. */
+ hubModelFocus = $state(null);
+
/** Whether the main chat form is expanded into its large editor. */
isComposerExpanded = $state(false);
@@ -117,6 +115,8 @@ class UiStore {
modelsReturnRoute: ResolvedPathname = resolve(ROUTES.START);
/** Bumped to close every open models selector; a counter, so no selector has to reset it. */
modelsSelectorCloseSignal = $state(0);
+ /** Table or grid of cards on the models page; remembered across reloads. */
+ modelsViewMode = $state(this.loadModelsViewMode());
/** Open state of the project dialog, `null` while closed. */
projectDialog = $state(null);
/** Open state of the project picker, a phone's stand-in for the project submenus. */
@@ -135,6 +135,11 @@ class UiStore {
return Boolean(settingsStore.getConfig(SETTINGS_KEYS.ENABLE_DISCOVER_MODELS));
}
+ /** Whether the Hub details drawer is open. */
+ get isHubModelDetailsOpen(): boolean {
+ return this.hubModelFocus !== null;
+ }
+
/**
* Whether MCP shows in the sidebar. Off by default: most people have never heard of MCP,
* so it waits behind its setting. Hiding it only hides the entry point: servers already
@@ -177,6 +182,11 @@ class UiStore {
localStorage.setItem(SIDEBAR_EXPANDED_LOCALSTORAGE_KEY, String(expanded));
}
+ /** Close the Hub details drawer. */
+ closeHubModelDetails(): void {
+ this.hubModelFocus = null;
+ }
+
/** Close the model details drawer. */
closeModelDetails(): void {
this.modelDetailsFocus = null;
@@ -233,19 +243,23 @@ class UiStore {
this.groupPicker = options;
}
+ /**
+ * Open the Hub details drawer on one repo; a no-op while Discover is off. The two
+ * details drawers never stack, so the model details drawer steps aside.
+ */
+ openHubModelDetails(repo: string): void {
+ if (!this.isDiscoverEnabled) return;
+
+ this.modelDetailsFocus = null;
+ this.hubModelFocus = repo;
+ }
+
/** Open the model details drawer over the current page, without leaving it. */
openModelDetails(focus: string): void {
+ this.hubModelFocus = null;
this.modelDetailsFocus = focus;
}
- /** Open the Discover dialog, focused on one repo; a no-op while Discover is off. */
- openModelsDiscover(focus?: string): void {
- if (!this.isDiscoverEnabled) return;
-
- this.discoverModelFocus = focus ?? null;
- this.discoverModelsOpen = true;
- }
-
/** Navigate to the models manager; a no-op while it is hidden. */
openModelsManager(): void {
if (!this.isModelsManagerShown || this.isModelsPageOpen) return;
@@ -316,6 +330,13 @@ class UiStore {
this.composerFocusRequested = true;
}
+ /** Lay the models page out as a table or a grid of cards. */
+ setModelsViewMode(mode: ModelsViewMode): void {
+ this.modelsViewMode = mode;
+
+ if (browser) localStorage.setItem(MODELS_VIEW_MODE_LOCALSTORAGE_KEY, mode);
+ }
+
/**
* Remembers the order the user dragged the sections into.
*
@@ -378,6 +399,14 @@ class UiStore {
}
}
+ private loadModelsViewMode(): ModelsViewMode {
+ if (!browser) return ModelsViewMode.TABLE;
+
+ const saved = localStorage.getItem(MODELS_VIEW_MODE_LOCALSTORAGE_KEY);
+
+ return saved === ModelsViewMode.GRID ? ModelsViewMode.GRID : ModelsViewMode.TABLE;
+ }
+
private loadSidebarExpanded(): boolean {
if (!browser || deviceStore.isMobile) return false;
diff --git a/ui/apps/chat/src/routes/models/+page.svelte b/ui/apps/chat/src/routes/models/+page.svelte
index 0a4e3643a3ad..a1cf9f1197b2 100644
--- a/ui/apps/chat/src/routes/models/+page.svelte
+++ b/ui/apps/chat/src/routes/models/+page.svelte
@@ -3,8 +3,8 @@
import { ArrowLeft, Server } from '@lucide/svelte';
import ModelsManager from '#lib/components/app/models/ModelsManager/ModelsManager.svelte';
import ModelsManagerServers from '#lib/components/app/models/ModelsManager/ModelsManagerServers.svelte';
- import { APP_NAME, DISCOVER_ICON } from '#lib/constants/index.ts';
- import { modelsStore, uiStore } from '#lib/stores/index.ts';
+ import { APP_NAME } from '#lib/constants/index.ts';
+ import { modelsStore } from '#lib/stores/index.ts';
import { onMount } from 'svelte';
// the manager's second view: the servers its models come from
@@ -58,19 +58,6 @@
{#if !showServers}
- {#if uiStore.isDiscoverEnabled}
- uiStore.openModelsDiscover()}
- size="sm"
- variant="secondary"
- >
-
-
- Discover Models
-
- {/if}
-
(showServers = true)} size="sm" variant="secondary">
diff --git a/ui/apps/chat/tests/client/models-manager-views.svelte.test.ts b/ui/apps/chat/tests/client/models-manager-views.svelte.test.ts
new file mode 100644
index 000000000000..52e44fb19e08
--- /dev/null
+++ b/ui/apps/chat/tests/client/models-manager-views.svelte.test.ts
@@ -0,0 +1,122 @@
+// Guards the models page layouts: the table/grid switch, and the one search that
+// lists local matches and Hugging Face matches in a section of their own.
+
+import ModelsManagerWrapper from './components/ModelsManagerWrapper.svelte';
+import { MODELS_VIEW_MODE_LOCALSTORAGE_KEY, SETTINGS_KEYS } from '#lib/constants/index.ts';
+import { ModelsViewMode } from '#lib/enums/index.ts';
+import { HuggingFaceService } from '#lib/services/index.ts';
+import { modelsDiscoverStore, modelsStore, settingsStore, uiStore } from '#lib/stores/index.ts';
+import type { HfModelInfo } from '#lib/types/index.ts';
+import type { ModelOption } from '#lib/types/models.js';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import { render } from 'vitest-browser-svelte';
+
+function option(model: string): ModelOption {
+ return { capabilities: [], id: model, model, name: model };
+}
+
+function hubRecord(id: string): HfModelInfo {
+ return {
+ _id: id,
+ downloads: 0,
+ id,
+ library_name: null,
+ likes: 0,
+ modelId: id,
+ pipeline_tag: null,
+ private: false,
+ tags: []
+ };
+}
+
+const models = [
+ option('org/alpha-8b:Q4_K_M'),
+ option('org/alpha-8b:Q8_0'),
+ option('org/gamma-8b:Q4_K_M')
+];
+
+beforeEach(() => {
+ modelsStore.routerModels = [];
+ modelsStore.models = models;
+ modelsStore.favoriteModelIds = new Set();
+ settingsStore.config[SETTINGS_KEYS.GROUP_MODELS_BY_FAMILY] = false;
+ settingsStore.config[SETTINGS_KEYS.ENABLE_DISCOVER_MODELS] = false;
+ uiStore.setModelsViewMode(ModelsViewMode.TABLE);
+ uiStore.closeHubModelDetails();
+ // no network: the catalog is empty and every repo has no files
+ vi.spyOn(HuggingFaceService, 'getCatalog').mockResolvedValue([]);
+ vi.spyOn(HuggingFaceService, 'getTree').mockResolvedValue([]);
+});
+
+afterEach(() => {
+ vi.restoreAllMocks();
+});
+
+async function renderManager() {
+ const screen = render(ModelsManagerWrapper);
+
+ await expect.element(screen.getByText(/gamma\s+8B/)).toBeVisible();
+
+ return screen;
+}
+
+it('switches to a grid of cards, one per quant, and remembers it', async () => {
+ const screen = await renderManager();
+
+ // the table folds the two alpha quants under their repo
+ expect(screen.container.textContent).toContain('2 quants available');
+
+ await screen.getByRole('radio', { name: 'Grid' }).click();
+
+ expect(uiStore.modelsViewMode).toBe(ModelsViewMode.GRID);
+ expect(localStorage.getItem(MODELS_VIEW_MODE_LOCALSTORAGE_KEY)).toBe(ModelsViewMode.GRID);
+
+ // every quant is a card of its own, and the grid orders from a menu
+ await vi.waitFor(() => {
+ expect(screen.container.querySelectorAll('.grid button[aria-pressed]')).toHaveLength(3);
+ });
+ expect(screen.container.textContent).not.toContain('2 quants available');
+ await expect.element(screen.getByText('Sort:')).toBeVisible();
+ expect(screen.getByTitle('Sort by model, lowest first').query()).toBeNull();
+});
+
+it('searches the Hub with the same term and opens a result in the drawer', async () => {
+ settingsStore.config[SETTINGS_KEYS.ENABLE_DISCOVER_MODELS] = true;
+
+ const search = vi
+ .spyOn(HuggingFaceService, 'searchByQuery')
+ .mockResolvedValue([hubRecord('hub-org/delta-8B-GGUF')]);
+ const screen = await renderManager();
+
+ // the suggestions lead the page until a search takes it
+ await expect.element(screen.getByText('Suggested models')).toBeVisible();
+
+ await screen.getByPlaceholder('Search models or Hugging Face').fill('alpha');
+
+ // local matches stay where they are, the Hub's land in a section after them
+ await expect.element(screen.getByText(/gamma\s+8B/)).not.toBeInTheDocument();
+ await expect.element(screen.getByText('On Hugging Face')).toBeVisible();
+ await expect.element(screen.getByText(/delta\s+8B/)).toBeVisible();
+ expect(screen.getByText('Suggested models').query()).toBeNull();
+ expect(search).toHaveBeenCalledWith('alpha', { limit: 50 });
+
+ await screen.getByText(/delta\s+8B/).click();
+
+ expect(uiStore.hubModelFocus).toBe('hub-org/delta-8B-GGUF');
+
+ // clearing the term clears the results
+ await screen.getByPlaceholder('Search models or Hugging Face').fill('');
+ await vi.waitFor(() => expect(modelsDiscoverStore.searchResults).toHaveLength(0));
+});
+
+it('keeps the Hub out of the search while Discover is off', async () => {
+ const search = vi.spyOn(HuggingFaceService, 'searchByQuery').mockResolvedValue([]);
+ const screen = await renderManager();
+
+ await screen.getByPlaceholder('Search your models').fill('alpha');
+
+ await expect.element(screen.getByText(/gamma\s+8B/)).not.toBeInTheDocument();
+ expect(screen.getByText('On Hugging Face').query()).toBeNull();
+ expect(screen.getByText('Suggested models').query()).toBeNull();
+ expect(search).not.toHaveBeenCalled();
+});