Files
GPU-Node/dashboard
Z User 12fb97314b fix: comfyui mount uses HOST_PROJECT_PATH + add CivitAI download support
## 1. ComfyUI mount fix

### Problem
When the dashboard called `docker compose up -d comfyui`, the comfyui
service's volume mounts used ${COMFY_BASE_HOST:-./gpu/comfy} and
${COMFY_RUN_HOST:-./comfyui/run}. Without explicit env overrides, compose
resolved these to './gpu/comfy' relative to the CWD of the dashboard
container (= /project inside the container). Docker daemon on the host
tried to mount /project/gpu/comfy — but /project only exists inside the
dashboard container, not on the host.

The result: comfyui mounted to non-existent paths on the host, all
models missing.

### Fix
`startService('comfyui')` now explicitly passes the same env vars that
`gpuctl start comfy` does, mirroring `ssh/scripts/comfy.sh`:
  - COMFY_BASE_HOST=$HOST_PROJECT_PATH/gpu/comfy
  - COMFY_RUN_HOST=$HOST_PROJECT_PATH/comfyui/run

These are passed as extra env to `runCompose`, which forwards them to
the compose subprocess. Compose then resolves the volume mounts to the
real host path.

## 2. CivitAI download support

### Why
CivitAI URLs are special:
- `https://civitai.com/models/12345` is a model PAGE (HTML), not the
  file. curl would download the HTML page instead of the .gguf.
- The actual file is at `https://civitai.com/api/download/models/12345`
  which returns a 302 redirect to a signed Cloudflare URL.
- Downloads require an API token: `?token=XXX`. Without it, NSFW /
  gated models fail with 401.
- `civitai.red` is a mirror — it doesn't accept API requests the same
  way.

### Fix

#### Settings storage

New `DashboardSettings` interface with `civitaiToken: string`. Persisted
to `gpu/dashboard/settings.json` (separate from the llama config —
download settings shouldn't be part of a llama preset).

- `loadSettings()` / `saveSettings()` in `dashboard/src/lib/downloads.ts`
- Cache like the .env loader (read once per process lifetime)

#### URL transformation

`prepareCivitaiUrl(rawUrl, token)` — handles all CivitAI URL shapes:

  1. `https://civitai.com/models/12345` (model page) → converts to
     `https://civitai.com/api/download/models/12345` (preserves any
     `?modelVersionId=...` query param)
  2. `https://civitai.com/api/download/models/12345` → appends
     `?token=XXX` if missing
  3. `https://civitai.red/models/12345` → normalizes host to civitai.com
     (mirror doesn't accept API requests the same way)
  4. Non-CivitAI URLs (HuggingFace, GitHub releases, etc.) → passed
     through unchanged

Returns `{ url, note }` where note explains what we did (e.g.
'converted model page → API download URL, added API token').

#### startModelDownload integration

`startModelDownload()` now:
1. Loads settings (to get the token)
2. Calls `prepareCivitaiUrl()` on the input URL
3. Uses the transformed URL for curl
4. Records `originalUrl` and `urlNote` on the job object (shown in UI)

#### API routes (new)

`/api/settings`:
- `GET` — returns the persisted settings (civitai token etc)
- `PUT` — updates settings (body: `{ civitaiToken: '...' }`)
- `POST { action: 'preview-url', url: '...' }` — returns what the URL
  would be transformed into, without starting a download. Used by the
  frontend for live URL preview as the user types.

#### Frontend

- **Settings UI** in the Models tab: 'CivitAI token' button (with badge
  showing 'set' / 'empty'). Click to expand a form with password input,
  Save / Clear buttons, and a link to https://civitai.com/user/account
  to get a token.

- **URL preview**: as the user types in the download URL field, a
  debounced call to `POST /api/settings {action:'preview-url'}` runs.
  If the URL will be transformed (e.g. civitai.com/models/12345 →
  civitai.com/api/download/models/12345?token=...), a preview card
  appears below the input showing the transformed URL + note.

- **DownloadJobRow**: shows `originalUrl` (struck through) → `url`
  (the actual URL curled), plus the `urlNote` as italic text. So the
  user can see what happened to their pasted URL.

## Verification

- `npm run build` — OK, all 26 routes (1 new /api/settings route)
- `bash dashboard/validate-build.sh` — all 8 COPY sources ✓, standalone ✓

## After deploy

```sh
git pull && sh build.sh
docker compose up -d --force-recreate dashboard
```

For ComfyUI:
1. Click 'Start Comfy' (or Start button in System tab → comfyui row)
2. Check `docker inspect <comfyui-container> | grep Mounts` — should
   show $HOST_PROJECT_PATH/gpu/comfy and $HOST_PROJECT_PATH/comfyui/run

For CivitAI:
1. Open Models tab → 'CivitAI token' button → paste your token from
   https://civitai.com/user/account → API Keys → Save
2. Paste any CivitAI URL (model page or API download URL) in the URL field
3. Watch the URL preview card show the transformed URL
4. Click Download — file fetches with token auth

## Files changed

- dashboard/src/lib/docker.ts — added DASHBOARD_SETTINGS_PATH export,
  startService() now passes COMFY_BASE_HOST / COMFY_RUN_HOST for comfyui
- dashboard/src/lib/downloads.ts — new DashboardSettings interface,
  loadSettings / saveSettings, prepareCivitaiUrl, startModelDownload
  integrates URL transformation
- dashboard/src/app/api/settings/route.ts — new (GET/PUT/POST preview)
- dashboard/src/app/page.tsx — settings state, civitai token UI,
  URL preview, DownloadJobRow shows originalUrl + urlNote
2026-10-24 01:53:37 +00:00
..

GPU-Node Dashboard

A small Next.js web dashboard for managing the llama.cpp instance running on the GPU node. Replaces the need to manually edit .env and call gpuctl over SSH.

Features

  • Status overview — live view of all containers (llama, ssh, comfyui, etc.) for the current node instance, with health check + auto-refresh.
  • Models list — scans gpu/llama_models/*.gguf and shows sizes / modified time; click "Use" to switch the active model in the launch config.
  • Launch config — structured form for --ctx-size, --parallel, --n-gpu-layers, --threads, --batch-size, --context-overflow, speculative decoding (--spec-type, --model-draft, --spec-draft-n-max), and a free-form extra args textarea for anything else.
  • Presets — save named configurations and reload them with one click.
  • Start / Restart / Stop / Remove llama container via docker compose.
  • Live logs — streaming docker logs -f with color-coded output.
  • GPU status — runs nvidia-smi via docker exec on the llama container (or falls back to docker compose run --rm gpu-test nvidia-smi ...).
  • Auto-writes .env — every "Apply / Start" persists the current LLAMA_MODEL and LLAMA_EXTRA_ARGS back to .env, so the existing workflow keeps working.

How it integrates

The dashboard runs as a new dashboard service in compose.yaml. It mounts:

  • /var/run/docker.sock → can run docker compose and docker ps commands
  • The host project path (read/write so it can edit .env and save presets)

On every "Start / Apply" action, the dashboard:

  1. Persists the structured config to gpu/dashboard-config.json.
  2. Writes LLAMA_MODEL and LLAMA_EXTRA_ARGS to .env (preserving other vars).
  3. Runs docker compose --profile llama up -d --force-recreate llama with the same env vars inlined — identical to gpuctl start llama <model> <args>.

The dashboard is exposed via Tailscale serve on port 8090.

Local development

cd dashboard
npm install
npm run dev

You will need to set the same env vars the container would set:

export HOST_PROJECT_PATH=/path/to/GPU-Node   # absolute path on host
export PROJECT_DIR=/path/to/GPU-Node         # path mounted inside the dev shell
export NODE_INSTANCE=gpu-node

You also need docker and docker compose available on your $PATH, and the current user must be in a group that can access /var/run/docker.sock.

Building the image

docker build -t gpu-node-dashboard ./dashboard

Or via the project's build.sh after this PR merges — that script will be extended to build the dashboard image as well.

Tech stack

  • Next.js 16 (standalone output, App Router)
  • React 19 + TypeScript 5
  • Tailwind CSS 4 + shadcn-style components
  • Radix UI primitives (select, tabs, switch, label)
  • lucide-react icons