Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

12 changes: 11 additions & 1 deletion ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
: `${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: () => close(() => openHubModel(model.id))
};
}

Expand Down Expand Up @@ -320,6 +320,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);
Expand Down
9 changes: 3 additions & 6 deletions ui/apps/chat/src/lib/components/app/dialogs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -469,6 +469,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';
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -61,6 +63,7 @@

<span {@attach nearViewport(() => (isNearViewport = true))} class={className}>
<ModelCapabilityIcons
{asBadges}
{hideModalities}
modalities={option.modalities}
{supportsThinking}
Expand Down
98 changes: 98 additions & 0 deletions ui/apps/chat/src/lib/components/app/models/ModelCard.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<script lang="ts">
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();
</script>

<!-- The surface of the MCP server cards. The title button stretches over the whole card,
so a click anywhere opens the model, while the controls stack above it: a button
nested in a button is invalid. -->
<Card.Root
class={[
'relative min-w-0 gap-3! overflow-hidden bg-muted/30 p-4 transition-colors hover:bg-muted/50',
selected && 'ring-1 ring-primary/40',
dimmed && 'opacity-60',
className
]}
>
<div class="flex min-w-0 items-start gap-3">
<button
aria-pressed={pressed}
class="flex min-w-0 flex-1 cursor-pointer items-center gap-3 text-left before:absolute before:inset-0 before:content-[''] focus-visible:outline-none focus-visible:before:rounded-xl focus-visible:before:ring-2 focus-visible:before:ring-ring/50"
onclick={onSelect}
title={tooltip}
type="button"
>
{@render avatar()}

<span class="min-w-0 flex-1">
{@render title()}
</span>
</button>

{#if actions}
<div class="relative z-10 -mt-1 -mr-1.5 shrink-0">
{@render actions()}
</div>
{/if}
</div>

{@render children?.()}

{#if footer || footerEnd}
<div class="mt-auto flex min-h-6 items-center justify-between gap-3 text-xs">
<div class="min-w-0 text-muted-foreground">
{@render footer?.()}
</div>

{#if footerEnd}
<div class="relative z-10 flex shrink-0 items-center">
{@render footerEnd()}
</div>
{/if}
</div>
{/if}

{@render overlay?.()}
</Card.Root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script lang="ts">
import * as Card from '@ggml-org/llama-ui/ui/card';
import { Skeleton } from '@ggml-org/llama-ui/ui/skeleton';

interface Props {
class?: string;
/** Leave room for a description, the way a Hub card carries one. */
description?: boolean;
}

let { class: className = '', description = false }: Props = $props();
</script>

<!-- Static skeleton of ModelCard: avatar, name over its subline, capability icons, footer facts. -->
<Card.Root class={['gap-3! bg-muted/30 p-4', className]}>
<div class="flex items-center gap-3">
<Skeleton class="size-9 shrink-0 rounded-md" />

<div class="min-w-0 flex-1 space-y-1.5">
<Skeleton class="h-4 w-36" />

<Skeleton class="h-3 w-20" />
</div>

<Skeleton class="h-3 w-12 shrink-0 self-start" />
</div>

{#if description}
<div class="space-y-1.5">
<Skeleton class="h-3 w-full" />

<Skeleton class="h-3 w-3/4" />
</div>
{/if}

<div class="mt-auto flex items-center justify-between">
<Skeleton class="h-3 w-24" />

<Skeleton class="h-3 w-16" />
</div>
</Card.Root>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { isLocalOption } from './ModelsManager/utils';
import { cn } from '@ggml-org/llama-ui/utils';
import { MODEL_ID } from '#lib/constants/index.ts';
import { HuggingFaceService } from '#lib/services/index.ts';
import type { ModelOption } from '#lib/types/models.js';
Expand Down Expand Up @@ -53,7 +54,7 @@

<span
{@attach nearViewport(() => (isNearViewport = true))}
class={['text-body-sm text-muted-foreground', className]}
class={cn('text-body-sm text-muted-foreground', className)}
>
{formatContextLength(values)}
</span>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import ModelsManagerHubResults from './ModelsManagerHubResults.svelte';
import ModelsManagerModelsTable from './ModelsManagerModelsTable.svelte';
import {
downloadGroups,
Expand All @@ -10,20 +11,22 @@
type ModelsTableGroup,
splitHiddenQuants
} from './utils';
import { ModelsDiscoverCarousel } from '#lib/components/app/models/discover/index.ts';
import {
LOCAL_BACKEND_ID,
type ModalityKey,
MODELS_DISCOVER_SEARCH_DEBOUNCE_MS,
MODELS_TABLE_GROUP_LABELS
} from '#lib/constants/index.ts';
import {
ModelCapability,
ModelsTableGroupKind,
ModelsTableServerKind
} from '#lib/enums/index.ts';
import { modelsStore, serversStore, uiStore } from '#lib/stores/index.ts';
import { modelsDiscoverStore, modelsStore, serversStore, uiStore } from '#lib/stores/index.ts';
import type { ModelOption } from '#lib/types/models.js';
import { filterModelOptions } from '#lib/utils/index.ts';
import type { Snippet } from 'svelte';
import { type Snippet, untrack } from 'svelte';
import { SvelteMap } from 'svelte/reactivity';

interface Props {
Expand Down Expand Up @@ -52,6 +55,26 @@
findModelOption(uiStore.modelDetailsFocus, allModels, downloads)?.id ?? null
);

// the same term searches the Hub, once typing settles; an empty one clears the results
let isHubSearch = $derived(uiStore.isDiscoverEnabled && filter.trim().length > 0);

$effect(() => {
const query = isHubSearch ? filter : '';

if (!query) {
untrack(() => void modelsDiscoverStore.search(''));

return;
}

const timer = setTimeout(
() => untrack(() => void modelsDiscoverStore.search(query)),
MODELS_DISCOVER_SEARCH_DEBOUNCE_MS
);

return () => clearTimeout(timer);
});

let isFavorite = $derived((option: ModelOption) =>
modelsStore.favoriteModelIds.has(option.model)
);
Expand Down Expand Up @@ -253,7 +276,14 @@

<svelte:window onkeydown={handleKeydown} />

<div class={['relative flex min-h-0 flex-1', className]}>
<div class={['relative flex min-h-0 flex-1 flex-col', className]}>
<!-- a search owns the page: the suggestions step aside for its results -->
{#if uiStore.isDiscoverEnabled && !filter.trim()}
<div class="shrink-0 pb-2">
<ModelsDiscoverCarousel />
</div>
{/if}

<div class="min-h-0 min-w-0 flex-1">
<ModelsManagerModelsTable
bind:capabilities={capabilityFilter}
Expand All @@ -267,6 +297,12 @@
{selectedId}
{serverCounts}
{toolbarEnd}
/>
>
{#snippet footer()}
{#if isHubSearch}
<ModelsManagerHubResults query={filter} />
{/if}
{/snippet}
</ModelsManagerModelsTable>
</div>
</div>
Loading
Loading