diff --git a/.env.example b/.env.example index 4f44187..c446cd6 100644 --- a/.env.example +++ b/.env.example @@ -1,49 +1,64 @@ +# Kaname settings. Copy to .env next to compose.yaml and fill in the "Required" part; everything +# else has working defaults. Full reference: https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki/Configuration + # --------------------------------------------------------------------------- # Required # --------------------------------------------------------------------------- -# URL you open Kaname at in the browser. Your OIDC redirect URI is -# /api/auth/callback/pocket-id +# The address you open Kaname at in the browser (no trailing slash). The OIDC redirect URI to +# register with your provider is /api/auth/callback/pocket-id AUTH_URL=http://localhost:3000 -# Random secret for session cookies: `openssl rand -base64 33` -AUTH_SECRET= # OIDC provider (e.g. Pocket ID): authorization code flow with PKCE OIDC_ISSUER=https://auth.example.com OIDC_CLIENT_ID= OIDC_CLIENT_SECRET= -# Optional, comma-separated: only members of these groups (`groups` claim) can log in. -OIDC_ALLOWED_GROUPS= + +# --------------------------------------------------------------------------- +# Recommended +# --------------------------------------------------------------------------- # Hugging Face token: read-only is enough. Needed for gated/private repos, recommended anyway # (higher rate limits). Stays on the server; never sent to the browser or written to logs. HF_TOKEN= -# Optional: launch80.com publish token (comes with the launch80 Supporter role). Lets you publish a -# benchmark run as a public launch80 page, after a preview and an explicit confirmation. Stays on -# the server; never sent to the browser or written to logs. -L80_TOKEN= +# Optional, comma-separated: only members of these groups (`groups` claim) can log in. +OIDC_ALLOWED_GROUPS= # --------------------------------------------------------------------------- -# Folders on the Docker host (deploy/compose.yaml); both must be owned by uid 1000 +# Folders, port and image (deploy/compose.yaml) # --------------------------------------------------------------------------- -# SQLite database, shared by web and worker. Must be on local disk, not NFS. +# SQLite database and benchmark results. Must be on local disk, not NFS. KANAME_DATA_DIR=./data # Downloaded models. Can be a NAS share mounted on the host, e.g. /mnt/nas/models. KANAME_MODELS_DIR=./models # Host port of the web UI WEB_PORT=3000 -# Image tag to run, e.g. 0.4.0 (default: latest) +# The user Kaname runs as (and owns the files it writes). Set these to the owner of your models +# folder, e.g. the uid/gid of a NAS share (`ls -ln /mnt/nas/models`). New, empty folders are set up +# for this user automatically. +PUID=1000 +PGID=1000 +# Image tag, e.g. 0.16.0 (default: latest). KANAME_IMAGE replaces the registry/name if you build or +# mirror the image yourself. KANAME_VERSION= +KANAME_IMAGE= # --------------------------------------------------------------------------- -# Optional tuning +# Optional # --------------------------------------------------------------------------- +# Random secret for session cookies. Empty: generated on first start and kept in the data folder. +AUTH_SECRET= + +# launch80.com publish token (comes with the launch80 Supporter role). Lets you publish a benchmark +# run as a public launch80 page, after a preview and an explicit confirmation. Stays on the server. +L80_TOKEN= + MAX_CONCURRENT_DOWNLOADS=1 # How often the worker checks every model on the Hub (still there? newer commit?); 0 disables it UPDATE_CHECK_INTERVAL_HOURS=12 # 1 (default): hf downloads over plain HTTP, so progress can be measured from bytes on disk. -# 0: use Xet (chunk-level dedup on updates), but progress only advances in large jumps. +# 0: use Xet (chunk-level dedup on updates). Files over 50 GB always use Xet. HF_HUB_DISABLE_XET=1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 95d5059..4a17a8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,45 @@ All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); each milestone of step 1 (Hugging Face downloader) is released as a minor version. +## [0.16.0] - 2026-10-30 + +A new look, a search for everything (⌘K / Ctrl+K), removing single files, and an easier deployment +on another server: no `chown` before the first start, no `AUTH_SECRET` to generate. + +**Upgrading:** take the new `deploy/compose.yaml` (the sandbox now runs as `nobody` and starts after +the worker; `KANAME_IMAGE` is new). Existing `.env` files keep working; nothing else to do. + +### Added + +- **New look**: every main page opens with Michelangelo's *The Creation of Adam* as a dot matrix, + full width behind a floating menu and fading into the page; cards and tables are frosted glass on + top of it. Drawn from a small brightness grid in the code (the photo isn't shipped), in the theme's + colors for light and dark mode. +- **Library header**: a greeting with live stats: downloads with speed and time left, free space + on the models folder, library size, and updates or deletions on Hugging Face (each links to the + matching filter). **Add model** moved up there. +- **Search everything** with ⌘K / Ctrl+K (or Search in the menu): models, endpoints, benchmark + runs, tags, settings pages and actions (add a model or endpoint, scan the models folder, theme). +- The library table: search and filters as one toolbar, one heading style for all tables, and + **pagination** (10–100 rows per page). +- **Remove single files** from a model: the trash icon next to a downloaded file on the Files tab + deletes it (all parts of a split file) from disk and takes it out of the selection; the rest of + the model stays. A model's last file can't be removed this way (delete the model instead). +- `PUID`/`PGID`: the user Kaname runs as. The containers start as root only to prepare the folders: + the data folder is created and given to that user, the models folder only if it is empty (one + with files in it is never changed). Then they drop to that user. +- `AUTH_SECRET` is optional: without it, one is generated on first start and kept in the data folder. +- `KANAME_IMAGE` for a self-built or mirrored image; the README explains where the image is (public, + no login), its tags, and how to build it yourself. + +### Changed + +- The menu floats as two pills (navigation; search, worker status, account). The worker status is a + green dot while it's online; the account button is just the avatar. The logo is gone. +- Model pages: the Hugging Face link sits next to the name, Delete at the end of the tabs. +- The sandbox container runs as `nobody` (65534) instead of the app user. +- `.env.example` is grouped into required, recommended and optional settings. + ## [0.15.1] - 2026-10-27 ### Added diff --git a/Dockerfile b/Dockerfile index 3d52ff3..9aa39e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,7 +48,8 @@ RUN python -m venv /opt/hf \ && rm -rf /root/.cache /tmp/betterbench.tar.gz \ && useradd --uid 1000 --create-home --shell /usr/sbin/nologin app \ && mkdir -p /data /models /sandbox \ - && chown app:app /data /models /sandbox + && chown app:app /data /models \ + && chmod 0777 /sandbox ARG APP_VERSION=dev ENV PATH=/opt/hf/bin:$PATH \ @@ -70,8 +71,12 @@ COPY --from=build --chown=app:app /app/.next ./.next COPY --from=build --chown=app:app /app/dist ./dist COPY --from=build --chown=app:app /app/drizzle ./drizzle COPY --chmod=755 docker-entrypoint.sh docker-healthcheck.sh /usr/local/bin/ +# Next.js writes its cache at runtime, as whatever PUID the container runs as. +RUN mkdir -p .next/cache && chmod 0777 .next/cache -USER app +# Starts as root: docker-entrypoint.sh prepares /data (and an empty models folder) for PUID:PGID +# (default 1000:1000), then drops to that user. /sandbox is the exchange folder between the worker +# (PUID) and the sandbox (nobody); a fresh named volume copies its 0777. EXPOSE 3000 HEALTHCHECK --interval=15s --timeout=5s --start-period=30s --retries=3 CMD ["docker-healthcheck.sh"] ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/README.md b/README.md index fdc6f0b..31dafe5 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,8 @@ their speed and answer quality with [BetterBench](https://github.com/GGZ14/Bette ## Install -You need Docker with Compose and an OIDC provider (e.g. [Pocket ID](https://pocket-id.org)). +You need a Linux server with Docker and Compose, and an OIDC provider for the login (e.g. +[Pocket ID](https://pocket-id.org), Authelia, Authentik, Keycloak). **1. Get the compose file and the config template** @@ -33,31 +34,61 @@ curl -fsSLo .env https://git.linxweiler.xyz/pascallinxweiler/Kaname/raw/branch/m ``` **2. Create an OIDC client** in your identity provider with the redirect URI -`/api/auth/callback/pocket-id`, e.g. `http://192.168.1.10:3000/api/auth/callback/pocket-id`. -Request the `groups` scope if you want to restrict access by group. +`/api/auth/callback/pocket-id`, e.g. `http://192.168.1.10:3000/api/auth/callback/pocket-id` +(the path says `pocket-id` whatever provider you use). Request the `groups` scope if you want to +restrict access by group. -**3. Fill in `.env`.** At minimum: `AUTH_URL` (the address you open in the browser), `AUTH_SECRET` -(`openssl rand -base64 33`), `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`, and ideally a -read-only `HF_TOKEN`. +**3. Fill in `.env`:** `AUTH_URL` (the address you open in the browser), `OIDC_ISSUER`, +`OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`, and ideally a read-only `HF_TOKEN`. Everything else has +defaults. Models go to `./models` and the database to `./data` next to the compose file; point +`KANAME_MODELS_DIR` at another folder (e.g. a NAS share mounted on the host) if you like. -**4. Create the folders and start** +**4. Start** ```bash -mkdir -p data models && sudo chown 1000:1000 data models docker compose up -d ``` Open your `AUTH_URL`, sign in, click **Add model**. That's it. +Kaname creates and takes over `./data` itself, and an empty models folder too. It runs as uid/gid +1000 by default; if your models folder already holds files that belong to another user (common for +NAS shares), set `PUID`/`PGID` in `.env` to that owner (`ls -ln /path/to/models`). Kaname never +changes the ownership of a models folder that has files in it. + **Updating:** `docker compose pull && docker compose up -d`. To stay on a version, set e.g. -`KANAME_VERSION=0.4.0` in `.env`. The running version is shown next to the app name. +`KANAME_VERSION=0.16.0` in `.env`. The running version is shown next to the app name. Read the +[changelog](CHANGELOG.md) before jumping minor versions: it says when the compose file changed. + +### The image + +`git.linxweiler.xyz/pascallinxweiler/kaname` is public: no account or `docker login` needed. + +| Tag | What it is | +| --- | --- | +| `latest` | the newest release | +| `0.16` | the newest 0.16.x release | +| `0.16.0` | exactly that release | + +It is built for x86-64 (`linux/amd64`). One image serves all three services (`web`, `worker`, +`sandbox`); the compose file picks the role. To build it yourself (e.g. for ARM) from this +repository: + +```bash +git clone https://git.linxweiler.xyz/pascallinxweiler/Kaname.git && cd Kaname +docker build -t kaname:mine --build-arg APP_VERSION=$(git describe --tags) . +``` + +and set `KANAME_IMAGE=kaname` and `KANAME_VERSION=mine` in `.env`. ## Configuration -All settings live in `.env`. The four steps above cover the required ones; the **[configuration -reference in the wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki/Configuration)** -lists every option with defaults and examples (folders, ports, download tuning, OIDC groups, which -Hugging Face token to use). +All settings live in `.env`; [`.env.example`](.env.example) explains each one. The +**[configuration reference in the wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki/Configuration)** +lists every option with defaults and examples (folders, ports, user, download tuning, OIDC groups, +which Hugging Face token to use). Settings that change while Kaname runs (download speed limit, +which files are picked with a quant, file labels, tags, how often the models folder is scanned) are +in the web UI under Settings. Models end up in `///`, e.g. `models/unsloth/Qwen3-8B-GGUF/`. More guides are in the [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki). @@ -73,6 +104,8 @@ More guides are in the [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname are selected along with it; choose which kinds in Settings → Downloads. You can add tags right there. - **Search:** type anything: `unsloth qwen`, `q4_k_m`, `gemma`, `roleplay`. Every word has to match somewhere (repo, author, base model family, architecture, quant, tags). +- **Search everything:** ⌘K / Ctrl+K (or **Search** in the menu) jumps to any model, endpoint, + benchmark run, tag or settings page, and runs actions like Add model or switching the theme. - **Filter:** combine Author, Family, Quant, Tag and Status filters. The URL keeps the filters, so you can bookmark a view. - **Tags:** add or remove your own tags on a model's page; click a tag in the list to filter by it. @@ -81,12 +114,19 @@ More guides are in the [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname "Found in the models folder"; **Import** matches them with the Hub repo and verifies the files instead of downloading them again. See the [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki/Importing-existing-models). + Kaname looks for such folders every 2 minutes by default; in Settings → Downloads you can make + that hourly, daily, weekly or monthly at a time you pick, or manual only (**Scan now**), e.g. so + NAS disks can sleep. +- **Download more / remove files:** on a model's Files tab, **Download more** adds files of the repo + (another quant, the vision projector, …); the trash icon next to a downloaded file deletes it from + disk and takes it out of the selection, the rest of the model stays. - **Verify / repair:** Verify checks every file's presence and size, Deep verify hashes them against the Hub; Repair downloads only what's missing or broken. - **Updates:** Kaname checks the Hub regularly and shows which of your files a newer commit changes; updating is always your click. If a repo (or its pinned commit) disappears from Hugging Face, the model is flagged and your local copy is kept. -- **Delete:** removes the model and, if you want, its files from disk. +- **Delete:** removes the model and, if you want, its files from disk (files that aren't part of + the repo are kept). - **Jobs:** each download has a page with per-file progress and the full `hf` log. - **Endpoints:** add the URL (and API key, if any) of an OpenAI-compatible server under Endpoints. **Test connection** shows the models it serves and, where it tells, the engine, version and context. @@ -108,8 +148,9 @@ Three containers from the same image; web and worker share one SQLite database: measures progress from bytes on disk; runs benchmarks against endpoints (BetterBench, the quality eval). Only one worker runs at a time. - **sandbox:** runs the quality eval's coding answers (Python written by the model under test) with - no network, a read-only filesystem, no capabilities and small limits. It shares only an exchange - folder with the worker. Optional: without it the eval skips the coding section. + no network, a read-only filesystem, no capabilities, small limits and an unprivileged user. It + shares only an exchange folder with the worker and gets no settings or secrets. Optional: without + it the eval skips the coding section. Notes on the `hf` CLI (huggingface_hub 2.1.1, pinned in the image): diff --git a/compose.yaml b/compose.yaml index e0fcb39..5830bc4 100644 --- a/compose.yaml +++ b/compose.yaml @@ -29,11 +29,13 @@ services: volumes: [data:/data] # Runs the quality eval's coding answers (Python written by the model under test) with no - # network, a read-only root, no capabilities and small limits. It shares only the exchange folder - # with the worker. Optional: without it the quality eval skips the coding section. + # network, a read-only root, no capabilities, small limits and an unprivileged user. It shares only + # the exchange folder with the worker. Optional: without it the quality eval skips coding. sandbox: image: kaname:local command: sandbox + user: "65534:65534" + depends_on: [worker] network_mode: none read_only: true tmpfs: ["/tmp:size=64m,mode=1777"] diff --git a/deploy/compose.yaml b/deploy/compose.yaml index 5763cfa..4edda9f 100644 --- a/deploy/compose.yaml +++ b/deploy/compose.yaml @@ -1,35 +1,40 @@ # Kaname: put this file and a filled-in .env (from .env.example) in one folder, then -# mkdir -p data models && sudo chown 1000:1000 data models # docker compose up -d +# The data and models folders are created next to this file unless .env points elsewhere. name: kaname +x-kaname: &kaname + # Public image, no login needed. Pin a version with KANAME_VERSION=0.15.2 in .env. + image: ${KANAME_IMAGE:-git.linxweiler.xyz/pascallinxweiler/kaname}:${KANAME_VERSION:-latest} + restart: unless-stopped + services: + web: + <<: *kaname + env_file: .env + ports: ["${WEB_PORT:-3000}:3000"] + volumes: + - ${KANAME_DATA_DIR:-./data}:/data # SQLite database and results, shared with the worker (local disk, not NFS) + worker: - image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest} + <<: *kaname command: worker env_file: .env environment: SANDBOX_DIR: /sandbox - volumes: - - ${KANAME_DATA_DIR:-./data}:/data # SQLite DB, shared with web (local disk, not NFS) - - ${KANAME_MODELS_DIR:-./models}:/models # downloaded models (a host-mounted NAS share works) - - sandbox:/sandbox # exchange folder with the code sandbox - restart: unless-stopped - - web: - image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest} - env_file: .env - ports: ["${WEB_PORT:-3000}:3000"] volumes: - ${KANAME_DATA_DIR:-./data}:/data - restart: unless-stopped + - ${KANAME_MODELS_DIR:-./models}:/models # downloaded models (a NAS share mounted on the host works) + - sandbox:/sandbox # exchange folder with the code sandbox - # Runs the quality eval's coding answers (Python written by the model under test) with no - # network, a read-only root, no capabilities and small limits. It shares only the exchange folder - # with the worker. Optional: without it the quality eval skips the coding section. + # Runs the quality eval's coding answers (Python written by the model under test): no network, a + # read-only root, no capabilities, small limits, an unprivileged user, and only the exchange + # folder shared with the worker. No .env (no secrets). Optional: without it the eval skips coding. sandbox: - image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest} + <<: *kaname command: sandbox + user: "65534:65534" + depends_on: [worker] network_mode: none read_only: true tmpfs: ["/tmp:size=64m,mode=1777"] @@ -39,7 +44,6 @@ services: pids_limit: 64 cpus: 1 volumes: [sandbox:/sandbox] - restart: unless-stopped volumes: sandbox: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 760834a..87a73dc 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,12 +1,38 @@ #!/bin/sh # Usage: docker run [web|worker|sandbox|] (default: web) +# +# Started as root (the default), it prepares the folders, then drops to PUID:PGID (default +# 1000:1000) and runs as that user. Started as a user already (`user:` in compose), it skips that. set -e role="${1:-web}" +models="${MODELS_DIR:-/models}" + +if [ "$(id -u)" = 0 ] && [ "$role" != sandbox ]; then + uid="${PUID:-1000}" + gid="${PGID:-1000}" + as_user() { setpriv --reuid="$uid" --regid="$gid" --clear-groups "$@"; } + # /data is Kaname's own (database, results): take it over if a new or old mount belongs to someone else. + if [ -d /data ] && [ "$(stat -c %u:%g /data)" != "$uid:$gid" ]; then + echo "Taking over /data for $uid:$gid" + chown -R "$uid:$gid" /data + fi + # The models folder may be a NAS share with other files: only a new, empty one is taken over. + if [ "$role" = worker ] && [ -d "$models" ] && ! as_user sh -c 'touch "$1/.write-test" && rm -f "$1/.write-test"' _ "$models" 2>/dev/null; then + if [ -z "$(ls -A "$models")" ]; then + echo "Taking over the empty models folder for $uid:$gid" + chown "$uid:$gid" "$models" + fi + fi + # The exchange folder with the sandbox (which runs as nobody); volumes from before 0.15.2 are 0755. + if [ "$role" = worker ] && [ -d "${SANDBOX_DIR:-/sandbox}" ]; then chmod 0777 "${SANDBOX_DIR:-/sandbox}"; fi + export HOME=/home/app + exec setpriv --reuid="$uid" --regid="$gid" --clear-groups "$0" "$@" +fi require_writable() { if ! touch "$1/.write-test" 2>/dev/null; then - echo "ERROR: $1 is not writable by uid $(id -u). On the host: chown -R $(id -u):$(id -g) " >&2 + echo "ERROR: $1 is not writable by uid $(id -u). Give that user access on the host (e.g. chown -R $(id -u):$(id -g) ), or set PUID/PGID in .env to the folder's owner." >&2 exit 1 fi rm -f "$1/.write-test" @@ -16,7 +42,13 @@ case "$role" in web|worker) echo "$role" > /tmp/kaname-role require_writable /data - if [ "$role" = worker ]; then require_writable "${MODELS_DIR:-/models}"; fi + if [ "$role" = worker ]; then require_writable "$models"; fi + # Without AUTH_SECRET, one is generated on first start and kept in /data. + if [ "$role" = web ] && [ -z "$AUTH_SECRET" ]; then + [ -s /data/.auth-secret ] || (umask 077 && head -c 33 /dev/urandom | base64 > /data/.auth-secret) + AUTH_SECRET="$(cat /data/.auth-secret)" + export AUTH_SECRET + fi # web and worker usually start together; the lock makes sure only one runs the migrations. flock /data/.migrate.lock node dist/migrate.mjs ;; @@ -26,6 +58,11 @@ case "$role" in web) exec node_modules/.bin/next start ;; worker) exec node dist/worker.mjs ;; sandbox) + # It runs code written by the model under test: never as root (compose gives it `user:`). + if [ "$(id -u)" = 0 ]; then + echo "ERROR: the sandbox must not run as root; give the service a user, e.g. user: \"65534:65534\"." >&2 + exit 1 + fi echo sandbox > /tmp/kaname-role require_writable "${SANDBOX_DIR:-/sandbox}" exec node dist/sandbox.mjs diff --git a/package-lock.json b/package-lock.json index 44231b3..994562f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kaname", - "version": "0.15.1", + "version": "0.16.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kaname", - "version": "0.15.1", + "version": "0.16.0", "dependencies": { "@base-ui/react": "^1.8.0", "@libsql/client": "^0.18.0", diff --git a/package.json b/package.json index b88eca5..d41c5f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kaname", - "version": "0.15.1", + "version": "0.16.0", "private": true, "scripts": { "dev": "concurrently -k -n web,worker -c blue,magenta \"npm:dev:web\" \"npm:dev:worker\"", diff --git a/src/app/(app)/[org]/[repo]/delete-model-button.tsx b/src/app/(app)/[org]/[repo]/delete-model-button.tsx index 300e6bc..fc16c33 100644 --- a/src/app/(app)/[org]/[repo]/delete-model-button.tsx +++ b/src/app/(app)/[org]/[repo]/delete-model-button.tsx @@ -59,7 +59,7 @@ export function DeleteModelButton({ + ); +} + /** - * Library header with an "Add model" toggle that opens the lookup/selection form inline, and the - * folders in the models folder that aren't in the library yet, each with "Import". + * The lookup/selection form, opened inline by the "Add model" toggle, and the folders in the models + * folder that aren't in the library yet, each with "Import". */ export function AddModelPanel({ freeBytes, - defaultOpen, folders, + open, + setOpen, }: { freeBytes: number | null; - defaultOpen: boolean; folders: Folder[]; + open: boolean; + setOpen: (open: boolean) => void; }) { const router = useRouter(); - const [open, setOpen] = useState(defaultOpen); const [importing, setImporting] = useState(null); + // Closed from outside (the toggle in the hero): forget the folder being imported. + const [wasOpen, setWasOpen] = useState(open); + if (open !== wasOpen) { + setWasOpen(open); + if (!open) setImporting(null); + } const [scanning, setScanning] = useState(false); function close() { @@ -53,12 +69,6 @@ export function AddModelPanel({ return ( <> -
-

Library

- -
{open && ( x.va === x.vb); return ( -
+
BetterBench {ab.betterbenchVersion} · paired A/B · {ab.pairs} pairs diff --git a/src/app/(app)/benchmarks/[id]/benchmark-detail.tsx b/src/app/(app)/benchmarks/[id]/benchmark-detail.tsx index c073f51..4b9b338 100644 --- a/src/app/(app)/benchmarks/[id]/benchmark-detail.tsx +++ b/src/app/(app)/benchmarks/[id]/benchmark-detail.tsx @@ -31,10 +31,23 @@ import { Button, buttonVariants } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { reportSummary, weightsLabel } from "@/lib/benchmark-report"; -import { CONFIG_ROWS, describeSettings, engineName, isEndpointSnapshot, modelName, targetName } from "@/lib/benchmark-view"; +import { + CONFIG_ROWS, + describeSettings, + engineName, + isEndpointSnapshot, + modelName, + targetName, +} from "@/lib/benchmark-view"; import type { ListRow } from "../benchmark-list"; +import { PageHero } from "@/components/hero/page-hero"; import { RunMetaCard } from "@/components/run-meta"; -import { cancelBenchmark, deleteBenchmark, describeBenchmark, renameBenchmark } from "../actions"; +import { + cancelBenchmark, + deleteBenchmark, + describeBenchmark, + renameBenchmark, +} from "../actions"; import { AbReport } from "./ab-report"; import { QualityReport } from "./quality-report"; import { BenchmarkReport } from "./benchmark-report"; @@ -104,7 +117,9 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { // Runs from before 0.15 measured a deployment (gone now); newer ones an endpoint. const legacy = !isEndpointSnapshot(s); const endpointLink = (id: string | null, name: string) => - legacy ? name : id ? ( + legacy ? ( + name + ) : id ? ( {name} @@ -114,136 +129,141 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { const took = duration(r.startedAt, r.finishedAt, now); return ( -
- - -
-
-

- {r.label ?? (r.kind === "ab" && sB ? `${targetName(s)} vs ${targetName(sB)}` : targetName(s))} -

- {r.kind === "ab" && ( - - A/B - - )} - -
-

- {endpointLink(r.endpointId, targetName(s))} ·{" "} - {r.modelId ? ( - - {modelName(s)} - - ) : ( - modelName(s) - )}{" "} - · {engineName(s)} - {r.kind === "ab" && sB && ( - <> - {" "} - · B: {endpointLink(r.endpointBId, targetName(sB))} ({engineName(sB)}) - - )} -

-

- {r.kind === "eval" ? "Kaname" : "BetterBench"} ·{" "} - {r.kind === "ab" - ? `paired A/B, target ±${r.settings.mdePct ?? 1}%, up to ${r.settings.maxPairs ?? 200} pairs` - : describeSettings(r.settings)}{" "} - · created - {took && - ` · ${r.state === "running" ? "running for" : "took"} ${took}`} -

-
-
- {r.hasReport && ( - - - Full report - + + {r.label ?? + (r.kind === "ab" && sB + ? `${targetName(s)} vs ${targetName(sB)}` + : targetName(s))} + {r.kind === "ab" && ( + + A/B + + )} + + + } + description={ +
+

+ {endpointLink(r.endpointId, targetName(s))} ·{" "} + {r.modelId ? ( + + {modelName(s)} + + ) : ( + modelName(s) + )}{" "} + · {engineName(s)} + {r.kind === "ab" && sB && ( + <> + {" "} + · B: {endpointLink(r.endpointBId, targetName(sB))} ( + {engineName(sB)}) + )} - {r.state === "completed" && ( - - - {r.kind === "ab" ? "ab.json" : "results.json"} - - )} - {active ? ( +

+

+ {r.kind === "eval" ? "Kaname" : "BetterBench"} ·{" "} + {r.kind === "ab" + ? `paired A/B, target ±${r.settings.mdePct ?? 1}%, up to ${r.settings.maxPairs ?? 200} pairs` + : describeSettings(r.settings)}{" "} + · created + {took && + ` · ${r.state === "running" ? "running for" : "took"} ${took}`} +

+
+ } + actions={ + <> + {r.hasReport && ( + + + Full report + + )} + {r.state === "completed" && ( + + + {r.kind === "ab" ? "ab.json" : "results.json"} + + )} + {active ? ( + + ) : ( + r.endpointId && + (r.kind !== "ab" || r.endpointBId) && ( - ) : ( - r.endpointId && - (r.kind !== "ab" || r.endpointBId) && ( + ) + )} + + + } + > + + Delete + + + + Delete this benchmark? + + Its numbers, log, results.json and HTML report are removed. + + + + Cancel + { + if (await deleteBenchmark(r.id)) { + router.push("/benchmarks"); + router.refresh(); + } + }} > - - Run again - - ) - )} - - - } - > - - Delete - - - - Delete this benchmark? - - Its numbers, log, results.json and HTML report are removed. - - - - Cancel - { - if (await deleteBenchmark(r.id)) { - router.push("/benchmarks"); - router.refresh(); - } - }} - > - Delete - - - - -
-
-
- + Delete + + + + + + } + > {r.error && (
@@ -263,7 +283,13 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
- {r.kind === "ab" ? : r.kind === "eval" ? : } + {r.kind === "ab" ? ( + + ) : r.kind === "eval" ? ( + + ) : ( + + )} )} @@ -319,7 +347,8 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { } />

- Passed to BetterBench (when set before the run starts) and to the launch80 preview, together with the system summary. + Passed to BetterBench (when set before the run starts) and to + the launch80 preview, together with the system summary.

@@ -353,7 +382,9 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
)} {isEndpointSnapshot(s) && s.hardware.description && ( -

{s.hardware.description}

+

+ {s.hardware.description} +

)} {sum && (

@@ -366,6 +397,6 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { )}

-
+ ); } diff --git a/src/app/(app)/benchmarks/[id]/benchmark-report.tsx b/src/app/(app)/benchmarks/[id]/benchmark-report.tsx index 332238f..bc91bde 100644 --- a/src/app/(app)/benchmarks/[id]/benchmark-report.tsx +++ b/src/app/(app)/benchmarks/[id]/benchmark-report.tsx @@ -72,7 +72,7 @@ export function BenchmarkReport({ run }: { run: ListRow }) { ].filter(Boolean) as string[]; return ( -
+
BetterBench {sum.betterbenchVersion} · {date(sum.timestamp ?? run.startedAt)} diff --git a/src/app/(app)/benchmarks/compare/page.tsx b/src/app/(app)/benchmarks/compare/page.tsx index 9737054..0970b3d 100644 --- a/src/app/(app)/benchmarks/compare/page.tsx +++ b/src/app/(app)/benchmarks/compare/page.tsx @@ -1,6 +1,7 @@ import type { Metadata } from "next"; import Link from "next/link"; import { BenchmarkStateBadge } from "@/components/benchmark-state"; +import { PageHero } from "@/components/hero/page-hero"; import { Card } from "@/components/ui/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { getBenchmarks } from "@/lib/benchmarks"; @@ -117,15 +118,17 @@ export default async function ComparePage({ searchParams }: PageProps<"/benchmar const anyQuick = runs.some((r) => r.summary?.quick); return ( -
-
-

Compare benchmarks

-

- Differences are against the first run. Separate runs aren't paired in time, so differences below ~{NOISE_PCT}% are within normal noise. -

- {corpora.size > 1 &&

These runs used different prompt sets (corpus versions), so their numbers aren't comparable.

} - {anyQuick &&

Some runs are quick runs (5 passes); their numbers are rough.

} -
+ +

Differences are against the first run. Separate runs aren't paired in time, so differences below ~{NOISE_PCT}% are within normal noise.

+ {corpora.size > 1 &&

These runs used different prompt sets (corpus versions), so their numbers aren't comparable.

} + {anyQuick &&

Some runs are quick runs (5 passes); their numbers are rough.

} +
+ } + > @@ -193,7 +196,7 @@ export default async function ComparePage({ searchParams }: PageProps<"/benchmar
-
+ ); } diff --git a/src/app/(app)/benchmarks/page.tsx b/src/app/(app)/benchmarks/page.tsx index 51ed0a2..c87b532 100644 --- a/src/app/(app)/benchmarks/page.tsx +++ b/src/app/(app)/benchmarks/page.tsx @@ -2,6 +2,7 @@ import type { Metadata } from "next"; import Link from "next/link"; import { listBenchmarks } from "@/lib/benchmarks"; import { getModel } from "@/lib/library"; +import { PageHero } from "@/components/hero/page-hero"; import { BenchmarkList } from "./benchmark-list"; export const dynamic = "force-dynamic"; @@ -12,10 +13,11 @@ export default async function BenchmarksPage({ searchParams }: PageProps<"/bench const model = typeof modelId === "string" ? await getModel(modelId) : null; const rows = await listBenchmarks({ modelId: model?.model.id }); return ( -
-
-

Benchmarks

-

+ {model ? ( <> Runs of{" "} @@ -36,9 +38,10 @@ export default async function BenchmarksPage({ searchParams }: PageProps<"/bench . Start one from an endpoint; select runs to compare their settings and numbers. )} -

-
+ + } + > -
+ ); } diff --git a/src/app/(app)/endpoints/[id]/edit/page.tsx b/src/app/(app)/endpoints/[id]/edit/page.tsx index 8c09e2d..0ebabbe 100644 --- a/src/app/(app)/endpoints/[id]/edit/page.tsx +++ b/src/app/(app)/endpoints/[id]/edit/page.tsx @@ -1,4 +1,5 @@ import type { Metadata } from "next"; +import { PageHero } from "@/components/hero/page-hero"; import { notFound } from "next/navigation"; import { getEndpoint } from "@/lib/endpoints"; import { EndpointForm } from "../../endpoint-form"; @@ -10,9 +11,8 @@ export default async function EditEndpointPage({ params }: PageProps<"/endpoints const endpoint = await getEndpoint((await params).id); if (!endpoint) notFound(); return ( -
-

Edit {endpoint.name}

+ -
+ ); } diff --git a/src/app/(app)/endpoints/[id]/endpoint-header.tsx b/src/app/(app)/endpoints/[id]/endpoint-header.tsx index 2300278..31724d9 100644 --- a/src/app/(app)/endpoints/[id]/endpoint-header.tsx +++ b/src/app/(app)/endpoints/[id]/endpoint-header.tsx @@ -17,13 +17,21 @@ import { AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { Button, buttonVariants } from "@/components/ui/button"; -import { Card, CardContent } from "@/components/ui/card"; +import { PageHero } from "@/components/hero/page-hero"; import type { EndpointView } from "@/lib/endpoints"; import { ProbeResult } from "../endpoint-form"; import { EndpointStatus } from "../endpoint-status"; -/** Name, URL, connection test, edit and delete. */ -export function EndpointHeader({ endpoint, runCount }: { endpoint: EndpointView; runCount: number }) { +/** The page banner: name, URL, connection test, edit and delete; the page's content below it. */ +export function EndpointHeader({ + endpoint, + runCount, + children, +}: { + endpoint: EndpointView; + runCount: number; + children: React.ReactNode; +}) { const router = useRouter(); const [probe, setProbe] = useState(endpoint.probe); const [testing, setTesting] = useState(false); @@ -31,9 +39,14 @@ export function EndpointHeader({ endpoint, runCount }: { endpoint: EndpointView; async function test() { setTesting(true); try { - const res = await fetch(`/api/endpoints/${endpoint.id}/test`, { method: "POST" }); + const res = await fetch(`/api/endpoints/${endpoint.id}/test`, { + method: "POST", + }); const json = await res.json().catch(() => ({})); - if (!res.ok) return toast.error(json.error?.message ?? `Test failed (${res.status})`); + if (!res.ok) + return toast.error( + json.error?.message ?? `Test failed (${res.status})`, + ); setProbe(json); router.refresh(); } finally { @@ -42,60 +55,82 @@ export function EndpointHeader({ endpoint, runCount }: { endpoint: EndpointView; } async function remove() { - const res = await fetch(`/api/endpoints/${endpoint.id}`, { method: "DELETE" }); + const res = await fetch(`/api/endpoints/${endpoint.id}`, { + method: "DELETE", + }); if (!res.ok) { const json = await res.json().catch(() => ({})); - return toast.error(json.error?.message ?? `Could not delete (${res.status})`); + return toast.error( + json.error?.message ?? `Could not delete (${res.status})`, + ); } router.push("/endpoints"); router.refresh(); } return ( - - -
-
-

{endpoint.name}

-

- {endpoint.baseUrl} - {endpoint.hasApiKey ? " · API key set" : ""} -

-
-
- - - - - Edit - - - }> - - Delete - - - - Delete {endpoint.name}? - - The endpoint and its stored API key are removed.{runCount > 0 ? ` Its ${runCount} run${runCount === 1 ? "" : "s"} stay, with what they recorded.` : ""} - - - - Cancel - - Delete - - - - -
-
- {probe && } -
-
+ + {endpoint.baseUrl} + {endpoint.hasApiKey ? " · API key set" : ""} +
+ } + painting={{ view: 0.55, focus: [0.75, 0.35], anchor: [0.65, 0.35] }} + actions={ + <> + + + + + Edit + + + + } + > + + Delete + + + + Delete {endpoint.name}? + + The endpoint and its stored API key are removed. + {runCount > 0 + ? ` Its ${runCount} run${runCount === 1 ? "" : "s"} stay, with what they recorded.` + : ""} + + + + Cancel + + Delete + + + + + + } + > + {probe && } + {children} + ); } diff --git a/src/app/(app)/endpoints/[id]/page.tsx b/src/app/(app)/endpoints/[id]/page.tsx index d0a3298..008d7f6 100644 --- a/src/app/(app)/endpoints/[id]/page.tsx +++ b/src/app/(app)/endpoints/[id]/page.tsx @@ -35,8 +35,7 @@ export default async function EndpointPage({ params }: PageProps<"/endpoints/[id }); return ( -
- +
{endpoint.hardware.description && ( -

{endpoint.hardware.description}

+

{endpoint.hardware.description}

)}
-
+
); } diff --git a/src/app/(app)/endpoints/new/page.tsx b/src/app/(app)/endpoints/new/page.tsx index 083c5af..3d5728e 100644 --- a/src/app/(app)/endpoints/new/page.tsx +++ b/src/app/(app)/endpoints/new/page.tsx @@ -1,13 +1,13 @@ import type { Metadata } from "next"; +import { PageHero } from "@/components/hero/page-hero"; import { EndpointForm } from "../endpoint-form"; export const metadata: Metadata = { title: "New endpoint" }; export default function NewEndpointPage() { return ( -
-

New endpoint

+ -
+ ); } diff --git a/src/app/(app)/endpoints/page.tsx b/src/app/(app)/endpoints/page.tsx index b5ac34c..cacfba7 100644 --- a/src/app/(app)/endpoints/page.tsx +++ b/src/app/(app)/endpoints/page.tsx @@ -8,6 +8,7 @@ import { ENGINE_LABEL } from "@/lib/benchmark-meta"; import { headline } from "@/lib/benchmark-view"; import { listBenchmarks } from "@/lib/benchmarks"; import { listEndpoints } from "@/lib/endpoints"; +import { PageHero } from "@/components/hero/page-hero"; import { EndpointStatus } from "./endpoint-status"; export const dynamic = "force-dynamic"; @@ -26,17 +27,17 @@ export default async function EndpointsPage() { } return ( -
-
-
-

Endpoints

-

OpenAI-compatible servers to benchmark. They run elsewhere; Kaname only sends them requests.

-
+ Add endpoint -
+ } + > {endpoints.length === 0 ? ( @@ -89,6 +90,6 @@ export default async function EndpointsPage() { )} -
+ ); } diff --git a/src/app/(app)/facet-filter.tsx b/src/app/(app)/facet-filter.tsx index c0efebc..8f02c3d 100644 --- a/src/app/(app)/facet-filter.tsx +++ b/src/app/(app)/facet-filter.tsx @@ -1,15 +1,17 @@ "use client"; -import { ChevronDownIcon } from "lucide-react"; +import { CirclePlusIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, + DropdownMenuItem, + DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -/** Multi-select dropdown for one facet, with per-value counts. */ +/** Multi-select filter for one facet (a dashed pill in the table toolbar), with per-value counts. */ export function FacetFilter({ label, values, @@ -30,13 +32,26 @@ export function FacetFilter({ return ( } + render={ - )} -
+ ) + } + > @@ -144,6 +148,6 @@ export function JobLive({ initial }: { initial: JobSnapshot }) { - + ); } diff --git a/src/app/(app)/layout.tsx b/src/app/(app)/layout.tsx index 4db6039..5a6c48a 100644 --- a/src/app/(app)/layout.tsx +++ b/src/app/(app)/layout.tsx @@ -2,6 +2,7 @@ import Link from "next/link"; import { redirect } from "next/navigation"; import { auth, signOut } from "@/auth"; import { AppNav } from "@/components/app-nav"; +import { CommandPalette, CommandPaletteButton } from "@/components/command-palette"; import { LabelSettingsProvider } from "@/components/labels"; import { UserMenu } from "@/components/user-menu"; import { WorkerIndicator } from "@/components/worker-indicator"; @@ -20,16 +21,18 @@ export default async function AppLayout({ children }: LayoutProps<"/">) { return (
-
-
- - {/* eslint-disable-next-line @next/next/no-img-element */} - - Kaname - {process.env.APP_VERSION ?? "dev"} - - -
+ {/* Floating menu: two pills (name + navigation, status + account) over the page. */} +
+
+
+ + Kaname + {process.env.APP_VERSION ?? "dev"} + + +
+
+ ) {
+
{children}
diff --git a/src/app/(app)/library-top.tsx b/src/app/(app)/library-top.tsx new file mode 100644 index 0000000..d3b5a6a --- /dev/null +++ b/src/app/(app)/library-top.tsx @@ -0,0 +1,23 @@ +"use client"; + +import { useState } from "react"; +import { LibraryHero } from "@/components/hero/library-hero"; +import type { WorkerStatus } from "@/lib/worker-status"; +import { AddModelPanel, AddModelToggle } from "./add-model-panel"; + +type HeroProps = Omit, "action" | "initialWorker">; +type PanelProps = Omit, "open" | "setOpen">; + +/** The hero with the "Add model" toggle, and the form it opens below. */ +export function LibraryTop({ hero, panel, worker, defaultOpen }: { hero: HeroProps; panel: PanelProps; worker: WorkerStatus; defaultOpen: boolean }) { + const [open, setOpen] = useState(defaultOpen); + return ( + <> + setOpen(!open)} />} /> + {/* Above the hero, which runs on behind what follows. */} +
+ +
+ + ); +} diff --git a/src/app/(app)/library-view.tsx b/src/app/(app)/library-view.tsx index 87d0675..fb3abfd 100644 --- a/src/app/(app)/library-view.tsx +++ b/src/app/(app)/library-view.tsx @@ -1,6 +1,6 @@ "use client"; -import { SearchIcon, XIcon } from "lucide-react"; +import { ChevronLeftIcon, ChevronRightIcon, ChevronsLeftIcon, ChevronsRightIcon, SearchIcon, XIcon } from "lucide-react"; import Link from "next/link"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { useMemo, useState } from "react"; @@ -9,10 +9,10 @@ import { LocalTime } from "@/components/local-time"; import { HUB_STATE_LABEL, HubStateBadge } from "@/components/hub-state-badge"; import { MODEL_STATUS, ModelStatusBadge } from "@/components/model-status-badge"; import { TagBadge, TagDot } from "@/components/tag-badge"; -import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; -import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Card } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; +import { NativeSelect } from "@/components/ui/native-select"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { useLive } from "@/hooks/use-live"; import type { ModelStatus } from "@/lib/db/schema"; @@ -31,7 +31,8 @@ import { } from "@/lib/search"; import { FacetFilter } from "./facet-filter"; -const OPEN = ["pending_approval", "queued", "downloading", "verifying"]; +const OPEN = ["queued", "downloading", "verifying"]; +const PAGE_SIZES = [10, 25, 50, 100]; const FACET_LABEL: Record = { author: "Author", @@ -71,6 +72,8 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) { const pathname = usePathname(); const params = useSearchParams(); const [query, setQuery] = useState(() => params.get("q") ?? ""); + const [page, setPage] = useState(0); + const [pageSize, setPageSize] = useState(25); const [filters, setFilters] = useState(() => { const f = { ...EMPTY_FILTERS }; for (const facet of FACETS) f[facet] = params.getAll(facet); @@ -84,18 +87,22 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) { const qs = p.toString(); router.replace(qs ? `${pathname}?${qs}` : pathname, { scroll: false }); } + // A new search or filter starts on the first page. const updateQuery = (q: string) => { setQuery(q); + setPage(0); sync(q, filters); }; const updateFilter = (facet: Facet, values: string[]) => { const next = { ...filters, [facet]: values }; setFilters(next); + setPage(0); sync(query, next); }; const clearAll = () => { setQuery(""); setFilters(EMPTY_FILTERS); + setPage(0); sync("", EMPTY_FILTERS); }; @@ -103,6 +110,9 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) { const tagColors = useMemo(() => new Map(rows.flatMap((r) => r.tags.map((t) => [t.name, t.color] as const))), [rows]); const visible = rows.filter((_, i) => matchesQuery(searchable[i], query) && matchesFilters(searchable[i], filters)); const anyActive = query.trim() !== "" || FACETS.some((f) => filters[f].length > 0); + const pages = Math.max(1, Math.ceil(visible.length / pageSize)); + const current = Math.min(page, pages - 1); + const shown = visible.slice(current * pageSize, (current + 1) * pageSize); const { snapshot } = useLive(); const openJobs = new Map(); @@ -111,86 +121,76 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) { } return ( -
-
-
- - updateQuery(e.target.value)} - placeholder="Search repo, author, family, quant, tag…" - className="pl-8" - aria-label="Search models" - /> + // Glass: the painting from the hero shows through, blurred. + + {/* Toolbar: title, search and filters, part of the table. */} +
+
+

Models

+ + {anyActive ? `${visible.length} of ${rows.length}` : rows.length} + +
+
+ {/* Same height and border as the filter pills. */} +
+ + updateQuery(e.target.value)} + placeholder="Search models…" + className="h-8 bg-transparent pl-8 text-sm" + aria-label="Search models" + /> +
+ {FACETS.map((facet) => ( + updateFilter(facet, v)} + format={facet === "status" ? statusLabel : undefined} + marker={facet === "tag" ? (v) => : undefined} + /> + ))} + {anyActive && ( + + )}
- {FACETS.map((facet) => ( - updateFilter(facet, v)} - format={facet === "status" ? statusLabel : undefined} - marker={facet === "tag" ? (v) => : undefined} - /> - ))}
- {anyActive && ( -
- - {visible.length} of {rows.length} models - - {FACETS.flatMap((facet) => - filters[facet].map((v) => ( - - {facet === "tag" && } - {FACET_LABEL[facet]}: {facet === "status" ? statusLabel(v) : v} - - - )), - )} - -
- )} - {visible.length === 0 ? ( - - - No matching models - Try a different search or remove a filter. - - +
+

No matching models

+

Try a different search or remove a filter.

+
) : ( - + <> - Model + Model Selection Size Pinned Downloaded - Status + Status - {visible.map((r) => { + {shown.map((r) => { const job = openJobs.get(r.id); const base = r.baseModels[0]; return ( - - - {r.repoId} + + + {r.author}/ + {r.repoId.slice(r.author.length + 1)}
{base && base !== r.repoId && base {base}} @@ -206,19 +206,31 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) { ))}
- - {r.quants.length > 0 ? r.quants.join(", ") : `${r.fileCount} file${r.fileCount === 1 ? "" : "s"}`} + + {r.quants.length > 0 ? ( + + {r.quants.map((q) => ( + + {q} + + ))} + + ) : ( + + {r.fileCount} file{r.fileCount === 1 ? "" : "s"} + + )} {formatBytes(r.totalBytes)} - + {r.trackedRevision}@{shortSha(r.pinnedSha)} - + {job ? ( @@ -241,8 +253,50 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) { })}
-
+
+ + {current * pageSize + 1}–{Math.min(visible.length, (current + 1) * pageSize)} of {visible.length} + +
+ + + Page {current + 1} of {pages} + +
+ + + + +
+
+
+ )} -
+ ); } diff --git a/src/app/(app)/page.tsx b/src/app/(app)/page.tsx index 8d8757f..1cfb644 100644 --- a/src/app/(app)/page.tsx +++ b/src/app/(app)/page.tsx @@ -1,21 +1,33 @@ +import { auth } from "@/auth"; import { listLibrary } from "@/lib/library"; import { listLocalFolders } from "@/lib/local-folders"; import { getWorkerStatus } from "@/lib/worker-status"; -import { AddModelPanel } from "./add-model-panel"; +import { LibraryTop } from "./library-top"; import { LibraryView } from "./library-view"; export const dynamic = "force-dynamic"; -export default async function LibraryPage() { - const [rows, worker, folders] = await Promise.all([listLibrary(), getWorkerStatus(), listLocalFolders()]); +export default async function LibraryPage({ searchParams }: PageProps<"/">) { + const [rows, worker, folders, session] = await Promise.all([listLibrary(), getWorkerStatus(), listLocalFolders(), auth()]); return (
- {/* Opens by default while the library is empty and there's nothing on disk to import. */} - ({ path: f.path, commit: f.commit, files: f.files, fileCount: f.fileCount, totalBytes: f.totalBytes }))} + {/* The form opens by default while the library is empty and there's nothing on disk to import, + and with ?add=1 (the ⌘K palette's "Add model"). */} + s + r.presentBytes, 0), + updates: rows.filter((r) => r.updateAvailable && (r.hubState === "available" || !r.hubState)).length, + goneFromHub: rows.filter((r) => r.hubState === "repo_missing" || r.hubState === "commit_missing").length, + }} + panel={{ + freeBytes: worker.online ? worker.modelsDirFreeBytes : null, + folders: folders.map((f) => ({ path: f.path, commit: f.commit, files: f.files, fileCount: f.fileCount, totalBytes: f.totalBytes })), + }} /> {rows.length > 0 && }
diff --git a/src/app/(app)/settings/downloads/scan-settings.tsx b/src/app/(app)/settings/downloads/scan-settings.tsx index fb6a9bf..087301c 100644 --- a/src/app/(app)/settings/downloads/scan-settings.tsx +++ b/src/app/(app)/settings/downloads/scan-settings.tsx @@ -65,7 +65,7 @@ export function ScanSettings({ initial }: { initial: ScanStatus }) { } return ( - + Models folder scan diff --git a/src/app/(app)/settings/layout.tsx b/src/app/(app)/settings/layout.tsx index 18798a6..78085f7 100644 --- a/src/app/(app)/settings/layout.tsx +++ b/src/app/(app)/settings/layout.tsx @@ -1,4 +1,5 @@ import { DownloadIcon, TagIcon, TagsIcon } from "lucide-react"; +import { PageHero } from "@/components/hero/page-hero"; import { SettingsNav } from "./settings-nav"; const SECTIONS = [ @@ -9,12 +10,15 @@ const SECTIONS = [ export default function SettingsLayout({ children }: LayoutProps<"/settings">) { return ( -
-

Settings

+
{children}
-
+ ); } diff --git a/src/app/(app)/settings/settings-nav.tsx b/src/app/(app)/settings/settings-nav.tsx index ce1433a..74bb0ba 100644 --- a/src/app/(app)/settings/settings-nav.tsx +++ b/src/app/(app)/settings/settings-nav.tsx @@ -7,7 +7,7 @@ import { cn } from "@/lib/utils"; export function SettingsNav({ sections }: { sections: { href: string; label: string; icon: React.ReactNode }[] }) { const pathname = usePathname(); return ( -