Documentation
¶
Overview ¶
Package web serves the local management UI (gomponents templates + htmx + embedded Tailwind) and its JSON-free HTML fragment endpoints. All static assets are embedded, so the server is fully self-contained and offline.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
BaseURL string
DefaultPollInterval time.Duration
// Addr is the server's listen address (host:port). It decides whether the
// arbitrary extra-scan-path capability is exposed: only a loopback bind is
// treated as single-user-local (see extraPathsAllowed).
Addr string
// Library-management config (used by the library page + quarantine).
ModelRoot string
TrashDir string
LibraryPaths []string
Extensions []string
// WebScanTimeout bounds a web-triggered "Scan now"; WebScanMaxFiles caps how
// many model files that scan will walk. Both bound the arbitrary-path walk the
// endpoint exposes. Zero falls back to the config package defaults.
WebScanTimeout time.Duration
WebScanMaxFiles int
// ComfyURL is the local ComfyUI server base URL for workflow runs/preflight. It
// is config-only (never a per-request parameter). Empty disables local run.
ComfyURL string
// ComfyToken is an optional bearer token for a login-fronted ComfyUI. Secret —
// never rendered/logged.
ComfyToken string
// ComfyModelPath is the local ComfyUI models/ directory root used by the
// "Download & run" action to write a missing model into the correct per-type
// subfolder. Empty (or a non-loopback ComfyUI) disables the download flow — the
// missing-models panel then degrades to CivitAI-link-only. Validated at config
// load (existing writable dir when set).
ComfyModelPath string
// ComfyRoot is the local ComfyUI INSTALL root (the folder holding
// custom_nodes/). It is used ONLY by the explicit, user-triggered install of
// the civitai-manager ComfyUI helper extension. Empty disables that action.
// Resolved by config (explicit comfy_root, else the comfy_model_path parent
// when it looks like a ComfyUI install).
ComfyRoot string
// OutputsDir is the civitai-manager-owned directory the output gallery copies
// successful workflow-run images into (app-owned data next to the DB). Always
// set by config resolution (defaults to <db-dir>/outputs). Capture is skipped
// when empty (e.g. an unconfigured test server).
OutputsDir string
// OutputsMaxBytes is the TOTAL disk cap of the outputs tree, in bytes. After a
// successful capture the oldest generations (rows + files) are evicted until the
// total is back under it. 0 (or negative) means UNLIMITED — no eviction ever.
// Resolved by config (default 20 GiB); an unset zero value in a test server is
// therefore "unlimited", matching the pre-cap behaviour.
OutputsMaxBytes int64
// MaxFileSizeBytes caps a "Download & run" model download (0 = the built-in
// safety guard). It reuses the poller's max_file_size setting so a single knob
// bounds every download the app makes.
MaxFileSizeBytes int64
// ComfyCloud enables the "Run on CivitAI Cloud" feature (submit to the CivitAI
// orchestration API, sending the graph + resource list to civitai.com and
// spending Buzz). Default OFF → the cloud UI is shown but disabled with a note.
//
// It is a *bool carried straight through from config.Config: nil means the
// config FILE said nothing, so the DB-stored web toggle governs (see
// Server.cloudEnabled); non-nil means the file is authoritative and the web
// toggle renders read-only. Read it through Server.cloudEnabled /
// Server.cloudEnabledFromConfig, never directly.
ComfyCloud *bool
// Token is the CivitAI API token, reused as the bearer for the cloud
// orchestration API — cloud auth introduces NO separate credential. Secret:
// never rendered (config.RedactToken only) and never logged.
Token string
// HFToken is the optional HuggingFace token for the HF fallback resolver. Secret
// — never rendered/logged; sent only to HuggingFace hosts.
HFToken string
// HFFallback enables the HuggingFace fallback (try HF when CivitAI resolution
// misses). Default resolved from config (on unless explicitly disabled).
HFFallback bool
// ResolveNodePacks enables the ONLINE half of custom-node attribution (send the
// class names ComfyUI-Manager could not place to api.comfy.org and
// raw.githubusercontent.com). Default resolved from config (on unless explicitly
// disabled). When false, attribution is local-Manager-only and NO request to
// either host is made. Manager itself is loopback and is never gated by this.
ResolveNodePacks bool
}
Config holds the web server's view of app configuration.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wires the store, the CivitAI reader, and the subscriber into an http.Handler.
func NewServer ¶
func NewServer(st *store.Store, reader civitai.Reader, sub Subscriber, cfg Config, log *slog.Logger) *Server
NewServer builds a Server.
func (*Server) SetBaseContext ¶ added in v0.1.9
SetBaseContext sets the server's base context, from which background discovery crawls derive. Cancelling ctx (server shutdown) cancels any in-flight crawl. Call before Handler is served.
type Subscriber ¶
type Subscriber interface {
SubscribeModel(ctx context.Context, modelID int, opts poller.SubscribeOptions) (int64, error)
SubscribeCreator(ctx context.Context, username string, opts poller.SubscribeOptions) (int64, error)
}
Subscriber is the subscription-management surface the UI needs (satisfied by *poller.Poller).
Source Files
¶
- assets.go
- brand.go
- breadcrumbs.go
- browse_surface.go
- cloud_connect.go
- cloud_handlers.go
- cloud_job.go
- cloud_pages.go
- comfy_model_cache.go
- comfy_model_path.go
- discover_apps.go
- discover_facet_pages.go
- discover_facets.go
- discover_handlers.go
- discover_pages.go
- discover_workflow_import.go
- discover_workflows.go
- disks_handlers.go
- disks_pages.go
- handlers.go
- hf_fallback.go
- layout.go
- library_handlers.go
- library_pages.go
- maturity.go
- model_card_pages.go
- model_community_pages.go
- model_pages.go
- model_related_workflows.go
- nodepack_attribute.go
- nodepack_handlers.go
- nodepack_pages.go
- outputs_capture.go
- outputs_handlers.go
- outputs_media.go
- outputs_pages.go
- outputs_rail.go
- outputs_storage.go
- pages.go
- rail_activity.go
- reveal_handlers.go
- run_batch.go
- run_comfy_setup.go
- run_download.go
- run_gate.go
- run_handlers.go
- run_install_all.go
- run_modes.go
- run_pages.go
- run_params.go
- run_preset_pages.go
- run_presets.go
- run_queue_handlers.go
- run_readiness.go
- run_readiness_schema.go
- run_resolve.go
- run_zone.go
- sanitize.go
- scan_handlers.go
- scan_pages.go
- server.go
- subscribe_disclosure.go
- subscribe_followup.go
- workflow_facets.go
- workflow_graph.go
- workflow_handlers.go
- workflow_list_groups.go
- workflow_model_links.go
- workflow_open_comfy.go
- workflow_pages.go
- workflow_resources.go
- workflow_scan_handlers.go
- workflow_scan_pages.go