Client bundles: no drizzle in the browser, lazy palette, one copy of the painting
- The enum arrays move from schema.ts to src/lib/db/enums.ts (no imports), which schema.ts re-exports. The endpoint form and benchmark start imported ENDPOINT_ENGINES/QUALITY_SECTIONS from the schema, which put drizzle-orm, every table definition and ulid (18 KB gzipped) on the endpoint pages. An ESLint rule now refuses value imports from the schema in client code. - The ⌘K palette dialog is its own chunk, loaded on first open and preloaded when you hover or focus Search or press ⌘/Ctrl. - The dot painting's brightness grid was copied into 10 page chunks (~10 KB gzipped each); it is now one async chunk, parsed once per tab. The canvas skips redraws when size, pixel ratio and theme are unchanged (the ResizeObserver's first callback drew everything a second time) and draws at most once per frame while resizing. First-load JS per route drops by 10-29 KB gzipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
This commit is contained in:
9 files changed
+458
-339
No files matched your search
@@ -0,0 +1,93 @@
|
||||
// Enum values stored in text columns (see schema.ts), with their types. No imports: client
|
||||
// components may use these, unlike schema.ts, whose table definitions pull in drizzle-orm.
|
||||
|
||||
// Models
|
||||
|
||||
export const MODEL_STATUSES = [
|
||||
"pending", // added, nothing downloaded yet
|
||||
"downloading",
|
||||
"ready", // all selected files present at pinned SHA
|
||||
"incomplete", // verify found missing/broken files, or an update/repair didn't finish
|
||||
"failed", // last download failed
|
||||
"deleting",
|
||||
] as const;
|
||||
export type ModelStatus = (typeof MODEL_STATUSES)[number];
|
||||
|
||||
/** Is the repo (at the pinned commit) still on the Hub? Local files are never touched either way. */
|
||||
export const HUB_STATES = ["available", "repo_missing", "commit_missing"] as const;
|
||||
export type HubState = (typeof HUB_STATES)[number];
|
||||
|
||||
export const MODEL_FILE_STATES = [
|
||||
"pending", // not downloaded yet / not checked
|
||||
"present", // exists with the expected size
|
||||
"missing",
|
||||
"size_mismatch",
|
||||
"hash_mismatch",
|
||||
"verified", // deep verify: hash matches
|
||||
] as const;
|
||||
export type ModelFileState = (typeof MODEL_FILE_STATES)[number];
|
||||
|
||||
// Jobs
|
||||
|
||||
export const JOB_KINDS = ["download", "verify", "deep_verify", "delete"] as const;
|
||||
export type JobKind = (typeof JOB_KINDS)[number];
|
||||
|
||||
/** 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 = [
|
||||
"queued",
|
||||
"downloading",
|
||||
"verifying",
|
||||
"completed",
|
||||
"failed",
|
||||
"cancelled",
|
||||
"interrupted",
|
||||
] as const;
|
||||
export type JobState = (typeof JOB_STATES)[number];
|
||||
export const ACTIVE_JOB_STATES = ["downloading", "verifying"] as const satisfies JobState[];
|
||||
|
||||
export const JOB_ERROR_CODES = [
|
||||
"auth", // invalid/missing token
|
||||
"gated", // gated repo, access not granted
|
||||
"repo_not_found",
|
||||
"revision_not_found",
|
||||
"disk_full",
|
||||
"network",
|
||||
"size_mismatch", // finished but files don't match expected sizes
|
||||
"unknown",
|
||||
] as const;
|
||||
export type JobErrorCode = (typeof JOB_ERROR_CODES)[number];
|
||||
|
||||
export const JOB_FILE_STATES = ["pending", "downloading", "done", "failed"] as const;
|
||||
export type JobFileState = (typeof JOB_FILE_STATES)[number];
|
||||
|
||||
export const LOG_STREAMS = ["stdout", "stderr", "system"] as const;
|
||||
export type LogStream = (typeof LOG_STREAMS)[number];
|
||||
|
||||
// Endpoints and benchmarks
|
||||
|
||||
export const ENDPOINT_ENGINES = ["llama.cpp", "vllm", "sglang", "ollama", "other"] as const;
|
||||
export type EndpointEngine = (typeof ENDPOINT_ENGINES)[number];
|
||||
|
||||
export const BENCHMARK_STATES = ["queued", "running", "completed", "failed", "cancelled"] as const;
|
||||
export type BenchmarkState = (typeof BENCHMARK_STATES)[number];
|
||||
|
||||
export const BENCHMARK_PHASES = ["decode", "prefill", "concurrency"] as const;
|
||||
export type BenchmarkPhase = (typeof BENCHMARK_PHASES)[number];
|
||||
|
||||
export const QUALITY_SECTIONS = ["tools", "coding", "retrieval"] as const;
|
||||
export type QualitySection = (typeof QUALITY_SECTIONS)[number];
|
||||
|
||||
/** run: BetterBench; ab: paired A/B; eval: Kaname's quality eval (tool calling, coding, retrieval). */
|
||||
export const BENCHMARK_KINDS = ["run", "ab", "eval"] as const;
|
||||
export type BenchmarkKind = (typeof BENCHMARK_KINDS)[number];
|
||||
|
||||
/**
|
||||
* preview: the worker runs `L80 betterbench --results … --dry-run --payload-out`; previewed: the
|
||||
* exact payload is ready to inspect; publish: confirmed by a user, the worker publishes it;
|
||||
* published / failed.
|
||||
*/
|
||||
export const PUBLICATION_STATES = ["preview", "previewed", "publish", "published", "failed"] as const;
|
||||
export type PublicationState = (typeof PUBLICATION_STATES)[number];
|
||||
+22
-85
@@ -8,6 +8,28 @@ import {
|
||||
uniqueIndex,
|
||||
} from "drizzle-orm/sqlite-core";
|
||||
import { ulid } from "ulid";
|
||||
import {
|
||||
BENCHMARK_KINDS,
|
||||
type BenchmarkPhase,
|
||||
BENCHMARK_STATES,
|
||||
ENDPOINT_ENGINES,
|
||||
type EndpointEngine,
|
||||
HUB_STATES,
|
||||
JOB_ERROR_CODES,
|
||||
JOB_FILE_STATES,
|
||||
JOB_KINDS,
|
||||
JOB_PURPOSES,
|
||||
JOB_STATES,
|
||||
LOG_STREAMS,
|
||||
MODEL_FILE_STATES,
|
||||
MODEL_STATUSES,
|
||||
PUBLICATION_STATES,
|
||||
type QualitySection,
|
||||
} from "./enums";
|
||||
|
||||
// The enum arrays live in ./enums (no dependencies), so client components can use them without
|
||||
// pulling drizzle-orm and every table definition into the browser bundle.
|
||||
export * from "./enums";
|
||||
|
||||
// Conventions (keep these when adding tables in later steps, they keep a Postgres port simple):
|
||||
// - Primary keys are ULID strings, generated in the app, never reused.
|
||||
@@ -36,20 +58,6 @@ const ts = (name: string) => integer(name, { mode: "timestamp_ms" });
|
||||
// Models
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const MODEL_STATUSES = [
|
||||
"pending", // added, nothing downloaded yet
|
||||
"downloading",
|
||||
"ready", // all selected files present at pinned SHA
|
||||
"incomplete", // verify found missing/broken files, or an update/repair didn't finish
|
||||
"failed", // last download failed
|
||||
"deleting",
|
||||
] as const;
|
||||
export type ModelStatus = (typeof MODEL_STATUSES)[number];
|
||||
|
||||
/** Is the repo (at the pinned commit) still on the Hub? Local files are never touched either way. */
|
||||
export const HUB_STATES = ["available", "repo_missing", "commit_missing"] as const;
|
||||
export type HubState = (typeof HUB_STATES)[number];
|
||||
|
||||
export type UpdateDiffFile = { path: string; size: number; oldSize?: number };
|
||||
export type UpdateDiff = {
|
||||
/** Commit the diff was computed against (the tracked revision's head on the Hub). */
|
||||
@@ -181,16 +189,6 @@ export const modelRevisions = sqliteTable(
|
||||
(t) => [index("model_revisions_model_idx").on(t.modelId)],
|
||||
);
|
||||
|
||||
export const MODEL_FILE_STATES = [
|
||||
"pending", // not downloaded yet / not checked
|
||||
"present", // exists with the expected size
|
||||
"missing",
|
||||
"size_mismatch",
|
||||
"hash_mismatch",
|
||||
"verified", // deep verify: hash matches
|
||||
] as const;
|
||||
export type ModelFileState = (typeof MODEL_FILE_STATES)[number];
|
||||
|
||||
/** All files in the repo at the pinned SHA. `selected` marks what we keep locally. */
|
||||
export const modelFiles = sqliteTable(
|
||||
"model_files",
|
||||
@@ -218,37 +216,6 @@ export const modelFiles = sqliteTable(
|
||||
// Jobs (executed by the worker)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const JOB_KINDS = ["download", "verify", "deep_verify", "delete"] as const;
|
||||
export type JobKind = (typeof JOB_KINDS)[number];
|
||||
|
||||
/** 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 = [
|
||||
"queued",
|
||||
"downloading",
|
||||
"verifying",
|
||||
"completed",
|
||||
"failed",
|
||||
"cancelled",
|
||||
"interrupted",
|
||||
] as const;
|
||||
export type JobState = (typeof JOB_STATES)[number];
|
||||
export const ACTIVE_JOB_STATES = ["downloading", "verifying"] as const satisfies JobState[];
|
||||
|
||||
export const JOB_ERROR_CODES = [
|
||||
"auth", // invalid/missing token
|
||||
"gated", // gated repo, access not granted
|
||||
"repo_not_found",
|
||||
"revision_not_found",
|
||||
"disk_full",
|
||||
"network",
|
||||
"size_mismatch", // finished but files don't match expected sizes
|
||||
"unknown",
|
||||
] as const;
|
||||
export type JobErrorCode = (typeof JOB_ERROR_CODES)[number];
|
||||
|
||||
export const jobs = sqliteTable(
|
||||
"jobs",
|
||||
{
|
||||
@@ -279,9 +246,6 @@ export const jobs = sqliteTable(
|
||||
(t) => [index("jobs_state_idx").on(t.state), index("jobs_model_idx").on(t.modelId)],
|
||||
);
|
||||
|
||||
export const JOB_FILE_STATES = ["pending", "downloading", "done", "failed"] as const;
|
||||
export type JobFileState = (typeof JOB_FILE_STATES)[number];
|
||||
|
||||
export const jobFiles = sqliteTable(
|
||||
"job_files",
|
||||
{
|
||||
@@ -299,9 +263,6 @@ export const jobFiles = sqliteTable(
|
||||
(t) => [primaryKey({ columns: [t.jobId, t.modelFileId] })],
|
||||
);
|
||||
|
||||
export const LOG_STREAMS = ["stdout", "stderr", "system"] as const;
|
||||
export type LogStream = (typeof LOG_STREAMS)[number];
|
||||
|
||||
export const jobLogs = sqliteTable(
|
||||
"job_logs",
|
||||
{
|
||||
@@ -425,9 +386,6 @@ export type DeploymentOptions = {
|
||||
// Endpoints: OpenAI-compatible servers to benchmark (llama.cpp, vLLM, SGLang, …), run elsewhere
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const ENDPOINT_ENGINES = ["llama.cpp", "vllm", "sglang", "ollama", "other"] as const;
|
||||
export type EndpointEngine = (typeof ENDPOINT_ENGINES)[number];
|
||||
|
||||
/**
|
||||
* What runs behind an endpoint, as the user describes it (Kaname can't see that machine). Copied into
|
||||
* every run; goes into BetterBench notes and launch80. Nothing here may identify the host.
|
||||
@@ -499,12 +457,6 @@ export const endpoints = sqliteTable(
|
||||
// Benchmarks (BetterBench runs against an endpoint)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const BENCHMARK_STATES = ["queued", "running", "completed", "failed", "cancelled"] as const;
|
||||
export type BenchmarkState = (typeof BENCHMARK_STATES)[number];
|
||||
|
||||
export const BENCHMARK_PHASES = ["decode", "prefill", "concurrency"] as const;
|
||||
export type BenchmarkPhase = (typeof BENCHMARK_PHASES)[number];
|
||||
|
||||
/** What a run measures. `passes`/`warmup` null: BetterBench's defaults (20 / 3), or 5 / 1 with quick. */
|
||||
export type BenchmarkSettings = {
|
||||
quick: boolean;
|
||||
@@ -518,9 +470,6 @@ export type BenchmarkSettings = {
|
||||
evalSections?: QualitySection[];
|
||||
};
|
||||
|
||||
export const QUALITY_SECTIONS = ["tools", "coding", "retrieval"] as const;
|
||||
export type QualitySection = (typeof QUALITY_SECTIONS)[number];
|
||||
|
||||
/** A quality eval's result: pass rates per section and the overall score (their mean), 0–100. */
|
||||
export type QualityResult = {
|
||||
/** The eval set's version; only results of the same version are comparable. */
|
||||
@@ -539,10 +488,6 @@ export type QualityResult = {
|
||||
config: { temperature: number; seed: number; thinking: boolean; contextTokens: number | null };
|
||||
};
|
||||
|
||||
/** run: BetterBench; ab: paired A/B; eval: Kaname's quality eval (tool calling, coding, retrieval). */
|
||||
export const BENCHMARK_KINDS = ["run", "ab", "eval"] as const;
|
||||
export type BenchmarkKind = (typeof BENCHMARK_KINDS)[number];
|
||||
|
||||
/** One side of a paired comparison, as BetterBench's paired_compare reports it. */
|
||||
export type PairedResult = {
|
||||
metric: string;
|
||||
@@ -792,14 +737,6 @@ export const benchmarkLogs = sqliteTable(
|
||||
// launch80 publications (double opt-in: a dry-run preview, then an explicit confirmation)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* preview: the worker runs `L80 betterbench --results … --dry-run --payload-out`; previewed: the
|
||||
* exact payload is ready to inspect; publish: confirmed by a user, the worker publishes it;
|
||||
* published / failed.
|
||||
*/
|
||||
export const PUBLICATION_STATES = ["preview", "previewed", "publish", "published", "failed"] as const;
|
||||
export type PublicationState = (typeof PUBLICATION_STATES)[number];
|
||||
|
||||
export const benchmarkPublications = sqliteTable(
|
||||
"benchmark_publications",
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user