Download more, file labels, split-file grouping, settings for labels and tags

- Files tab: "Download more" adds files to a model's selection and queues them
- Colored file labels (Model, MTP, Vision/mmproj, imatrix, Config, …)
- Split GGUF/safetensors parts shown and selected as one entry everywhere
- Settings page with a Labels section: file label names/colors, tag
  rename/recolor/delete; new settings table and tags.color
- Quants only count model weights

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 20:42:03 +02:00
1 parent 5211ec9064
commit df18415e02
34 files changed
+2256 -132

No files matched your search

+69
View File
@@ -0,0 +1,69 @@
import "server-only";
import { eq } from "drizzle-orm";
import { db } from "@/lib/db/client";
import { settings } from "@/lib/db/schema";
import { isLabelColor } from "@/lib/colors";
import { FILE_ROLE_ORDER, FILE_ROLES, type FileRole, type FileRoleStyles } from "@/lib/file-roles";
const FILE_ROLES_KEY = "labels.fileRoles";
export const FILE_ROLE_LABEL_MAX = 24;
type StoredRoles = Partial<Record<FileRole, { label?: string; color?: string }>>;
async function read<T>(key: string): Promise<T | null> {
try {
const row = await db().query.settings.findFirst({ where: eq(settings.key, key) });
return (row?.value as T) ?? null;
} catch {
return null; // table missing before the first migration
}
}
async function write(key: string, value: unknown) {
await db()
.insert(settings)
.values({ key, value })
.onConflictDoUpdate({ target: settings.key, set: { value, updatedAt: new Date() } });
}
/** Label text and color per file role: defaults merged with what was saved in Settings. */
export async function getFileRoleStyles(): Promise<FileRoleStyles> {
const stored = (await read<StoredRoles>(FILE_ROLES_KEY)) ?? {};
const out = {} as FileRoleStyles;
for (const role of FILE_ROLE_ORDER) {
const s = stored[role] ?? {};
out[role] = {
label: typeof s.label === "string" && s.label.trim() ? s.label.trim() : FILE_ROLES[role].label,
color: isLabelColor(s.color) ? s.color : FILE_ROLES[role].color,
};
}
return out;
}
export class SettingsError extends Error {
status = 400;
code = "invalid";
}
/** Save label/color overrides. Values equal to the default are not stored. */
export async function saveFileRoleStyles(input: Record<string, { label?: unknown; color?: unknown }>): Promise<FileRoleStyles> {
const stored: StoredRoles = {};
for (const [role, v] of Object.entries(input)) {
if (!(role in FILE_ROLES)) throw new SettingsError(`Unknown file label "${role}".`);
const def = FILE_ROLES[role as FileRole];
const entry: { label?: string; color?: string } = {};
if (v.label !== undefined) {
if (typeof v.label !== "string" || !v.label.trim() || v.label.trim().length > FILE_ROLE_LABEL_MAX) {
throw new SettingsError(`Label for "${role}" must be 1–${FILE_ROLE_LABEL_MAX} characters.`);
}
if (v.label.trim() !== def.label) entry.label = v.label.trim();
}
if (v.color !== undefined) {
if (!isLabelColor(v.color)) throw new SettingsError(`Unknown color "${String(v.color)}".`);
if (v.color !== def.color) entry.color = v.color;
}
if (entry.label || entry.color) stored[role as FileRole] = entry;
}
await write(FILE_ROLES_KEY, stored);
return getFileRoleStyles();
}