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 9a241af283..4bc6fa8f51 100644 --- a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte +++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte @@ -10,6 +10,7 @@ X } from '@lucide/svelte'; import { ActionIcon, KeyboardShortcutInfo, ModelOrgAvatar } from '#lib/components/app/index.ts'; + import { ModelsDiscoverDetailsContainer } from '#lib/components/app/models/discover/index.ts'; import { CONVERSATION_SEARCH_CONTENT_DEBOUNCE_MS, CONVERSATION_SEARCH_CONTENT_LIMIT, @@ -77,6 +78,8 @@ let query = $state(''); let highlighted = $state(0); let inputRef = $state(null); + /** The Hub repo picked from the results, shown in place of them. */ + let selectedModel = $state(null); const needle = $derived(query.trim().toLowerCase()); const limit = $derived( @@ -157,11 +160,10 @@ if (open && isDiscoverEnabled) untrack(() => void modelsDiscoverStore.fetch()); }); - /** A Hub repo as a result; picking it opens Discover on that repo. */ + /** A Hub repo as a result; picking it shows the repo's details under the search. */ function modelEntry(model: HfModelInfo, section: string): SearchEntry { const range = modelsDiscoverStore.cachedSizeRangeFor(model.id); - - return { + const entry: SearchEntry = { icon: DISCOVER_ICON, id: `${section}-${model.id}`, label: model.id, @@ -170,8 +172,16 @@ : `${HuggingFaceService.formatDownloads(model.downloads)} downloads`, // the model's own org, the way the model cards show it org: orgOf(HuggingFaceService.getBaseModels(model)[0]) || orgOf(model.id), - run: () => close(() => uiStore.openModelsDiscover(model.id)) + run: () => (selectedModel = entry) }; + + return entry; + } + + /** Back from a picked repo to the results it was picked from. */ + function clearSelectedModel() { + selectedModel = null; + inputRef?.focus(); } const suggestedEntries = $derived.by((): SearchEntry[] => @@ -307,6 +317,9 @@ // while an IME is composing, Enter confirms a candidate and the arrows move through them if (isIMEComposing(event)) return; + // a picked repo replaces the results: there is nothing to move through or open + if (selectedModel) return; + if (event.key === KeyboardKey.ARROW_DOWN) { event.preventDefault(); move(1); @@ -323,6 +336,7 @@ if (!nextOpen) { query = ''; highlighted = 0; + selectedModel = null; } open = nextOpen; @@ -349,18 +363,82 @@ {/snippet} +{#snippet row(entry: SearchEntry, index: number | null, isActive: boolean)} + +{/snippet} + {#snippet search()}
0 ? `search-result-${activeIndex}` : undefined} + aria-activedescendant={entries.length > 0 && !selectedModel + ? `search-result-${activeIndex}` + : undefined} aria-controls="search-results" aria-expanded="true" autocomplete="off" class="h-10 min-w-0 flex-1 border-0 bg-transparent px-1 text-title font-normal outline-none placeholder:text-muted-foreground focus:outline-none focus-visible:ring-0" - oninput={() => (highlighted = 0)} + oninput={() => { + highlighted = 0; + selectedModel = null; + }} onkeydown={handleKeydown} placeholder="Search" role="combobox" @@ -377,100 +455,74 @@
-
- {#each sections as section, sectionIndex (section.title)} - {@const offset = sections - .slice(0, sectionIndex) - .reduce((total, previous) => total + previous.entries.length, 0)} + {#if selectedModel} + +
+ {@render row({ ...selectedModel, run: clearSelectedModel }, null, true)} +
-
-

- {section.title} + +

+ +
+ {:else} +
+ {#each sections as section, sectionIndex (section.title)} + {@const offset = sections + .slice(0, sectionIndex) + .reduce((total, previous) => total + previous.entries.length, 0)} - {#if section.loading} - - {/if} -

- - {#each section.entries as entry, entryIndex (entry.id)} - {@const index = offset + entryIndex} - {@const isActive = index === activeIndex && !deviceStore.isMobile} - - - - {/each} -
- {:else} -

{emptyMessage}

- {/each} -
+ + {@render row(entry, index, isActive)} + {/each} +
+ {:else} +

{emptyMessage}

+ {/each} + + {/if}
- {@render hint('Close', ['Esc'])} + {#if selectedModel} + {@render hint('Back', ['Esc'])} + {:else} + {@render hint('Close', ['Esc'])} - {@render hint('Navigate', [ArrowUp, ArrowDown])} + {@render hint('Navigate', [ArrowUp, ArrowDown])} - {@render hint('Open', [CornerDownLeft])} + {@render hint('Open', [CornerDownLeft])} + {/if}
{/snippet} { + // Esc steps back from a picked repo before it closes the search + if (!selectedModel) return; + + event.preventDefault(); + clearSelectedModel(); + }} onOpenAutoFocus={(event) => { event.preventDefault(); inputRef?.focus(); diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetails.svelte b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetails.svelte index 8cbaac8578..450174a53b 100644 --- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetails.svelte +++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetails.svelte @@ -23,9 +23,19 @@ loading?: boolean; /** Error message when loading failed. */ error?: string | null; + /** Leaner pane for a narrow host such as Search: no Hugging Face link, no description. */ + compact?: boolean; } - let { details, error = null, files, loading = false, modelId, readme }: Props = $props(); + let { + compact = false, + details, + error = null, + files, + loading = false, + modelId, + readme + }: Props = $props(); let gguf = $derived(details?.gguf); let baseModels = $derived(HuggingFaceService.getBaseModels(details)); @@ -77,7 +87,7 @@ {#if loading} - + {:else if error}

{error}

@@ -86,6 +96,7 @@
(null); let files = $state([]); @@ -63,4 +65,4 @@ }); - + diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte index 64bdbd5f62..79de8a3faa 100644 --- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte +++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte @@ -20,10 +20,13 @@ modalities: ModelModalities; hasTools: boolean; hasReasoning: boolean; + /** Leaner pane for a narrow host such as Search: no Hugging Face link, no description. */ + compact?: boolean; } let { baseModels, + compact = false, details, gguf, hasReasoning, @@ -83,23 +86,25 @@
- + + + {/if} - + diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsMetadata.svelte b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsMetadata.svelte index c222d4ab0a..8c425a4fec 100644 --- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsMetadata.svelte +++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsMetadata.svelte @@ -13,9 +13,11 @@ details: HfModelDetailInfo; gguf?: HfModelGguf; licenseTag: string | null; + /** Leaner pane for a narrow host such as Search: no Hugging Face link, no description. */ + compact?: boolean; } - let { details, gguf, licenseTag, modelId }: Props = $props(); + let { compact = false, details, gguf, licenseTag, modelId }: Props = $props(); // Catalog family description when curated, else the HF card description. let description = $derived( @@ -25,7 +27,7 @@ let chatTemplateOpen = $state(false); -{#if description} +{#if description && !compact}

{description}

{/if} diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsSkeleton.svelte b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsSkeleton.svelte index 1841495389..244023183a 100644 --- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsSkeleton.svelte +++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsSkeleton.svelte @@ -1,27 +1,36 @@ - +
-
+
- + - +
- + {#if !compact} + + {/if}
-
+
@@ -29,63 +38,61 @@
- - + + {#if !compact} +
+ - +
+ {/if} + +
- + - + - + - +
- +
{#each [0, 1, 2] as _, index (index)}
-
- +
+ - +
-
- +
+ - + {#if index === 0} + + {/if}
{/each}
- -
- - -
- - - - - -
- - -
+ + + diff --git a/ui/apps/chat/src/lib/constants/huggingface.constants.ts b/ui/apps/chat/src/lib/constants/huggingface.constants.ts index ca444b0162..cff3b6f602 100644 --- a/ui/apps/chat/src/lib/constants/huggingface.constants.ts +++ b/ui/apps/chat/src/lib/constants/huggingface.constants.ts @@ -103,7 +103,7 @@ export const HF_SHARED_DRAFT_TOKEN = 'shared'; * Extracts the leading precision digits from a quant token, e.g. * `Q4_K_XL` -> 4, `IQ2_XXS` -> 2, `TQ1_0` -> 1, `BF16` -> 16. */ -export const HF_QUANT_PRECISION_REGEX = /^(?:I?Q|TQ|BF|F|MXFP)?(\d+)/i; +export const HF_QUANT_PRECISION_REGEX = /^(?:I?Q|TQ|BF|F|MXFP|NVFP)?(\d+)/i; // Model card tags diff --git a/ui/apps/chat/src/lib/constants/model-id.constants.ts b/ui/apps/chat/src/lib/constants/model-id.constants.ts index d40fe39d78..a3152c88c7 100644 --- a/ui/apps/chat/src/lib/constants/model-id.constants.ts +++ b/ui/apps/chat/src/lib/constants/model-id.constants.ts @@ -48,10 +48,10 @@ export const MODEL_ID = { PARAMS_REGEX: /^[Ee]?\d+(\.\d+)?[BbMmKkTt]$/, /** - * Matches a quantization/precision segment, e.g. `Q4_K_M`, `IQ4_XS`, `F16`, `BF16`, `MXFP4`. + * Matches a quantization/precision segment, e.g. `Q4_K_M`, `IQ4_XS`, `F16`, `BF16`, `MXFP4`, `NVFP4`. * Case-insensitive to handle both uppercase and lowercase inputs. */ - QUANTIZATION_SEGMENT_REGEX: /^(I?Q\d+(_[A-Z0-9]+)*|F\d+|BF\d+|MXFP\d+(_[A-Z0-9]+)*)$/i, + QUANTIZATION_SEGMENT_REGEX: /^(I?Q\d+(_[A-Z0-9]+)*|F\d+|BF\d+|(?:MX|NV)FP\d+(_[A-Z0-9]+)*)$/i, /** Separates the model path from the quantization tag, e.g. `model:Q4_K_M`. */ QUANTIZATION_SEPARATOR: ':', diff --git a/ui/apps/chat/tests/unit/hf-helpers.test.ts b/ui/apps/chat/tests/unit/hf-helpers.test.ts index f21f3c9a30..c6cde5705d 100644 --- a/ui/apps/chat/tests/unit/hf-helpers.test.ts +++ b/ui/apps/chat/tests/unit/hf-helpers.test.ts @@ -59,6 +59,8 @@ describe('getBitDepth', () => { it('falls back to the leading precision digits', () => { expect(getBitDepth('TQ1_0')).toBe(1); expect(getBitDepth('MXFP4_MOE')).toBe(4); + expect(getBitDepth('NVFP4')).toBe(4); + expect(HuggingFaceService.extractQuantMeta('Inkling-2-Mini-NVFP4.gguf')?.quant).toBe('NVFP4'); }); it('returns null for unrecognized tokens', () => { diff --git a/ui/apps/chat/tests/unit/model-id-parser.test.ts b/ui/apps/chat/tests/unit/model-id-parser.test.ts index 85408a2c6d..1787b4d084 100644 --- a/ui/apps/chat/tests/unit/model-id-parser.test.ts +++ b/ui/apps/chat/tests/unit/model-id-parser.test.ts @@ -65,6 +65,7 @@ describe('parseModelId', () => { expect(parseModelId('model-100B-F16')).toMatchObject({ quantization: 'F16' }); expect(parseModelId('model-100B-BF16')).toMatchObject({ quantization: 'BF16' }); expect(parseModelId('model-100B-MXFP4')).toMatchObject({ quantization: 'MXFP4' }); + expect(parseModelId('model-26B-NVFP4')).toMatchObject({ quantization: 'NVFP4' }); // Colon-separated quantization expect(parseModelId('model-100B:UD-IQ1_S')).toMatchObject({ quantization: 'UD-IQ1_S' });