Files
llama.cpp/tools/ui/src/lib/components/app/models/ModelsManager/ModelsManagerTableToolbar.svelte
T
Aleksander Grygier b013e56a71 ui : add the models manager (#29583)
* ui : add the drawer, sheet and grouped list primitives

Add the drawer and sheet overlay components, the toggle and toggle
group, the shared searchable input, the collapsible sections and the
grouped list, and the near viewport helper they position with.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* ui : add the shared model components and data layer

Add the model row pieces shared by the selector and the manager, the
models store with its download status feed, the huggingface and
migration services, and the model utils, enums and constants they
read through.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* ui : rework the models selector around its providers

Group the selector components under their own folder, rework the list
around the provider grouping, add the mobile trigger and the download
item, and derive the selection state in one hook.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* ui : add the models manager

Add the manager table with its repo, quant and status rows, the
filters and the toolbar, the row actions in a drawer, the downloads
section, the manage models dialog and the stories and tests.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* ui : rework the chat form actions and the mobile experience

Move the add actions into a drawer and a sheet, float the model
actions in a bar on a phone, open the context panel in a drawer, and
derive the attachment, reasoning and tools menus in hooks.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* ui : move the mcp servers to the sidebar rail and tidy the dialogs

Move the mcp servers dialog to the sidebar rail with its menu
entries, even out the dialogs on a phone, and group the mcp and
settings stores behind their own modules.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* ui : polish the shell

The secondary button gets its own look back and the chat add button its
own light surface. Pressable elements get a pointer cursor again, the
font rendering smooths on the app shell, and the agent skills stay out
of prettier's way.

The root layout props probe rework that came with this polish reads the
providers api url and stays with the providers change instead.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* ui : wrap the model id classes

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* ui : load the model the new chat CTA picks

Start a new chat selected the model but left it unloaded, so the chat
opened against a server with nothing in memory. Both CTAs share a load
helper now.

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash

* refactor: Post-review fixes
2026-10-09 10:34:45 +02:00

89 lines
2.5 KiB
Svelte

<script lang="ts">
import ModelsManagerFilters from './ModelsManagerFilters.svelte';
import { hasActiveFilters } from './utils';
import { X } from '@lucide/svelte';
import { SearchInput } from '$lib/components/app/forms';
import { Button } from '$lib/components/ui/button';
import { type ModalityKey } from '$lib/constants';
import { ModelCapability } from '$lib/enums';
import { deviceStore, uiStore } from '$lib/stores';
import type { Snippet } from 'svelte';
interface Props {
/** Capabilities a model must have every one of. */
capabilities?: ModelCapability[];
/** Smallest context a model must support; 0 keeps every model. */
contextLimit?: number;
filter?: string;
/** Modalities a model must support at least one of. */
modalities?: ModalityKey[];
/** Rendered at the toolbar's right end, past the filters. */
toolbarEnd?: Snippet;
}
let {
capabilities = $bindable<ModelCapability[]>([]),
contextLimit = $bindable(0),
filter = $bindable(''),
modalities = $bindable<ModalityKey[]>([]),
toolbarEnd
}: Props = $props();
let hasFilters = $derived(hasActiveFilters(contextLimit, modalities, capabilities));
let filterInput = $state<HTMLInputElement | null>(null);
// The search takes the focus the dialog would give its first control: the input
// mounts a frame or two after the dialog opens (the toolbar renders below the
// table in the DOM), so the poll retries until the ref lands or gives up.
$effect(() => {
if (!uiStore.manageModelsOpen) return;
let frames = 0;
let handle = requestAnimationFrame(function focusFilter() {
if (filterInput) {
filterInput.focus({ preventScroll: true });
return;
}
if (frames++ < 20) handle = requestAnimationFrame(focusFilter);
});
return () => cancelAnimationFrame(handle);
});
</script>
<!-- Below md the search takes a row of its own and the filters follow it. -->
<div class="flex shrink-0 flex-wrap items-center gap-2 pb-4 max-md:gap-3 md:flex-nowrap">
<SearchInput
bind:ref={filterInput}
bind:value={filter}
class="w-full md:w-auto md:max-w-64"
placeholder="Search your models"
size={deviceStore.isMobile ? 'default' : 'sm'}
/>
<ModelsManagerFilters bind:capabilities bind:contextLimit bind:modalities />
{#if hasFilters}
<Button
class="gap-1.5 text-muted-foreground"
onclick={() => {
contextLimit = 0;
modalities = [];
capabilities = [];
}}
size="sm"
variant="ghost"
>
<X class="h-3.5 w-3.5" />
Clear filters
</Button>
{/if}
<div class="ml-auto flex items-center gap-2">
{@render toolbarEnd?.()}
</div>
</div>