mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-28 17:07:31 -05:00
ui : drop family favorites
Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
This commit is contained in:
+6
-42
@@ -19,7 +19,6 @@
|
||||
Trash2
|
||||
} from '@lucide/svelte';
|
||||
import {
|
||||
ActionIcon,
|
||||
DropdownMenuActions,
|
||||
GroupedList,
|
||||
type GroupedListGroup,
|
||||
@@ -110,20 +109,15 @@
|
||||
})
|
||||
);
|
||||
|
||||
/** Families of one section, the ones the user pinned leading it. */
|
||||
/** Families of one section. */
|
||||
function familyGroups(
|
||||
group: (typeof sections)[number]
|
||||
): GroupedListGroup<ModelFamilyGroup<ModelQuantGroup>, ModelQuantGroup>[] {
|
||||
return group.families
|
||||
.map((family) => ({
|
||||
entries: family.entries,
|
||||
group: family,
|
||||
key: `${group.key}::${family.key}`
|
||||
}))
|
||||
.sort(
|
||||
(a, b) =>
|
||||
Number(modelsStore.isFavoriteFamily(b.key)) - Number(modelsStore.isFavoriteFamily(a.key))
|
||||
);
|
||||
return group.families.map((family) => ({
|
||||
entries: family.entries,
|
||||
group: family,
|
||||
key: `${group.key}::${family.key}`
|
||||
}));
|
||||
}
|
||||
|
||||
// Cancel is confirmed once for the whole list, so a single dialog instance
|
||||
@@ -434,16 +428,13 @@
|
||||
{#snippet familyRow({
|
||||
expanded,
|
||||
group: family,
|
||||
key,
|
||||
toggle
|
||||
}: {
|
||||
expanded: boolean;
|
||||
group: ModelFamilyGroup<ModelQuantGroup>;
|
||||
key: string;
|
||||
toggle: () => void;
|
||||
})}
|
||||
{@const countLabel = `${family.entries.length} model${family.entries.length === 1 ? '' : 's'}`}
|
||||
{@const favorite = modelsStore.isFavoriteFamily(key)}
|
||||
|
||||
<!-- <div class="px-2"> -->
|
||||
<div
|
||||
@@ -464,33 +455,6 @@
|
||||
<span class="truncate text-sm font-medium">{family.label}</span>
|
||||
|
||||
<span class="text-sm text-muted-foreground">{countLabel}</span>
|
||||
|
||||
<span
|
||||
class="flex shrink-0"
|
||||
onclick={(event) => event.stopPropagation()}
|
||||
onkeydown={(event) => event.stopPropagation()}
|
||||
role="presentation"
|
||||
>
|
||||
{#if favorite}
|
||||
<ActionIcon
|
||||
class="h-5 w-5 text-rose-500 hover:text-rose-400"
|
||||
icon={Heart}
|
||||
iconSize="h-4 w-4"
|
||||
onclick={() => modelsStore.toggleFamilyFavorite(key)}
|
||||
tooltip="Remove family from favorites"
|
||||
tooltipAsTitle
|
||||
/>
|
||||
{:else}
|
||||
<ActionIcon
|
||||
class="h-5 w-5 opacity-0 transition group-hover:opacity-100 [@media(pointer:coarse)]:opacity-100"
|
||||
icon={Heart}
|
||||
iconSize="h-4 w-4"
|
||||
onclick={() => modelsStore.toggleFamilyFavorite(key)}
|
||||
tooltip="Add family to favorites"
|
||||
tooltipAsTitle
|
||||
/>
|
||||
{/if}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span></span>
|
||||
|
||||
@@ -34,9 +34,6 @@ export const FAVORITE_MODELS_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.favoriteMod
|
||||
/** Open state the user set for a model list section or one of its families, by id. */
|
||||
export const MODEL_GROUP_OPEN_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.modelGroupOpen`;
|
||||
|
||||
/** Model families pinned to the top of their provider section. */
|
||||
export const FAVORITE_MODEL_FAMILIES_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.favoriteModelFamilies`;
|
||||
|
||||
/** Per-model load and inference overrides, keyed by backend-qualified model id. */
|
||||
export const MODEL_OVERRIDES_LOCALSTORAGE_KEY = `${STORAGE_APP_NAME}.modelOverrides`;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
import { browser } from '$app/environment';
|
||||
import {
|
||||
FAVORITE_MODEL_FAMILIES_LOCALSTORAGE_KEY,
|
||||
FAVORITE_MODELS_LOCALSTORAGE_KEY,
|
||||
HIDDEN_MODELS_LOCALSTORAGE_KEY,
|
||||
MODEL_GROUP_OPEN_LOCALSTORAGE_KEY,
|
||||
@@ -88,19 +87,6 @@ function loadHiddenModels(): Set<string> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Family keys pinned to the top of their provider section. */
|
||||
function loadFavoriteFamilies(): Set<string> {
|
||||
if (!browser) return new SvelteSet<string>();
|
||||
|
||||
try {
|
||||
const raw = localStorage.getItem(FAVORITE_MODEL_FAMILIES_LOCALSTORAGE_KEY);
|
||||
|
||||
return raw ? new SvelteSet(JSON.parse(raw) as string[]) : new SvelteSet<string>();
|
||||
} catch {
|
||||
return new SvelteSet<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/** Open state the user set for a section or family of the model lists. */
|
||||
function loadGroupOpenState(): SvelteMap<string, boolean> {
|
||||
if (!browser) return new SvelteMap<string, boolean>();
|
||||
@@ -141,7 +127,6 @@ function loadRecentModels(): string[] {
|
||||
class ModelsStore implements ModelPropsHost, ModelStatusHost {
|
||||
activeModels = $state<ModelOption[]>([]);
|
||||
error = $state<string | null>(null);
|
||||
favoriteFamilyIds = $state<Set<string>>(loadFavoriteFamilies());
|
||||
favoriteModelIds = $state<Set<string>>(this.loadFavoritesFromStorage());
|
||||
groupOpenState = $state<SvelteMap<string, boolean>>(loadGroupOpenState());
|
||||
hiddenModelIds = $state<Set<string>>(loadHiddenModels());
|
||||
@@ -473,10 +458,6 @@ class ModelsStore implements ModelPropsHost, ModelStatusHost {
|
||||
return this.favoriteModelIds.has(modelId);
|
||||
}
|
||||
|
||||
isFavoriteFamily(key: string): boolean {
|
||||
return this.favoriteFamilyIds.has(key);
|
||||
}
|
||||
|
||||
isGroupOpen(id: string, fallbackOpen: boolean): boolean {
|
||||
return this.groupOpenState.get(id) ?? fallbackOpen;
|
||||
}
|
||||
@@ -666,25 +647,6 @@ class ModelsStore implements ModelPropsHost, ModelStatusHost {
|
||||
return candidate && candidate.trim().length > 0 ? candidate : id;
|
||||
}
|
||||
|
||||
/** Pin a family to the top of its provider section. */
|
||||
toggleFamilyFavorite(key: string): void {
|
||||
const next = new SvelteSet(this.favoriteFamilyIds);
|
||||
|
||||
if (next.has(key)) {
|
||||
next.delete(key);
|
||||
} else {
|
||||
next.add(key);
|
||||
}
|
||||
|
||||
this.favoriteFamilyIds = next;
|
||||
|
||||
try {
|
||||
localStorage.setItem(FAVORITE_MODEL_FAMILIES_LOCALSTORAGE_KEY, JSON.stringify([...next]));
|
||||
} catch {
|
||||
toast.error('Failed to save favorite model families to local storage');
|
||||
}
|
||||
}
|
||||
|
||||
toggleFavorite(modelId: string): void {
|
||||
this.setFavorites([modelId], !this.favoriteModelIds.has(modelId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user