## Problem
'цивитай в comfy models нужен скорее' — the CivitAI URL transformation
(model page → API download URL, token append) was only applied to llama
model downloads via `/api/models/download`. ComfyUI model downloads via
`/api/comfy/models/add` just passed the raw URL straight to
model-worker, so CivitAI model page URLs would download HTML instead of
the actual file, and gated/NSFW models would 401 without a token.
## Fix
### Backend
#### `dashboard/src/lib/docker.ts` — addComfyModel()
Now applies the same `prepareCivitaiUrl()` transformation as
`startModelDownload()`:
1. Loads settings (to get the saved civitaiToken)
2. Calls `prepareCivitaiUrl(rawUrl, token)`:
- civitai.com/models/12345 → civitai.com/api/download/models/12345
- civitai.red/... → normalize host to civitai.com
- append ?token=XXX if missing
3. Passes the transformed URL to `modelWorkerExec('add', url, type)`
4. Returns `originalUrl`, `transformedUrl`, `urlNote` in the response
so the frontend can show what happened
Uses lazy `await import('./downloads')` to avoid a circular import
between docker.ts (which exports paths) and downloads.ts (which imports
them).
#### `dashboard/src/app/api/comfy/models/add/route.ts`
Returns the transformation metadata (`originalUrl`, `transformedUrl`,
`urlNote`) in the JSON response.
### Frontend
#### `dashboard/src/app/page.tsx`
- New state: `comfyUrlPreview` — separate from `urlPreview` (which is
for the llama Models tab) so switching tabs doesn't mix them up.
- New debounced effect: watches `comfyAddUrl` and calls
`POST /api/settings {action:'preview-url'}` to get the transformed URL.
- `handleComfyAddModel()` now reads `urlNote` and `transformedUrl`
from the response and includes them in the toast message (multi-line)
so the user sees what happened to their pasted URL.
- `<ComfyTab>` now accepts `civitaiToken`, `onSaveCivitaiToken`, and
`urlPreview` props.
- ComfyTab 'Queue Download' section:
- 'CivitAI token' button (with badge 'set' / 'empty') in the header —
opens a settings panel with password input, Save/Clear buttons, and
a link to https://civitai.com/user/account.
- The settings panel notes that the token is shared with the
llama-models downloader (same settings.json).
- URL input placeholder updated to show CivitAI URLs are accepted.
- Enter key in the URL field queues the download (no need to click
Queue button).
- URL preview card appears below the input when the URL will be
transformed (e.g. civitai.com/models/12345 →
civitai.com/api/download/models/12345?token=...), showing the
transformed URL + note.
## How it works end-to-end
1. User opens Comfy tab → 'CivitAI token' button → pastes token → Save
(stored in `gpu/dashboard/settings.json`, shared with llama downloader)
2. User pastes `https://civitai.com/models/12345` in URL field
3. URL preview card shows:
```
[CivitAI] converted model page → API download URL, added API token
https://civitai.com/api/download/models/12345?token=XXX...
```
4. User selects type (checkpoints/loras/etc) and clicks Queue (or Enter)
5. Backend `addComfyModel()` transforms URL → calls
`docker exec model-worker python3 /app/worker.py add <transformed-url> <type>`
6. Worker downloads the file with token auth → saves to
`gpu/comfy/models/<type>/<filename>`
7. Toast shows: 'Queued: checkpoints\nconverted model page → API download
URL, added API token\n→ https://civitai.com/api/download/models/...'
## Verification
- `npm run build` — OK, 26 routes
- `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
```
Open Comfy tab → 'CivitAI token' button → paste token → Save.
Paste any CivitAI URL (model page or API download URL) → see preview →
Queue. The model fetches with token auth and lands in the right type
subdirectory.
## Files changed
- dashboard/src/lib/docker.ts — addComfyModel() applies prepareCivitaiUrl
- dashboard/src/app/api/comfy/models/add/route.ts — returns transformation metadata
- dashboard/src/app/page.tsx — comfyUrlPreview state, debounced preview
effect, handleComfyAddModel shows transformation in toast, ComfyTab
gets civitai token UI + URL preview + Enter-to-queue
Description
No description provided
Languages
TypeScript
82.5%
Python
8.6%
Shell
6.4%
Dockerfile
0.9%
CSS
0.9%
Other
0.7%