Recommended files with a quant; floating selection bar

Picking model weights in Add model or Download more also selects the
files that usually go with them (chat template, MTP head, mmproj, ...),
shown in a strip where each can be unchecked. Variants are matched by
quant, otherwise the best single one; kinds already selected aren't
added twice. Which kinds is set in Settings -> Downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 23:10:53 +02:00
1 parent 145818f149
commit 0247f257fb
16 files changed
+514 -27

No files matched your search

+23 -4
View File
@@ -2,7 +2,8 @@
import { createContext, useContext } from "react";
import { BADGE_CLASS } from "@/lib/colors";
import { FILE_ROLES, fileRole, type FileRoleStyles } from "@/lib/file-roles";
import { FILE_ROLES, fileRole, type FileRole, type FileRoleStyles } from "@/lib/file-roles";
import { DEFAULT_RECOMMENDED_ROLES } from "@/lib/recommend";
import { cn } from "@/lib/utils";
const defaults = Object.fromEntries(
@@ -10,16 +11,34 @@ const defaults = Object.fromEntries(
) as FileRoleStyles;
const LabelContext = createContext<FileRoleStyles>(defaults);
const RecommendedContext = createContext<FileRole[]>(DEFAULT_RECOMMENDED_ROLES);
/** Provides the label settings (from the Settings page) to client components. */
export function LabelSettingsProvider({ fileRoles, children }: { fileRoles: FileRoleStyles; children: React.ReactNode }) {
return <LabelContext.Provider value={fileRoles}>{children}</LabelContext.Provider>;
/** Provides file label and download settings (from the Settings page) to client components. */
export function LabelSettingsProvider({
fileRoles,
recommendedRoles,
children,
}: {
fileRoles: FileRoleStyles;
recommendedRoles: FileRole[];
children: React.ReactNode;
}) {
return (
<LabelContext.Provider value={fileRoles}>
<RecommendedContext.Provider value={recommendedRoles}>{children}</RecommendedContext.Provider>
</LabelContext.Provider>
);
}
export function useFileRoleStyles(): FileRoleStyles {
return useContext(LabelContext);
}
/** File kinds picked automatically along with model weights. */
export function useRecommendedRoles(): FileRole[] {
return useContext(RecommendedContext);
}
/** Label in front of a file name telling what the file is (Model, MTP, Vision, …). */
export function FileRoleBadge({ path, className }: { path: string; className?: string }) {
const styles = useFileRoleStyles();
+63
View File
@@ -0,0 +1,63 @@
"use client";
import { SparklesIcon } from "lucide-react";
import Link from "next/link";
import { FileRoleBadge } from "@/components/labels";
import { Checkbox } from "@/components/ui/checkbox";
import { groupSplitFiles } from "@/lib/file-groups";
import { formatBytes } from "@/lib/format";
import { cn } from "@/lib/utils";
/** Companion files picked along with the chosen quant; each can be unchecked. */
export function RecommendedStrip({
files,
paths,
active,
onToggle,
className,
}: {
files: { path: string; size: number }[];
/** All recommended paths (checked or not). */
paths: string[];
active: Set<string>;
onToggle: (paths: string[], on: boolean) => void;
className?: string;
}) {
if (paths.length === 0) return null;
const wanted = new Set(paths);
const entries = groupSplitFiles(files.filter((f) => wanted.has(f.path)));
return (
<div className={cn("flex flex-col gap-2 rounded-lg bg-muted/50 px-3 py-2.5 ring-1 ring-foreground/5", className)}>
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground">
<span className="flex items-center gap-1.5 font-medium text-foreground">
<SparklesIcon className="size-3.5 text-amber-500" />
Recommended with your quant
</span>
<Link href="/settings/downloads" className="hover:text-foreground hover:underline">
Change in Settings
</Link>
</div>
<div className="flex flex-wrap gap-2">
{entries.map((e) => {
const parts = e.parts.map((p) => p.path);
const on = parts.every((p) => active.has(p));
return (
<label
key={e.path}
className={cn(
"flex cursor-pointer items-center gap-2 rounded-md border bg-background px-2 py-1 text-xs transition-opacity",
!on && "opacity-60",
)}
>
<Checkbox checked={on} onCheckedChange={(v) => onToggle(parts, v === true)} aria-label={`Download ${e.path}`} />
<FileRoleBadge path={e.path} />
<span className="font-mono break-all">{e.path}</span>
<span className="text-muted-foreground tabular-nums">{formatBytes(e.size)}</span>
</label>
);
})}
</div>
</div>
);
}