Release 0.16.0: new look, search, remove files, easier deploy
Release / release (push) Successful in 4m33s

- Dot-matrix "Creation of Adam" page banners behind a floating menu,
  glass cards and tables, library header with live stats, table toolbar
  with pagination, Cmd/Ctrl+K search across models, endpoints, runs,
  tags, settings and actions.
- Remove single files from a model (selection + disk, via a worker job).
- Containers start as root to prepare folders and drop to PUID:PGID;
  AUTH_SECRET is generated when unset; sandbox runs as nobody;
  KANAME_IMAGE and image docs in the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-30 14:06:46 +01:00
1 parent c6bcb514e6
commit 5becfc47a0
53 files changed
+1869 -468

No files matched your search

+5 -2
View File
@@ -68,8 +68,10 @@ export type JobResult = {
hashMismatch?: string[];
/** Files in the model folder that aren't selected repo files. */
extra?: { path: string; size: number; inRepo: boolean }[];
/** Update jobs: files of the old revision to delete once the download succeeded. */
/** Update jobs: files of the old revision to delete once the download succeeded. Remove jobs: the files to delete. */
removePaths?: string[];
/** Remove jobs: what was actually deleted. */
removed?: string[];
/** Delete jobs: files that were kept because they don't belong to the repo. */
kept?: string[];
};
@@ -219,7 +221,8 @@ export const modelFiles = sqliteTable(
export const JOB_KINDS = ["download", "verify", "deep_verify", "delete"] as const;
export type JobKind = (typeof JOB_KINDS)[number];
export const JOB_PURPOSES = ["initial", "add", "import", "repair", "update"] as const;
/** Download purposes; "remove" is a delete job that removes only some files (the model stays). */
export const JOB_PURPOSES = ["initial", "add", "import", "repair", "update", "remove"] as const;
export type JobPurpose = (typeof JOB_PURPOSES)[number];
export const JOB_STATES = [
+1
View File
@@ -12,5 +12,6 @@ const KIND: Record<string, string> = { download: "Download", verify: "Verify", d
export function jobLabel(job: { kind: string; purpose: string | null }): string {
if (job.kind === "download") return DOWNLOAD_PURPOSE[job.purpose ?? "initial"] ?? "Download";
if (job.kind === "delete" && job.purpose === "remove") return "Remove files";
return KIND[job.kind] ?? job.kind;
}
+47
View File
@@ -231,3 +231,50 @@ export async function addFilesToModel(modelId: string, paths: string[]): Promise
const { jobId } = await queueDownload(modelId, "add");
return { jobId, added: changed.filter((f) => !f.selected).length };
}
/**
* Remove files from a model: take them out of the selection rule (exact-path excludes, and their
* exact includes dropped), mark them unselected, and queue a delete job that removes them from
* disk. The model and its other files stay. Removing every selected file is refused: delete the
* model instead.
*/
export async function removeFilesFromModel(modelId: string, paths: string[]): Promise<{ jobId: string; removed: number }> {
const d = db();
const model = await d.query.models.findFirst({ where: eq(models.id, modelId) });
if (!model) throw new ModelError("not_found", "Model not found.", 404);
if (await hasOpenJob(modelId)) throw new ModelError("busy", "A job for this model is still queued or running. Remove files when it has finished.", 409);
const files = await d.select().from(modelFiles).where(eq(modelFiles.modelId, modelId));
const wanted = new Set(paths);
const remove = files.filter((f) => f.selected && wanted.has(f.path));
if (remove.length === 0) throw new ModelError("empty_selection", "None of these files is selected.", 400);
if (remove.length === files.filter((f) => f.selected).length) {
throw new ModelError("empty_selection", "That would remove every file of this model. Delete the model instead.", 400);
}
const exact = new Set(remove.map((f) => escapeGlob(f.path)));
// Drop the files' exact includes; files a broader pattern still selects get an exact exclude.
const include = model.includePatterns.filter((p) => !exact.has(p));
const stillSelected = remove.filter((f) => isSelected(f.path, { include, exclude: model.excludePatterns }));
const rule: SelectionRule = { include, exclude: [...model.excludePatterns, ...stillSelected.map((f) => escapeGlob(f.path))] };
// The rule must now select exactly the old selection minus these files.
const changed = files.filter((f) => f.selected !== isSelected(f.path, rule));
if (changed.some((f) => !wanted.has(f.path))) throw new ModelError("busy", "The selection rule couldn't be narrowed to just these files.", 409);
const jobId = ulid();
await d.batch([
// The selection changed, so a stored update diff is stale; the next Hub check recomputes it.
d.update(models).set({ includePatterns: rule.include, excludePatterns: rule.exclude, updateDiff: null }).where(eq(models.id, modelId)),
...remove.map((f) => d.update(modelFiles).set({ selected: false }).where(eq(modelFiles.id, f.id))),
d.insert(jobs).values({
id: jobId,
modelId,
kind: "delete",
purpose: "remove",
targetSha: model.pinnedSha,
totalBytes: remove.reduce((s, f) => s + f.size, 0),
result: { removePaths: remove.map((f) => f.path) },
}),
]);
return { jobId, removed: remove.length };
}
+86
View File
@@ -0,0 +1,86 @@
// Removing single files from a model: selection rule, the queued job, and the worker deleting only
// those files. Temporary SQLite database and models folder; no Hub access.
// Runs with `--conditions=react-server` (see package.json) so "server-only" modules load.
import assert from "node:assert/strict";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { after, before, describe, it } from "node:test";
import { eq } from "drizzle-orm";
const dir = mkdtempSync(join(tmpdir(), "kaname-remove-"));
const modelsDir = join(dir, "models");
process.env.DATABASE_URL = `file:${join(dir, "test.db").replace(/\\/g, "/")}`;
process.env.MODELS_DIR = modelsDir;
type Mods = {
db: typeof import("./db/client");
schema: typeof import("./db/schema");
models: typeof import("./models");
delete: typeof import("../worker/delete");
};
let M: Mods;
const MODEL = "01M6000000000000000000000A";
const FILES = ["Qwen3-8B-Q4_K_M.gguf", "Qwen3-8B-Q8_0.gguf", "mmproj-F16.gguf", "README.md"];
before(async () => {
const { runMigrations } = await import("./db/migrate");
await runMigrations();
M = { db: await import("./db/client"), schema: await import("./db/schema"), models: await import("./models"), delete: await import("../worker/delete") };
const d = M.db.db();
// Q4 and Q8 picked by exact path, mmproj by a pattern; README not selected.
await d.insert(M.schema.models).values({
id: MODEL,
repoId: "unsloth/Qwen3-8B-GGUF",
pinnedSha: "a".repeat(40),
localPath: "unsloth/Qwen3-8B-GGUF",
includePatterns: ["Qwen3-8B-Q4_K_M.gguf", "Qwen3-8B-Q8_0.gguf", "mmproj-*"],
status: "ready",
});
await d.insert(M.schema.modelFiles).values(FILES.map((path) => ({ modelId: MODEL, path, size: 100, selected: path !== "README.md", state: path === "README.md" ? ("pending" as const) : ("present" as const) })));
mkdirSync(join(modelsDir, "unsloth", "Qwen3-8B-GGUF"), { recursive: true });
for (const f of FILES.slice(0, 3)) writeFileSync(join(modelsDir, "unsloth", "Qwen3-8B-GGUF", f), "x".repeat(100));
});
after(() => {
try {
rmSync(dir, { recursive: true, force: true });
} catch {}
});
describe("removing files from a model", () => {
it("narrows the selection rule to exactly the rest and queues a remove job", async () => {
const { jobId, removed } = await M.models.removeFilesFromModel(MODEL, ["Qwen3-8B-Q8_0.gguf", "mmproj-F16.gguf", "README.md"]);
assert.equal(removed, 2, "README isn't selected, so it isn't removed");
const model = await M.db.db().query.models.findFirst({ where: eq(M.schema.models.id, MODEL) });
assert.deepEqual(model!.includePatterns, ["Qwen3-8B-Q4_K_M.gguf", "mmproj-*"], "the exact include goes");
assert.deepEqual(model!.excludePatterns, ["mmproj-F16.gguf"], "the pattern stays, an exact exclude stops it");
const files = await M.db.db().select().from(M.schema.modelFiles).where(eq(M.schema.modelFiles.modelId, MODEL));
assert.deepEqual(files.filter((f) => f.selected).map((f) => f.path), ["Qwen3-8B-Q4_K_M.gguf"]);
const job = await M.db.db().query.jobs.findFirst({ where: eq(M.schema.jobs.id, jobId) });
assert.equal(job!.kind, "delete");
assert.equal(job!.purpose, "remove");
assert.deepEqual(job!.result?.removePaths, ["Qwen3-8B-Q8_0.gguf", "mmproj-F16.gguf"]);
await assert.rejects(M.models.removeFilesFromModel(MODEL, ["Qwen3-8B-Q4_K_M.gguf"]), /still queued or running/);
});
it("the worker deletes only those files and keeps the model", async () => {
const job = (await M.db.db().query.jobs.findFirst({ where: eq(M.schema.jobs.modelId, MODEL) }))!;
const model = (await M.db.db().query.models.findFirst({ where: eq(M.schema.models.id, MODEL) }))!;
await new M.delete.DeleteRunner(job, model, FILES).run();
const folder = join(modelsDir, "unsloth", "Qwen3-8B-GGUF");
assert.ok(existsSync(join(folder, "Qwen3-8B-Q4_K_M.gguf")));
assert.ok(!existsSync(join(folder, "Qwen3-8B-Q8_0.gguf")) && !existsSync(join(folder, "mmproj-F16.gguf")));
const done = await M.db.db().query.jobs.findFirst({ where: eq(M.schema.jobs.id, job.id) });
assert.equal(done!.state, "completed");
assert.deepEqual(done!.result?.removed, ["Qwen3-8B-Q8_0.gguf", "mmproj-F16.gguf"].sort());
const after = await M.db.db().query.models.findFirst({ where: eq(M.schema.models.id, MODEL) });
assert.equal(after!.status, "ready", "the remaining selection is complete");
});
it("refuses to remove every selected file", async () => {
await assert.rejects(M.models.removeFilesFromModel(MODEL, ["Qwen3-8B-Q4_K_M.gguf"]), /Delete the model instead/);
await assert.rejects(M.models.removeFilesFromModel(MODEL, ["README.md"]), /None of these files is selected/);
});
});