Flatten image edit controls and let CFG/steps be typed past the old slider caps.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-28 15:42:59 -05:00
co-authored by Cursor
parent f8db0d626a
commit a2f728fe2e
6 changed files with 151 additions and 100 deletions
+6 -9
View File
@@ -3,6 +3,9 @@ import { join } from 'node:path'
import { ownerRoot } from '~/server/utils/library'
import { filterLoraStackForStudio, normalizeLoraStack } from '~/utils/loras'
import {
clampImageCfg,
clampImageSteps,
clampVideoCfg,
normalizePresetName,
parseGenerationPresetKind,
type GenerationPreset,
@@ -54,12 +57,6 @@ function mutate<T>(owner: string, fn: (presets: GenerationPreset[]) => T): Promi
return run
}
function clampInt(raw: unknown, fallback: number, min: number, max: number) {
const value = Number(raw)
if (!Number.isFinite(value)) return fallback
return Math.min(max, Math.max(min, Math.round(value)))
}
function clampNum(raw: unknown, fallback: number, min: number, max: number, step = 0.1) {
const value = Number(raw)
if (!Number.isFinite(value)) return fallback
@@ -77,7 +74,7 @@ function sanitizeVideoSettings(raw: unknown): VideoPresetSettings {
return {
workflow,
turbo,
cfg: clampNum(rec.cfg, turbo ? 1.5 : 4, 1, 10, 0.5),
cfg: clampVideoCfg(rec.cfg, turbo ? 1.5 : 4),
fps: rec.fps === 12 || rec.fps === 30 || rec.fps === 24 ? Number(rec.fps) : 24,
samplerName: sampler === 'euler' || sampler === 'dpmpp_2m' || sampler === 'res_multistep' ? sampler : 'res_multistep',
scheduler: scheduler === 'ddim_uniform' || scheduler === 'sgm_uniform' || scheduler === 'simple' ? scheduler : 'simple',
@@ -90,8 +87,8 @@ function sanitizeVideoSettings(raw: unknown): VideoPresetSettings {
function sanitizeImageSettings(raw: unknown): ImagePresetSettings {
const rec = raw && typeof raw === 'object' ? raw as Record<string, unknown> : {}
return {
steps: clampInt(rec.steps, 20, 1, 40),
cfg: clampNum(rec.cfg, 1, 0.5, 4, 0.1),
steps: clampImageSteps(rec.steps),
cfg: clampImageCfg(rec.cfg),
negative: String(rec.negative || '').slice(0, 2000)
}
}