FUCC UI (fucc-controller) — local tool for managing ComfyUI builds
  • Python 65.9%
  • JavaScript 24.2%
  • CSS 6.2%
  • HTML 2.5%
  • Batchfile 0.7%
  • Other 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
ComfyUI Controller Dev 2cbefc9aaa
Some checks are pending
release / build (push) Waiting to run
ci: release workflow — build archive and attach it to the tag release
2026-12-06 21:35:55 +04:00
.forgejo/workflows ci: release workflow — build archive and attach it to the tag release 2026-12-06 21:35:55 +04:00
app feat(0.19.15): borderless tinted cards (blue global / purple model / yellow custom nodes) with tab-style segmented radii in single-column stacks; plain style for the cn '+' button; fix the add-model dialog losing its sub-headings 2026-12-06 15:20:57 +04:00
public feat(0.19.15): borderless tinted cards (blue global / purple model / yellow custom nodes) with tab-style segmented radii in single-column stacks; plain style for the cn '+' button; fix the add-model dialog losing its sub-headings 2026-12-06 15:20:57 +04:00
references v0.6.0: Sage Attention installation 2026-10-31 21:06:29 +04:00
tests fix(0.19.8): standalone sage/ffmpeg add-on clears the stage the pipeline progress setter re-stamps at 99% 2026-12-06 14:29:12 +04:00
tools/7zip v0.6.2: bundle 7-Zip CLI so portable builds extract with no system 7-Zip 2026-11-13 17:51:32 +04:00
.gitignore Add build.sh: redistribution archive build/comfyui/controller.zip 2026-10-28 22:46:44 +04:00
build.sh perf(0.15.7): serve downscaled WebP thumbnails for hero/bg and tiles 2026-11-20 22:38:50 +04:00
README.md feat(0.19.10): drop the git badge; hide the update button for nodes that are not git clones 2026-12-06 14:41:35 +04:00
requirements.txt perf(0.15.7): serve downscaled WebP thumbnails for hero/bg and tiles 2026-11-20 22:38:50 +04:00
run.bat UI/API alignment fixes, lifecycle + cancel tests, verbose flag, README for logging and server lifecycle 2026-10-29 15:57:48 +04:00
run.py fix(0.15.7): include PIL in run.py dep probe so Pillow installs on update 2026-11-20 22:52:41 +04:00
run.sh Add Linux/macOS launcher (run.sh) and document running on Linux 2026-10-28 21:42:36 +04:00

FUCC UI (fucc-controller)

Note: this documentation was generated with AI/LLM and should be reviewed before use.

A local, cross-platform (production target: Windows) tool for managing ComfyUI (and llama.cpp) builds through a web UI. The application presents itself as FUCC UI; the command and repository name is fucc-controller.

Features:

  • Build cards. Create a card and pick a mode in the modal:
    • Portable build (default) — a Windows ComfyUI build from the Comfy-Org/ComfyUI releases (.7z, embedded Python included). Pick a release and a GPU variant (default: ComfyUI_windows_portable_nvidia.7z). The archive is downloaded into the build's own folder and extracted. Off Windows the modal says so up front — a plaque in the footer, left of Отмена/Создать (from /api/config → os_nt): installing is allowed, starting such a card is Windows-only.
    • From Git — the ComfyUI repository is fetched as a source archive at a chosen ref (branch / tag / commit; plain git clone for hosts that serve no archive). This is a reproducible snapshot; models and custom_nodes live inside the build folder like a regular install.
  • Sage Attention. The create modal can install it right after the build (Установить Sage Attention): a Windows portable card gets triton-windows (+ its include//libs/), the sageattention wheel, SpargeAttn and the ComfyUI-RadialAttn node in custom_nodes; a git card gets pip install sageattention --extra-index-url https://comfy-org.github.io/wheels into its own venv; if the prebuilt wheel's _fused extension does not match the venv's torch (undefined-symbol import error), the controller uninstalls it and rebuilds from source (--no-binary) against the installed torch. Installing is one job with its own ring stage (sage), it is not a transaction — the card's Изменить offers it once and there is no uninstall. The Задействовать switch there is the --use-sage-attention launch flag itself: it is dead until Sage Attention is installed, and toggling it adds/removes that flag in the card's own arguments (kept out of the Параметры запуска text). Installing needs an installed card (a working interpreter/venv) that is stopped: the check keys on venv_ready, not on the transient idle status, so a card that was started and stopped (stopped) or is running (running) is handled correctly — a running card is refused with "stop this card first" (Sage rewrites the card's Python environment), only a never-installed card is told to install the build first.
  • Floating modal title bars. Every modal dialog carries its title in a bar that floats above the window body; the primary actions (Отмена / Сохранить / ОК / Подтвердить) sit at the right end of that bar, dialogs without actions show an X instead. The window body itself has no header.
  • Custom nodes manager. A button on the ComfyUI build page (under Открыть папку сборки; hidden on llama.cpp cards) opens a modal that scans the active ComfyUI card's custom_nodes/ folder — every folder directly inside it is a node, and the folder name is the package name shown in the list (excluded: __pycache__ and other names from FUCC_CN_SKIP, plus hidden folders). Each row has Удалить (red trash, with a confirm); git clones additionally get Обновить (a spinning-arrow icon; git pull --ff-only — non-clone nodes have no origin to pull from, so their update button is hidden). Добавить custom nodes opens a nested modal that takes a git URL and git clones it into custom_nodes/ (the same host/scheme allowlist as git builds; the folder name is the repo name). Mutating actions require a stopped card.
  • Build control. Activate, start / stop ComfyUI (from the portable build's embedded Python or from the git build's venv), update, rename (the card's folder is renamed with it), delete. Installation can be cancelled mid-way (red X on the progress bar); the card then offers Установить and reinstalls on that click.
  • Card layout. The card shows the title, the run button and — only when there is something to do — one text action (Обновить for a newer release, Установить for a card whose install was cancelled). No status text: the spotlight in the card is green when the build can be started, red while it runs, neutral otherwise. The top-right corner holds only the kebab (the actions menu: change / duplicate / rename / delete). A dedicated gear below the progress bar opens the build's page (the card-click switch still decides what a click on the card body itself does: open ComfyUI when running, or the build page). The same build page the gear reaches is also what the card's click can open.
  • Error block. When an install fails, the build page shows which step broke (Сбой на шаге «распаковка» · …) alongside the message, so the card reads as "broken at download / extract / prepare"; the grid card only turns red. A build that did not finish offers Переустановить (resume) instead of Запустить, and re-clicking it continues from the last completed step instead of redownloading.
  • Start / stop semantics. Start runs on a fixed port if one is saved on the card, otherwise the first free port is chosen (the UI shows the number it plans to use). The port is edited in the card's Изменить dialog. A start is complete only when ComfyUI logs To see the GUI go to: http://127.0.0.1:<port> — until then the card is starting (white ring), and a process that dies before that line fails with the tail of its log. While a start is not complete, the stop control on the card's own page is a hard kill (kills the process tree immediately); once the instance is up it becomes a graceful stop (waits up to 10 s for ComfyUI to shut down, then kills the tree); the card menu on the grid always stops gracefully.
  • Server lifecycle. Ctrl+C in the console, or the Остановить сервер button in the settings modal, stops every ComfyUI instance the controller started and exits. The browser opens the UI automatically on start; disable with --no-browser (or FUCC_NO_BROWSER=1).
  • Defaults for empty fields. An empty name becomes build-<number>; a git build with empty URL/ref uses https://github.com/Comfy-Org/ComfyUI.git at master.
  • Two program types. A card is either a ComfyUI build or a llama.cpp build (program column). The main screen groups cards into collapsible program categories (ComfyUI first, then llama.cpp); each category header shows the program logo, a live count and a chevron that folds the group (the choice is remembered). A card's program is chosen in the Новая сборка modal. llama.cpp cards download the latest CUDA nightly release, are managed through the same job/stage/run machinery, and expose llama-specific version info (b#####) instead of a ComfyUI release tag. ComfyUI-only features (the result gallery, Sage Attention) are hidden for llama cards and refused by the backend. See Program types below.
  • Result gallery. Recursive scan of output/ (subfolders + images + video) viewed directly in the web UI. Tiles use a justified-rows layout: a flexbox where each tile grows by its own aspect ratio, so widths follow the file and every row is a fixed height (--tile-h: 220px desktop, 160px on narrow screens) filled edge-to-edge. The scan reads each image's width/height from its header (Pillow, cheap) into the gallery table, so the browser reserves the tile shape before the image loads (no reflow); unknown dimensions (videos, pre-migration rows) fall back to square. Tiles load downscaled WebP; the lightbox and a pinned hero load the full-resolution original. Thumbnails are generated on demand and kept only in memory (nothing is written to disk, for privacy; the LRU is capped by FUCC_THUMB_CACHE_MB, default 64 MB), so a tile shows a plain placeholder skeleton until its image arrives and then fades in. Settings → Интерфейс → Замостить плитки галереи (on by default, browser-stored as fucc.mosaicTiles) toggles this; when off, tiles become uniform squares in a responsive grid capped at five per row (an 18% track minimum, so four-to-five fit on any normal width and it never exceeds five on wide screens). A tile's filename shows on hover (on a small solid chip) and fades out 2s after the pointer leaves; clicking a tile opens a full preview (lightbox) with a bottom control bar — назад/вперёд, на весь экран, открыть папку, удалить файл, закрыть. The file name shows in a header above the image (dark chip, 25px, name only). The per-tile kebab menu keeps only Открыть папку and Удалить файл. Fullscreen covers the whole overlay, so назад/ вперёд and the fullscreen toggle (which flips to Выйти из полноэкранного) stay available inside fullscreen; the name header is hidden there.
  • Config file editor (llama.cpp cards). The header is a Блоки / Редактор tab toggle over the build's config/models.ini, and both tabs share one recognizer for the file (public/llama_ini.js): it reads the [section] blocks and their key = value parameters, treats [*] as the single shared-settings block, and rewrites a block in place so the rest of the file stays byte-identical.
    • Редактор is the raw text editor; section headers are highlighted as you type — [*] in blue, each model block in purple.
    • Блоки shows a stack of cards: Общие настройки (the [*] section, name only), one card per model block (name plus its ctx-size), and a dashed + Добавить модель card. Clicking a card opens the block editor: rows of parameter = value inputs (each with an X to drop the row), + Добавить параметр, and a block name field (models only). Импорт opens a paste box: pasted text is broken into parameter rows (a pasted [name] header names a new block) for the user to review before saving. Удалить (with a confirmation) removes the block from the file; Сохранить writes it back through the same PUT /api/builds/{id}/ini endpoint as the editor (so a running card still refuses the write).
  • Open the build folder. Every build page has an Открыть папку сборки button (just above Редактировать) that reveals the build's root folder in the OS file manager (POST /api/builds/{id}/open-folder, any program type). Opening folders is a silent action — no toast on success.
  • Download cache section (in Settings). Files are grouped by program (ComfyUI, then llama.cpp), and inside each program by the version folder they live in (.cache/<release>/<asset>.7z). Each file row shows only the archive name and its size, preceded by a control that is the verdict icon and the per-file verify button in one (green check = the sum matches GitHub, blue arrow = intact and a newer release exists, red cross = sum mismatch or damage, grey dot = never hashed / nothing published to compare) and followed by a per-file delete button. Each version-folder subheader shows the folder label, the file count, the newest download date and a folder-level delete button (DELETE /api/cache/folder); folders and files sort newest-download-first. The CUDA runtime (cudart-…) and ffmpeg-… archives are shown in their own subsections under llama.cpp rather than as build groups. Git-build archives (cached under a folder named after the 40-hex commit sha) are never shown as groups or rows: each program gets one Git-сборки summary subsection with just the file count, the total size and a single delete button for all of them (DELETE /api/cache/git?program=…). Gallery thumbnails are cached in memory (not on disk), so they are not listed here. The header shows the file count and total size with Проверить (verify all) and Очистить (clear the cache).
  • Checksum-verified downloads, no pointless reinstalls. Every portable download is checked against GitHub's sha256; Update skips the install when the card already holds exactly that archive, the Settings switch "Обновлять с переустановкой…" turns the skip off (see How it works).
  • Lifecycle logging. The console prints what happens to which build (download, unpack, setup, ready, running, stopped, deleted) prefixed with the build name, plus the build's own ComfyUI output. HTTP request lines are hidden by default; --verbose (or FUCC_VERBOSE=1) turns them back on.

Layout

comfyui-controller/
├── app/                 # backend (FastAPI + SQLite)
│   ├── main.py          # API + static file serving
│   ├── builds.py        # portable (.7z) and git builds, start/stop
│   ├── releases.py      # ComfyUI release list, .7z selection/download/extraction
│   ├── gallery.py       # output/ scanner
│   ├── store.py         # database access (cards, gallery cache)
│   ├── db.py            # SQLite schema + forward migration
│   └── config.py        # paths, ports, security limits
├── public/              # frontend (index.html, app.js, style.css)
├── tests/               # regression tests (unit + API)
├── shared/              # one folder per card, named after the card (git-ignored)
├── .cache/              # downloaded .7z archives, reused on rebuilds (git-ignored)
├── run.py               # cross-platform launcher
├── run.sh               # Linux/macOS launcher
├── run.bat              # Windows launcher
├── build.sh             # redistribution build -> build/comfyui/controller.zip
└── requirements.txt

Install and run

Python 3.10+ is required (3.11+ on Windows).

./run.sh                 # Linux/macOS: creates .venv in this folder, installs deps, starts
python run.py            # same launcher directly

Open http://127.0.0.1:8000 in a browser. On Windows, run.bat works by double click.

Redistribution build

./build.sh                 # -> build/comfyui-controller.zip

The archive contains a single top-level folder comfyui-controller/ with the runnable product: app/, public/, run.py, run.sh, run.bat, requirements.txt, README.md. Excluded: tests/, .venv/, .cache/, shared/, __pycache__, databases, .git/. The script verifies the manifest (entry points present, no non-product files). Recipients just unpack it and run run.bat (Windows), ./run.sh (Linux/macOS) — the first start creates its own .venv.

Running on Linux / macOS

The controller runs on Linux and macOS: create a from git build — it gets its own venv, and ComfyUI starts locally (loopback port from FUCC_COMFYUI_BASE). Portable builds also download and install on Linux (extraction needs a 7-Zip CLI), and the card becomes ready, but starting them is refused with a clear message: their embedded interpreter is a Windows python.exe. Copy shared/<folder>/ to a Windows machine to run that build.

run.py bootstraps a self-contained .venv in the project folder (from a Python on PATH, or from a portable Python dropped into python/python.exe) and re-executes into it. Dependency checks run on every start, so a half-created .venv is repaired.

Bootstrap troubleshooting

Some systems create a venv that has no pip (e.g. Fedora with a fresh Python, where ensurepip is not shipped). The launcher handles it in this order:

  1. .venv/bin/python -m pip — used when available.
  2. -m ensurepip --upgrade — repairs a venv without pip.
  3. pip from the base Python with --target <venv site-packages> — last resort.
  4. If none work, it prints the package to install (python3-pip / python3-venv) and exits with a message instead of a traceback.

The pins are exercised on Python 3.11 (this workspace's container). Newer Pythons (3.13/3.14) are unverified here — pip resolves the same pins to wheels for that interpreter; send the launcher output if an install fails.

Environment variables

Variable Default Purpose
FUCC_HOST 127.0.0.1 Server bind address — loopback only (127.0.0.1, ::1, localhost); anything else is refused at startup
FUCC_PORT 8000 Web UI port
FUCC_COMFYUI_BASE 8100 First port tried for ComfyUI instances
FUCC_COMFYUI_TRIES 200 How many ports to probe
FUCC_DB <root>/comfyui_controller.db Database file location
FUCC_SHARED_DIR <root>/shared Where builds are stored
FUCC_CACHE_DIR <root>/.cache Downloaded archives (and the thumbs/ WebP cache)
FUCC_HERO_MIN_W 500 Min width (px) for a random hero/background image (orientation ignored)
FUCC_WEBP_QUALITY 72 WebP quality for the gallery/hero thumbnails
FUCC_PORTABLE_REPO Comfy-Org/ComfyUI GitHub repo for portable releases
FUCC_7Z auto-detected Path to a 7-Zip CLI (7zz / 7z / 7za / 7z.exe)
FUCC_GIT_HOSTS github.com,www.github.com Hosts allowed for git builds
FUCC_GALLERY_MAX_FILES 5000 Cap for one gallery scan
FUCC_SAGE_WHEEL_INDEX https://comfy-org.github.io/wheels Wheel index for the git-build Sage Attention install
FUCC_SAGE_WHEEL_WIN / FUCC_SAGE_SPAS / FUCC_SAGE_TRITON_LIBS / FUCC_SAGE_RADIAL woct0rdho release URLs Sources the Windows portable Sage Attention install pulls from
FUCC_VERBOSE off 1 = print HTTP access lines (--verbose on the command line does the same)
FUCC_NO_BROWSER off 1 = do not open the browser when the server starts (--no-browser on the command line)

How it works

  1. Portable (default). Release list → pick the ComfyUI_windows_portable_*.7z asset → download (once, cached per version in .cache/<release-tag>/) → extract → the layout is detected and stored relative to the build folder. The official archive nests everything under ComfyUI_windows_portable/, with the app in ComfyUI/ and the interpreter in python_embeded/ (see /workspace/docs/comfyui/portable-layout.md). The extracted tree is flattened into the card folder: shared/<folder>/ComfyUI, shared/<folder>/python_embeded, no ComfyUI_windows_portable/ in between. Update = extract the selected asset again (existing files, e.g. models/, are kept); an update of a card that is running is refused — stop it first, because the update replaces the app folder. An update is skipped when the card already holds the exact archive the asset points at (same published sha256) and the install is intact (main.py + interpreter present); POST .../rebuild?force=true — the UI switch — reinstalls regardless. Extraction: py7zr extracts archives it can decode, so plain .7z archives need no extra tools. The official assets use the BCJ2 filter, which py7zr cannot decode, so those need an external 7-Zip CLI. A 7-Zip console build is bundled for Windows in tools/7zip/ (7z.exe + 7z.dll, 7-Zip 26.06, see tools/7zip/README.md) and used automatically, so Windows needs no separate install. Lookup order is FUCC_7Z, then the bundled copy, then a system-wide 7-Zip (7zz, 7z, 7za, C:\Program Files\7-Zip\7z.exe); on Linux/macOS only a system tool is available (install p7zip). A cached archive whose 7z header is unreadable (a saved HTML error page, an interrupted download) is dropped and re-downloaded automatically; a file with a valid header but a damaged body is only discovered when extraction fails, and the card then reports the 7-Zip tool's own message. Checksums: GitHub publishes a sha256 per asset; a download that does not match it is deleted and the card reports a checksum mismatch. A cached archive is reused only when its recorded checksum matches the asset's, so a cache file that GitHub replaced (an updated asset under the same name) is re-downloaded, not trusted. The measured checksum is kept next to the archive (<asset>.7z.sha256) and in the card (archive_sha256); archives cached before this feature are hashed once on first use. The published digests from GitHub are stored in the DB (release_digests (name, tag, sha256)) and the release list is refetched in a background thread at startup, so the cache verdicts survive a server restart; offline the last stored list is used. A row whose file has a local sum but nothing published to compare with is marked grey ("unknown"), and its check button stays active — it re-measures the file. Each release keeps its own folder, so a new release never overwrites the archive an older card is pinned to; archives that sat flat in .cache/ before this are moved into their version folder at startup when the release name is known. The per-row button in the cache section re-measures that one archive (POST /api/cache/verify?name=…) and turns its icon green (совпадает) or red (НЕ СОВПАЛА); POST /api/cache clears the cache. Version. After an install the version is read once from the app's comfyui_version.py and stored in the card (comfyui_version); the build page shows it without touching the disk again.
  2. Git. The ref is resolved to a SHA with git ls-remote (no clone), then the repository is fetched as a source archive through the unified download system (queue, Range-resume, shared cache tagged by commit — .cache/<sha>/; GitHub/Gitea pattern …/archive/<ref>.zip, GitLab …/-/archive/<ref>/…, probed once per host). Hosts that serve no archive fall back to git clone → git fetch + checkout. Then python -m venv → pip install -r requirements.txt. Update = fetch the new commit and install requirements into the existing venv (the venv folder is reused, not recreated; delete shared/<folder>/.venv to force a clean one). An update that would land on the commit already installed is skipped unless force=true. The app tree is wiped and replaced (a clean tree, so no orphan files survive from a previous version), except the user-data folders parked aside and merged back (see item 6).
  3. Start → <interpreter> main.py --listen --port <port> <launch arguments>, in its own process group so stopping takes ComfyUI's children with it. The port is the card's saved port, or the first free one from FUCC_COMFYUI_BASE (0 in the DB = auto). The launch arguments belong to the card (extra_args, edited in the card's Edit dialog); the recommended set (--offline --disable-partner-nodes --preview-method auto, exposed as recommended_args) is written in when a card is created with the Recommended settings switch, --fast when the Sage switch is on (the switch ships disabled: the flag is experimental). Starting a portable card off Windows is refused — the official archive ships a Windows interpreter; os_ok in the payload tells the UI to say so and disable Запустить. stdout/stderr go to shared/<folder>/comfyui.log and to the controller console, prefixed with the build name. Starting requires a ready build. start_comfyui registers the process, sets the card to starting and watches the log for To see the GUI go to: … (GUI_URL_RE, FUCC_START_TIMEOUT, default 180 s): that line is the success condition; the payload carries starting while it is awaited. Stopping the controller (Ctrl+C, /api/server/shutdown) stops every ComfyUI instance it started: graceful signal first, process-tree kill after 10 s; ?hard=1 skips the wait. A running install/update job is cancelled by the POST .../cancel endpoint (the same red X in the UI), so the card folder is never touched by a dead job.
  4. Gallery → recursive scan of the build's output/ (images + video) on demand; results are cached in the DB, and /media/<build_id>/... serves only files from that build's output/.
  5. Install checkpoints and Reinstall. Each install is a fixed sequence of named steps (portable: download, extract, provision; git: clone, venv). Every finished step is recorded in the card (install_steps, a JSON list) and is also gated on its on-disk artifact, so a step whose work is already present is skipped. When an install ends in error or cancelled the card is not "correctly installed": the build page and the card offer a neutral-gray Переустановить square (POST .../rebuild?resume=true), which re-runs the pipeline but skips every step that already finished and only retries the failed/incomplete ones — a downloaded archive is taken from the cache, not re-fetched. A start failure is treated differently from an install failure. The install pipeline records the stage it broke on in failed_stage; a failed launch records failed_stage='start'. Because a start error is still a fully installed card, the payload adds install_error (true only when failed_stage != 'start') and the UI keeps the Запустить button live for a start error (reinstall stays available as a secondary action and disappears once a launch succeeds). The card kebab and the build page hide Переустановить for a start error — it appears only for genuine install errors (install_error). A fresh install or a normal update clears the checkpoints and runs the whole pipeline. Resume is refused (409) on a card that already finished installing, and it never runs under a live ComfyUI instance. The venv step resumes at sub-step granularity: the marker file shared/<folder>/.venv/.fucc-requirements-ok stores the sha256 of the requirements.txt actually installed. The venv is created only if absent, and requirements are (re)installed whenever that marker is missing or no longer matches — so a venv that was created but whose pip install -r failed (which a plain "venv exists → skip" check would silently leave broken) is completed on the next install instead of skipped.
  6. User-data folders. config.USER_DATA_DIRS — models, input, output, custom_nodes, user — always live under the card's ComfyUI app dir and are never deleted by an update, a reinstall or a Reinstall; they are preserved (git rebuild parks them aside and merges them back over the fresh checkout; portable extraction only overwrites same-named files anyway). Deleting a card is a choice, not a wipe: DELETE /api/builds/{id} with purge=false (the default, and the UI's default) stops ComfyUI and removes the installed app / interpreter / .venv and loose files, but keeps shared/<folder>/ with those folders — so creating a card with the same slug reuses them. The delete dialog has a Удалить пользовательские данные checkbox; when checked it sends ?purge=true, which rmtrees the whole build folder. Without a re-created card the leftover shared/<folder>/ stays on disk (intentional, no auto-scan).

Download source registry (app/sources.py)

Every URL the controller can download is declared once, as data, in app/sources.py: a Source descriptor per app × install-method × add-on — its kind (github_api, http_file, git_clone, git_archive, pip_spec), where the URL/repo template lives (by config attribute name, so FUCC_* env overrides and test patches stay live), the asset-selection hints (name prefix, GPU variant order), the stable cache tag, and how the file is applied (extract_7z, extract_zip, pip_wheel, git_clone, …). The generic pipeline — sources.download() → shared queue with Range-resume and the stall watchdog → checksum sidecar cache — executes what the descriptor says; the app drivers (builds.py, builds_llama.py) keep only the orchestration and any run-time resolved URL (a GitHub asset picked from the API overrides url=/tag= per call). New apps or add-ons should be added here as registry entries, not as new call sites.

Cards and the build page

The header carries a badge with the controller version (app/config.py → APP_VERSION) plus a static amber pre-alpha badge (.badge.pre) with a tooltip warning that the build is unstable and use is at the user's own risk. The build page address is a real path built from the card's slug — http://host:8811/comfy/my_card (GET /comfy/{slug} serves the SPA, openBuild/gotoPath/route navigate with history.pushState + popstate): bookmarks, refresh and the browser's back button all work. A numeric id resolves too, and an old #/b/<slug> bookmark is rewritten to the path on load. The grid groups cards by program into collapsible categories (ComfyUI first, then llama.cpp — see Program types): each category is a sub-header with the program logo, a live count and a chevron that folds it (remembered in localStorage), followed by that program's card grid. Each card is one square: the server icon, the name, the version (portable release tag / git "app version (commit)", e.g. 0.4.1 (a1b2c3d4e5)) and a footer with the jump to ComfyUI (a card-go button that appears only while ComfyUI is fully started — running && !starting — and the card click switch is off), the Start/Stop button and the card's kebab. While an install runs the icon becomes a progress ring: it appears the moment the job is scheduled (stage=queued, rotating), the arc fills for downloads, measured in bytes, and rotates for phases that cannot be measured (unpacking); on hover the ring is replaced by a normal-size (32 px) round cancel button with a translucent red background — solid red under the cursor — which cancels the job (only the ring rotates). Starting ComfyUI shows the same ring in white from the click until ComfyUI prints its GUI address (success) or the start fails. The frame of a running card lights up in the card's own hue (hue, 0–359 — six presets plus a slider in the picker: the row under the dots is a hue-spectrum layer under a transparent input[type=range] — a gradient painted on the input itself gets covered by the browser's native track, and the generic .field input box rules are overridden by .field .hue-slider so the slider stays a band and not a 40px form box — and the knob is a tall bar painted in the picked hue. The row is shown exactly while a custom hue is picked (presets hide it, the pencil swatch opens it); a card built and not looked at yet lights up in green, cleared by POST /api/builds/{id}/seen when the card page is opened or ComfyUI is started.

Clicking a card opens ComfyUI in a new tab. Settings → Card click (off by default, stored in the browser) makes the card open its settings page instead; then a gear (the settings page) appears in the card's head next to the kebab, and the footer keeps only the jump to ComfyUI, and only while the server is fully started. A running card always opens ComfyUI on click.

The card page is a list of menu-like rows: Открыть ComfyUI (only while the server runs), Запустить filling its row (the row disappears entirely while the server runs; the port is edited in Изменить), Остановить (graceful; Завершить процесс in its kebab), then one row that shows Обновить (blue) when a newer release exists and the reserved, disabled Перекачать otherwise, then a separator and Изменить — the dialog for the name, hue, port, launch arguments, Sage Attention and deleting card. The Sage Attention row holds the Задействовать switch (dead until it is installed; its state is the --use-sage-attention flag, which is why it never appears in the Параметры запуска text) and, while it is not installed, the Установить Sage Attention button, which takes the switch's place entirely (the switch is not shown at all, and any switch the user cannot touch is faded — .switch.is-disabled). The confirm dialog says the card can be broken and the install cannot be undone. The dialog saves only on Сохранить — editing a field never mutates the card until then, and closing it (Esc / backdrop) discards the edits. While the card's server is running, the dangerous settings — name, port, launch arguments, Sage Attention (switch + install) and ffmpeg — are locked (dimmed, .field-lock) and Удалить is disabled; only the card hue and the hero reset stay editable. The backend mirrors this: a PATCH to a live card is refused with 409 only if it actually changes one of those dangerous fields, so an unchanged value the disabled form still sends is accepted and a hue-only edit saves while the card is up. The Sage and ffmpeg fields each carry a one-line hint (Sage speeds up generation; ffmpeg lets llama.cpp work with video). The header shows the card's program icon (comfy-icon.svg for ComfyUI, llama-icon.svg for llama.cpp) next to the build name as the page title (25px); the version line reads the installed ComfyUI version (or the llama nightly b#####), and a Windows-only archive shows a red note under it.

Hero and background images

A ComfyUI-only backdrop feature (llama.cpp has no gallery). It is switched off entirely by Settings → Интерфейс → Отображать фоновые изображения (on by default, stored in the browser under fucc.bgImages); when off, no hero, no background, and the Установить фоновым tile action disappears. Images come from the card's gallery (never video).

  • Build page — hero: a band behind the page header (#hero-layer). The header grows to the band height (~250px, controls pinned to its bottom, the growth animates); the image is capped at max-width: 1500px (so it is not stretched on wide monitors) with rounded top corners, and the layer runs ~100px taller than the header so the picture bleeds below it and fades out. A random (auto) hero is softly blurred (blur(100px)); a manually pinned one is shown sharp. The pool is this card's gallery.
  • Main page — background: a full-viewport layer (#page-bg), object-fit: cover (correct proportions, no distortion), heavily dimmed and blurred. The pool is any ComfyUI card's gallery.
  • Selection: a random eligible image on each open, rotated every 15 s when there is more than one and nothing is pinned; every switch is a 2 s crossfade (entering a build page fades in from transparent). "Eligible" is decided on the server: the image is at least HERO_MIN_W (500) px wide, orientation ignored, checked against the width captured during the gallery scan (the gallery.width column) so the newest-N candidate query filters by eligibility before capping. That way a recent run of small images cannot crowd older eligible heroes out of the rotation pool. If none qualify, nothing is shown.
  • Pinning one image: the gallery tile kebab → Установить фоновым stores it in builds.hero_image, pinning it as that card's hero and disabling both random and rotation (a pinned hero is always honored, even if it fails the size rule). Reset it from Изменить → Сбросить фоновое изображение.

API: GET /api/builds/{id}/hero-images ({pinned, images}, images pre-filtered to the eligible set), GET /api/hero-images (across all ComfyUI cards, likewise filtered), POST /api/builds/{id}/hero (pin, 409 on llama.cpp) and DELETE /api/builds/{id}/hero (clear). The images are served through the existing /media/{build_id}/{path} endpoint.

  • Downscaled WebP (app/images.py). Blurred hero/background images and small grid tiles do not need the full-resolution original, so /media/{build_id}/{path}?w=N returns a WebP thumbnail (long edge <= N, FUCC_WEBP_QUALITY, default 72) cached on disk under .cache/thumbs/ and regenerated when the source's mtime/size changes; the tile grid uses w=400 and the blurred hero/bg use w=480. The lightbox and a user-pinned hero omit w and get the full-resolution original, and videos always serve the original. When Pillow cannot decode a file it fails open (the original is served, and that image counts as an eligible hero rather than being dropped from the pool).

Program types (ComfyUI / llama.cpp)

Every card carries a program name (app/db.py), and app/programs.py is the driver registry that routes a card's install / start / stop / version calls (and its running-state probes is_running / is_starting) to that program's driver. The API (app/main.py) asks the card's own driver for everything, so a card is managed the same way no matter what it runs. comfyui is the default and a program that is not registered falls back to it.

  • comfyui — thin adapters over app.builds (the original behaviour, unchanged).

  • llama.cpp (app/builds_llama.py) — reuses the same job/stage/process machinery: a llama card resolves the newest nightly release (app/releases_llama.py, a port of version.ps1: newest b##### prerelease, highest CUDA-variant asset that is not a downgrade), downloads and unpacks it, then runs llama-server on the card's port. Update is available when the newest nightly is past the recorded build by more than the threshold (a few builds of churn are ignored); start/stop/delete mirror ComfyUI. The version column holds the nightly tag (b11532), shown in place of a ComfyUI release tag. The CUDA runtime (cudart-…) is cached under a stable cudart folder (not the nightly tag): it changes rarely, so download_cached reuses the already-cached copy by its recorded checksum across nightly updates instead of re-downloading it every time.

  • llama.cpp video support (optional ffmpeg). A llama card can opt into video output. The create form has an ffmpeg switch (ffmpeg column), and the edit modal an install / remove button (Установить ffmpeg / Удалить ffmpeg, via POST / DELETE /api/builds/<id>/ffmpeg; no status text). When enabled the installer fetches ffmpeg-master-latest-win64-gpl.zip from BtbN/FFmpeg-Builds (cached under a stable ffmpeg tag, like cudart) and lays ffmpeg.exe + ffprobe.exe into the card's build_dir/tools folder — which is ../tools relative to llama-server.exe. Because llama-server resolves --video-ffmpeg-dir against its own folder (not the process cwd), launch_args adds the flag with a path computed relative to the server dir (--video-ffmpeg-dir ../tools); the flag is added only while tools/ffmpeg.exe exists.

Because llama.cpp has no ComfyUI app tree, its cards are not offered the ComfyUI-only features: the result gallery (GET returns empty; scan / delete / open-folder answer 409), the Sage Attention switch and install (409), and the ComfyUI-only release_select. The UI hides all of these for a llama card from the gallery / sage_possible / release_select flags on the payload.

  • Safe controller updates (schema migration). The meta table stores a schema_version; app/db.py stamps it on a fresh DB and, before running any forward migration on an existing DB, takes a timestamped snapshot of the database file via the SQLite online-backup API (.backup, consistent even while the server holds it open). A migration that breaks therefore leaves a restorable copy next to the live DB rather than corrupting the user's builds in place.

Card folders

A card lives in shared/<folder>, where the folder is the card name lowercased and underscored: ComfyUI Test -> shared/comfyui_test. Duplicate names get -2, -3, ...; names Windows reserves (con, nul, com1, ...) are never produced; an empty name falls back to build_<number>.

  • Renaming a card renames its folder (stop ComfyUI first — Windows blocks renaming files that are open). The rename refuses to overwrite an existing folder.
  • App, output, venv and interpreter paths are derived from the folder name stored in the DB, so renaming a card cannot break its gallery, models, or startup.
  • Cards created before this scheme (shared/12) are migrated at startup: they get a slug and their folder is moved to it.

Security model

The API has no authentication and is intended for the local machine only:

  • The API has no authentication and binds to loopback only. FUCC_HOST accepts 127.0.0.1, ::1, localhost; any other address (including 0.0.0.0) makes the server refuse to start. Remote access requires a reverse proxy with authentication. ComfyUI instances started by the controller also listen on that loopback address.
  • State-changing requests carrying a foreign Origin header are refused (CSRF / DNS-rebinding guard), so a random web page cannot drive the local API.
  • Git builds are restricted to FUCC_GIT_HOSTS and to http(s)/git/ssh schemes: the ext:: transport (which executes shell commands) and file:// are rejected, and a cloned repository's requirements.txt is installed into a venv, so only trusted sources are allowed.
  • /media/<build_id>/<path> is confined to that build's output/ folder and to image/video extensions.
  • Every string rendered by the UI is HTML-escaped, so build names, refs and error text cannot inject markup.
  • Deleting a build removes its entire folder (including models/ and output/), so the UI asks for confirmation twice, with the build name shown. That guard is UI-level convenience only: the API endpoint itself deletes on request (it is loopback-bound and CSRF-guarded, per above).
  • Renaming a card is refused while its ComfyUI is running, and never overwrites an existing folder.
  • Clearing the download cache is refused while a build is downloading/extracting, so partial downloads are never torn out from under a running job.

Tests

From the project root (unit tests use a temp DB/shared dir; the API suite starts its own uvicorn on a free port with temp data paths):

python -m unittest tests.suite -v      # unit + API suites in one run
python -m unittest tests.test_units    # offline unit suite only
python -m unittest tests.test_api      # API suite only

The UI renderer is checked headlessly (no browser needed): from the project root run node tests/lab/render_check.cjs — it drives public/app.js through a DOM shim and asserts the card, build-page and cache-row DOM it produces.

Optional: verify the layout of a real downloaded archive (requires the .7z in .cache/, ~2 GB):

FUCC_TEST_ARCHIVE=1 python -m unittest tests.test_units.ArchiveHeaderTests

Separately, tests/lab/ holds the operational scenario harness (real controller instances, git fixture, port and cache scenarios). It is not part of the suites and is run by hand: see tests/lab/README.md.

Notes and limits

  • Portable builds are Windows builds: their embedded python.exe only runs on Windows. Starting such a build on Linux/macOS is refused with a clear message; use a git build there.
  • Extracting the official portable archives needs a 7-Zip CLI (py7zr has no BCJ2 filter). One is bundled for Windows in tools/7zip/; on Linux/macOS a system tool is used. Without any tool the build ends in error with an actionable message.
  • Verified end-to-end against the real ComfyUI_windows_portable_nvidia.7z (v0.43.0, 2.04 GB): extraction, layout detection, interpreter resolution, cached re-extract on rebuild.
  • A path column in the builds table is legacy/unused; app_dir and runtime_path hold paths relative to the build folder.
  • Gallery cache paths are relative to the build's output/ folder; cards created by older versions need a "Rescan" once.