Skip to content

feat: studio gallery, Civitai, generation meta, and local GPU worker - #12

Merged
surrealwolf merged 77 commits into
mainfrom
feat/freya-studio-reproduction
Nov 24, 2026
Merged

surrealwolf merged 77 commits into
mainfrom
feat/freya-studio-reproduction

Conversation

@surrealwolf

@surrealwolf surrealwolf commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Continuation of studio work from feat/freya-operator-openrouter after #11 landed on main. This branch replays that follow-up stack on current main (including org Cursor rules) without changing the original branch or PR.

Agent gallery & studio UI

  • Unified gallery empty state, agent favorites, and copy / remix / clear flows
  • Asset and generation detail modals with richer metadata
  • Civitai browse, previews, mixed asset types, and install-to-worker queue
  • Generation meta surfaced in the UI (sampler, steps, LoRA weights, backend)

Local worker & diffusion engine

  • Dockerized GPU worker rollout (freya-gpu image bumps, setup scripts, Compose paths)
  • SDXL Compel conditioning fixes (padded text embeddings, LoRA adapter scaling)
  • Worker controls in the UI (bases, start/stop, GPU stats)

API / operator / MCP

Continuation of #11 — the original PR and feat/freya-operator-openrouter branch are left as-is.

Test plan

  • cargo check --workspace
  • cd web && npm ci && npm run build
  • make mock-ui — gallery copy/remix/clear, Civitai modals, favorites
  • make run-local-worker or make compose-up-gpu — local generation + SDXL LoRA pass
  • Agent/MCP smoke against make run-mcp

Rebase notes

Rebased onto origin/main (9ca89e3). Conflicts occurred on legacy Makefile/README history, the #9 mega-commit (script paths / removed HeroCanvas), and style preset deletion; resolved toward current studio behavior and followed with a tree-restore fix commit so the diff matches the pre-rebase feature tip versus main.


Note

Medium Risk
Large API surface around Civitai fetching, NSFW filtering, and reproduction flows that touches generation and worker install paths; Dockerfile change adds runtime ffmpeg and a non-distroless API image.

Overview
Expands Freya’s Civitai integration with NSFW-aware model search, recommended resources (including tRPC backfill), community image browsing with full generation metadata, CDN media proxying, hash-based downloads, and inventory-aware “missing LoRA/checkpoint” hints. New HTTP routes cover lookup, images, media, generation-meta (get/put/recommend), gallery apply, and community reproduction apply; auth exempts the allowlisted Civitai media proxy like gallery images.

Adds genmeta and reproduce so studio can recommend sampler/CFG/steps from Civitai examples or family defaults, parse settings from chat, map samplers to Diffusers schedulers, and apply community posts or gallery sidecars into pinned LoRAs and locked generation settings (enhance off). Gallery sidecars and studio prefs now carry richer generation fields; GIFs are served by magic-byte sniffing. Builtin/sample style packs are removed in favor of pack files only; agent instructions are updated for one-type Civitai search.

Ops: the API container image switches to Debian slim with ffmpeg (nonroot UID 65532) for gif modality; Makefile gains update-local-worker; diffusion worker CR samples and operator reconciliation honor custom image repository/tag/pullPolicy; the Python worker adds compel for SDXL conditioning.

Reviewed by Cursor Bugbot for commit f924e19. Bugbot is set up for automated code reviews on this repo. Configure here.

surrealwolf and others added 30 commits November 23, 2026 21:33
Replace Compose/GPU UI default path with kube-rs studio, cloud+local
generation router, and Civitai key install flow.

Co-authored-by: Cursor <cursoragent@cursor.com>
* Add make swarmui-update for in-container SwarmUI upgrades

The UI update button pulls source but Freya skips the native rebuild step.
Wire git pull + dotnet build into make targets and document the workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix make sui update race and avoid full stack teardown

Stop only ComfyUI to preserve git state, use fetch+reset with retries,
and skip rebuild/restart when SwarmUI is already current.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Interactive mock/dev:mock path, lacquer mist theme, portrait icons,
and suggest/session instruction packs with API assist enrichment for #9.

Co-authored-by: Cursor <cursoragent@cursor.com>
Contain asset dest paths, allowlist Civitai download hosts, optional
FREYA_API_TOKEN + tighter CORS, drop shell eval on asset Jobs, and
fix external worker URL / Job phase / LoRA local backend wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>
Require bearer on protected GETs, wire apiTokenSecretRef and
worker authSecretRef through the operator, and allowlist worker
install hosts so cluster/Ingress deployments are not fail-open.

Co-authored-by: Cursor <cursoragent@cursor.com>
Stop nginx from injecting the API bearer, allowlist FreyaModelAsset
download hosts before attaching secretRef, and sanitize assist mode
paths. Reword sample secret comments so Security Checks CI passes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pass download credentials as authToken Bearer instead of a URL
query param, and return sanitized worker install errors so reqwest
URL Display cannot echo the secret.

Co-authored-by: Cursor <cursoragent@cursor.com>
Refresh .env.example and local docs for operator/API keys;
feature freya.png NL brand prompt in packs and builtins.

Co-authored-by: Cursor <cursoragent@cursor.com>
Planner chat models were treated as image endpoints and /images
errors were masked by a chat-modalities fallback. Sanitize model
ids, surface ZDR/credits clearly, and return a visible local stub PNG.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Surface installable Civitai weights (LoRA/LoCon/DoRA/Checkpoint/TI/VAE) with
thumbnails and a detail view that shows base-model family + related checkpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the list/suggest card in the modal when GET /v1/civitai/models/{id}
fails (common in mock vs live ids) instead of blocking Favorite/Pin.

Co-authored-by: Cursor <cursoragent@cursor.com>
Prompt submit chats with Freya; generate/search/install become
mode-gated tool actions via POST /v1/chat instead of a Generate CTA.

Co-authored-by: Cursor <cursoragent@cursor.com>
Wire Studio sample to nginx Ingress host and point the external worker
sample at an in-cluster Service/Endpoints reachable from kind.

Co-authored-by: Cursor <cursoragent@cursor.com>
Settings shows VRAM/util from worker or host nvidia-smi; API
adds /v1/worker/stats plus docker/systemd start|stop and
enable|disable so local gens can be paused without breaking
OpenRouter.

Co-authored-by: Cursor <cursoragent@cursor.com>
Local GPU control and OpenRouter chat discovery need first-class
Worker/API surfaces; rotate tokens in-UI and sync LE wildcard into
kind so freya.dataknife.net matches fleet TLS.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Auto on an internal privacy/alignment/cost matrix, and add the Civitai queue, local worker setup, and studio UI on that path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep alignment and cost fallbacks in packs/auto-models.json so the router, agent, image, and video defaults can change without another hardcoded table.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
* Add make swarmui-update for in-container SwarmUI upgrades

The UI update button pulls source but Freya skips the native rebuild step.
Wire git pull + dotnet build into make targets and document the workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix make sui update race and avoid full stack teardown

Stop only ComfyUI to preserve git state, use fetch+reset with retries,
and skip rebuild/restart when SwarmUI is already current.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: move Compose/Comfy stack under legacy/

Clear root for OpenRouter operator rebuild while keeping prior UI tooling reachable.

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: add OpenRouter operator, API, and Freya UI

Replace Compose/GPU UI default path with kube-rs studio, cloud+local
generation router, and Civitai key install flow.

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: add Freya mock UI and agentic session assist

Interactive mock/dev:mock path, lacquer mist theme, portrait icons,
and suggest/session instruction packs with API assist enrichment for #9.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(ci): validate Compose and Dockerfiles under legacy/

Root compose moved with the operator cutover; Lint and Validate was
failing with "no configuration file provided".

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: address Bugbot security and review findings (#9)

Contain asset dest paths, allowlist Civitai download hosts, optional
FREYA_API_TOKEN + tighter CORS, drop shell eval on asset Jobs, and
fix external worker URL / Job phase / LoRA local backend wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(security): close residual auth gaps on API and worker (#9)

Require bearer on protected GETs, wire apiTokenSecretRef and
worker authSecretRef through the operator, and allowlist worker
install hosts so cluster/Ingress deployments are not fail-open.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(security): close UI proxy and asset auth gaps (#9)

Stop nginx from injecting the API bearer, allowlist FreyaModelAsset
download hosts before attaching secretRef, and sanitize assist mode
paths. Reword sample secret comments so Security Checks CI passes.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(security): stop leaking Civitai key in errors (#9)

Pass download credentials as authToken Bearer instead of a URL
query param, and return sanitized worker install errors so reqwest
URL Display cannot echo the secret.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the CRD manifest as YAML, require the API bearer on /mcp, and stop empty persisted keys or a failed Secret read from replacing live credentials.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Router prompt listed short Gemini names next to openrouter/auto, so
the model emitted openrouter/google-gemini-pro-image-1. The resolver
accepted any slug containing "image". Drop that prefix unless a real
provider/model follows, and use the Auto matrix id otherwise.

Cost tier moves onto the prompt bar and still writes the saved cost
preference. Models tab keeps fallbacks only.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Keyword lists forced chat unless the user said generate,
draw, or make, and forced picture on a character or a
visual noun. The route model classifies the conversation.
Heuristics only catch an obvious render or obvious advice.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
A look or a question about generating is not a request to
render. Picture needs generate, draw, make it, make the
picture, or again. Ambiguous turns stay chat.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Chat-guard sent every look without generate, draw, or make
back to chat, so an outfit description never rendered.
Obvious advice still stays chat. The route model decides
a scene or a character description.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Chat and MCP share non-secret Studio controls. Image
download saves the gallery file instead of a new tab.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Dark theme used light chrome text on the bone mat, so the
download control disappeared beside Remix and Delete.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
The Low/Med/High/Max switch is a 30px $ control. Its popover
list matches the model menus, sets autoFallbacks.costTier, and
closes. Models tab stays fallbacks only.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Supplied PNGs have readable captions.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Chat sessions live in localStorage. Archive hides a row
and keeps it recoverable. Delete drops that record only.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Composer, Worker, and Installed kept the first worker fetch.
A job leaving downloading restarted the poll before refresh.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
surrealwolf and others added 27 commits November 23, 2026 21:33
Sampler, CFG, steps, and clip skip come from the selected version's
example image when it has them, otherwise one family default. The
Diffusers engine applies those fields, and the gallery sidecar plus
Agent Meta store keep the seed that was actually used.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Reduced motion drops the status-word sweep so the word stays visible. Mock model pages follow the civitai.red / civitai.com rule and include modelVersionId.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Show Civitai posts for the model version on Agent → Gallery.
A row click copies prompt and sampler settings into Meta and does not generate.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Gallery rows and civitai_images say which checkpoint a
post used, if it differs from the current base, and if
it is installed. Install missing queues only resources
with a Civitai version or model id and does not pin
or change the base.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Serde maps alias n onto quantity, so posting both is
duplicate field quantity and the worker returns 422.
cfg, negativePrompt, and loraRequest match GenReq.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
A 12-image cap hid the rest of the Civitai page. The next
cursor appends. A tile opens the image and does not write
the composer or Meta.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Install missing and the Civitai link join favorite,
copy, and download. Tiles keep that row under the
image; the detail modal keeps it on the top right.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Copy on a community image fills the composer prompt, negative prompt,
and generation meta, and selects an installed checkpoint when one matches.
Favorites split by asset type, with community images on an Images tab
kept in freya.communityImageFavorites.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
A same-family checkpoint was standing in for the post's file.
Copy keeps the image checkpoint, or the asset's recommended
checkpoint when that file is installed, and does not download.
A clipboard miss no longer reports the fill as an error.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Copy prefers the gallery context LoRA when it is on the worker;
otherwise pins installed LoRAs from post resources without
downloading. Reorder gallery tile actions per spec.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Pinned installed Loras often have a filename id but no Civitai model id.
The UI no longer sends that string as modelId; the API drops invalid
modelId values instead of failing JSON deserialize on /v1/generate and chat.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Copy now matches installed checkpoints by display name and filename
stem, sets localBaseModel/activeBasePath (and worker stats) via
setInstalledAsBase, and stops rendering Civitai Search under Meta.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Agent Gallery tiles, detail modal, and image favorites used img for
.mp4/.webm/.mov URLs from image.civitai.com. CommunityMedia chooses
video (muted autoplay on tiles, controls in modal) and keeps GIFs on
img. API includes mediaType and keeps video posts that have a URL.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Deduplicate community posts by Civitai id and canonical media URL on API
and in the web client, migrate stray community-image rows from model
favorites, and match unfavorite against every duplicate key. Stream MP4
community posts through GET /v1/civitai/media so tiles and the modal can
play video after Civitai CDN redirects.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
The Gallery tab rendered the same artifact in the hero preview and again
in the thumbnail wall (and batch sets duplicated the featured image). Skip
wall rows and the solo preview when the session set already shows them.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Extend artifact sidecars with LoRA pins, checkpoint identity, and
enhance flag; default LoRA weight 1.0. Copy/apply paths set enhance off.
Add apply endpoints and agent/MCP tools with generation instructions.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Stored studio enhance:off now wins over chat generate_image auto
defaults. Copy pins every installed Civitai LoRA on the post (not only
gallery-context), passes Civitai ids, and appends missing triggers.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Civitai copy/paste keeps `<lora:…>` tokens while Freya loads LoRAs via
Diffusers adapters; encoding the tags skews reproduction. Strip tags in
the API worker path, record workerPrompt on gallery sidecars, and mirror
strip plus lora_scale in the Diffusers engine.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Add Clear before community Copy so prompt, Agent Meta, enhance, seed,
and pinned LoRAs reset instead of merging with prior state; Copy now
replaces gen meta and pins from the selected image only.

Encode Civitai attention syntax via Compel in the diffusers engine so
negative weights like (watermark:1.2) apply. GPU hosts must reload the
worker image for engine changes.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Add update-local-worker.sh to pull FreyaDiffusionWorker spec.image and
recreate freya-local-worker. Document the flow on the Worker tab; honor
pullPolicy on in-cluster worker Deployments.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Use CPU seed generators, leading Euler ancestral spacing, Compel for all
SDXL prompts, optional single-LoRA fuse into UNet and CLIP, and token
length diagnostics on generate responses.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Compel 2.x dropped CompelForSDXL; SDXL encoding fell back to truncated
CLIP (90-token prompt dropped pose tags on the Frankie reproduction).
Use dual-encoder Compel with pooled embeds and stop permanent fuse_lora
so cached pipelines do not stack weights. Install may pass fileHash to
pick a Civitai version file by AutoV2/AutoV3 hash.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Batch positive and negative SDXL prompts in Compel so long prompts no
longer mismatch negative embed length. Suppress the Agent-tab LoRA hint
when pins and base already match, and hide a second Generate after a
failed tool run.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Copy on community images runs the full gallery clear before applying
prompt, meta, pins, and base. Composer and meta Clear use the same
reset. Freya gallery tiles use icon actions and a unified Remix control;
Civitai asset detail matches community image layout. Favorites dedupe
and toggle by stable id or canonical model URL.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 6 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f924e19. Configure here.

Comment thread crates/freya-api/src/civitai.rs Resolved
Comment thread deploy/worker/engine/server.py Resolved
Comment thread deploy/worker/engine/server.py Resolved
Comment thread crates/freya-api/src/reproduce.rs Resolved
Comment thread crates/freya-api/src/reproduce.rs Resolved
Comment thread crates/freya-api/src/reproduce.rs Resolved
@surrealwolf
surrealwolf merged commit c31f4aa into main Nov 24, 2026
10 of 13 checks passed
@surrealwolf
surrealwolf deleted the feat/freya-studio-reproduction branch November 24, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant