Let MOSS use the same LoRA picker and chain those adapters onto its graph.

The picker was hidden and the API cleared every stack, so a selected MOSS job could not carry a LoRA.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-10-22 20:28:25 -05:00
co-authored by Cursor
parent 354f475866
commit 8602d6ed2e
11 changed files with 38 additions and 28 deletions
+1 -1
View File
@@ -172,7 +172,7 @@
<Studio2StyleChips v-if="!video && form.mode!=='music'" v-model="form.imageStyles" class="mt-1" />
<Studio2PromptControls v-if="video" v-model="form.promptSections" class="mt-2" />
<div v-if="['flux','krea','qwen21'].includes(form.engine)">
<div v-if="['flux','krea','qwen21','moss'].includes(form.engine)">
<span class="field-label">LoRA</span>
<LoraSelect
v-model="form.settings.loraStack"
+1 -1
View File
@@ -116,7 +116,7 @@ Generate MOSS (`moss_v2_generate.json`) is text-to-image only. Edit, Compose, Re
| `14` | `EmptyFlux2LatentImage` at request width × height (1024×1024 start, about 1MP) |
| `15` | `KSampler` euler / sgm_uniform, default 25 steps, CFG 2.5 |
`ModelSamplingSD3` is not used. Its default multiplier is 1000, and MOSS samples with multiplier 1. `ModelSamplingAuraFlow` sets shift 5 at that multiplier. The prompt upsampler stays off. MOSS does not load Klein or Krea weights or LoRAs. Missing MOSS files fail the job. No Flux or Krea fallback. Steps and CFG are stored per engine. `scripts/setup-moss-image.ps1` downloads the single-file INT8 set into the Comfy models tree.
`ModelSamplingSD3` is not used. Its default multiplier is 1000, and MOSS samples with multiplier 1. `ModelSamplingAuraFlow` sets shift 5 at that multiplier. The prompt upsampler stays off. A MOSS LoRA is a file whose name contains moss. Those cards chain through `LoraLoader` onto the MOSS model and CLIP. Klein and Krea LoRAs are refused. MOSS does not load Klein or Krea weights. Missing MOSS files fail the job. No Flux or Krea fallback. Steps and CFG are stored per engine. `scripts/setup-moss-image.ps1` downloads the single-file INT8 set into the Comfy models tree.
There is no `LoadImage` on Generate. If the executed Generate graph has a required LoadImage, the job fails. v1 node 145 (muted T2I with a baked prompt) is not used.
+3 -4
View File
@@ -799,10 +799,9 @@
SNOFS
</label>
<LoraSelect
v-if="v2Engine !== 'moss'"
v-model="imageV2LoraStack"
:names="imageV2LoraOptions"
:engine="v2Engine === 'krea' ? 'krea' : 'flux'"
:engine="v2Engine"
:triggers="loraTriggers"
:aliases="loraAliases"
label="LoRA"
@@ -813,7 +812,7 @@
@update-trigger="saveLoraTrigger"
/>
<p v-if="v2Engine === 'krea'" class="mt-1 text-[11px] text-zinc-500">Krea only lists krea LoRAs. Flux files stay on the Flux engine.</p>
<p v-else-if="v2Engine === 'moss'" class="text-[11px] text-zinc-500">MOSS SFT does not load Klein or Krea LoRAs. The prompt upsampler stays off.</p>
<p v-else-if="v2Engine === 'moss'" class="text-[11px] text-zinc-500">MOSS lists moss LoRAs. Klein and Krea files stay on those engines. The prompt upsampler stays off.</p>
</div>
<div>
<AspectRatioPick :model-value="aspect" heading="Aspect ratio" :options="imageAspects" @update:model-value="setImageAspect" />
@@ -7490,7 +7489,7 @@ async function editImageV2() {
const tagged = imageLoraEngineOf(item.name)
return tagged != null && tagged !== v2Engine.value
})
if (v2Engine.value !== 'moss' && wrongEngine) {
if (wrongEngine) {
toast(imageLoraEngineMismatchMessage(wrongEngine.name, v2Engine.value))
return
}
+2
View File
@@ -662,6 +662,7 @@ function buildMossGenerateWorkflow(params: ImageV2BuildParams) {
setInput(graph, SAVE, 'filename_prefix', params.filenamePrefix || 'v2-moss')
assertImageV2Graph(graph, 'generate', undefined, 'moss')
const userLoras = applyImageV2UserLoras(graph, imageV2UserStack(params, 'moss'), 'moss')
const loaders = loadImageNames(graph)
console.log(JSON.stringify({
src: 'image-v2',
@@ -678,6 +679,7 @@ function buildMossGenerateWorkflow(params: ImageV2BuildParams) {
},
shift: IMAGE_V2_MOSS_SHIFT,
slg: IMAGE_V2_MOSS_SLG_LAYER,
loras: { user: userLoras },
upsampler: false,
steps,
cfg,
+1 -2
View File
@@ -440,7 +440,6 @@ function linkRef(value: unknown): [string, number] | null {
}
export function assertImageV2LoraStack(stack: unknown, engine: 'flux' | 'krea' | 'moss') {
if (engine === 'moss') return []
const items = normalizeLoraStack(stack)
const wrong = items.find((item) => {
const tagged = imageLoraEngineOf(item.name)
@@ -482,7 +481,7 @@ function clipConsumers(graph: WorkflowGraph) {
export function applyImageV2UserLoras(
graph: WorkflowGraph,
stack?: unknown,
engine: 'flux' | 'krea' = 'flux'
engine: 'flux' | 'krea' | 'moss' = 'flux'
) {
stripExistingLoraLoaders(graph)
+1 -1
View File
@@ -82,7 +82,7 @@ export function validateRequest(raw, xaigen = false) {
photos: Array.isArray(raw.photos) ? raw.photos : [],
startFrameSource: raw.startClipId ? {kind:'previous-last-frame',clipId:raw.startClipId} : {kind:'still',stillId:raw.imageAId || ''},
promptSections, compiledPrompt:compilePrompt(promptSections,video,{...raw,engine,lockFace:quietLocks?false:raw.lockFace,lockOutfit:quietLocks?false:raw.lockOutfit}),
settings: { aspect, fps:number('fps',24,1,60), width, height, steps, cfg, seedMode:raw.settings?.seedMode==='locked'?'locked':'random',seed:shotSeeds[0],duration:number('duration',5,1,15),turbo:moss ? false : raw.settings?.turbo !== false, loraStack:moss ? [] : (Array.isArray(raw.settings?.loraStack)?raw.settings.loraStack:[]) },
settings: { aspect, fps:number('fps',24,1,60), width, height, steps, cfg, seedMode:raw.settings?.seedMode==='locked'?'locked':'random',seed:shotSeeds[0],duration:number('duration',5,1,15),turbo:moss ? false : raw.settings?.turbo !== false, loraStack:Array.isArray(raw.settings?.loraStack)?raw.settings.loraStack:[] },
guides: (Array.isArray(raw.guides)?raw.guides:[]).slice(0,8).map(g=>{ if (!g.stillId || !Number.isInteger(g.frame) || g.frame<1 || g.frame>=frames) fail('Each guide requires a still and positive frame index.'); return {stillId:String(g.stillId),frame:g.frame} }),
batch: (Array.isArray(raw.batch)?raw.batch:[]).slice(0,30).map(s=>{const next=sectionsFrom({...promptSections,...(typeof s==='string'?{action:s}:s)});if(!next.action.trim())fail('Every shot needs an action prompt.');return video?next:{action:next.action}}) }
}
+8 -4
View File
@@ -8,8 +8,9 @@ import ts from 'typescript'
const stub = `
export function filterLoraStackForImageEngine(stack, engine) {
if (engine === 'moss') return []
return Array.isArray(stack) ? stack : []
const items = Array.isArray(stack) ? stack : []
if (engine !== 'moss') return items
return items.filter(item => /(^|[\\/_.-])moss/i.test(String(item?.name || '')))
}
export function loraIdentityKey(name) {
return String(name || '').replace(/\\\\/g, '/').split('/').pop().toLowerCase()
@@ -47,11 +48,14 @@ test('MOSS is a generate engine with its own workflow and sampling defaults', ()
assert.deepEqual(api.imageV2SamplingDefaults('krea'), { steps: 8, cfg: 1 })
assert.deepEqual(api.imageV2SamplingDefaults('flux'), { steps: 24, cfg: 4 })
assert.deepEqual(api.defaultImageV2LoraStack({ engine: 'moss', mode: 'generate', xaigen: true }), [])
assert.deepEqual(api.mergeLegacyImageV2Loras([{ name: 'klein.safetensors', strengthModel: 1, strengthClip: 1 }], {
assert.deepEqual(api.mergeLegacyImageV2Loras([
{ name: 'klein.safetensors', strengthModel: 1, strengthClip: 1 },
{ name: 'moss-style.safetensors', strengthModel: 0.8, strengthClip: 0.8 }
], {
engine: 'moss',
mode: 'generate',
xaigen: true
}), [])
}), [{ name: 'moss-style.safetensors', strengthModel: 0.8, strengthClip: 0.8 }])
})
test('MOSS look settings stay separate from Klein and Krea', () => {
+6 -1
View File
@@ -7,6 +7,7 @@ import {useAsHero,useAsSource,restoreAll,hydrateStudio2Job} from '../shared/stud
import {toggleStyle,parseBatch,parseBatchDoubleBlank,stylePrompt} from '../shared/studio2/styles.mjs'
import {compilePrompt,validateRequest} from '../shared/studio2/contracts.mjs'
import {queueEngineLabel} from '../shared/studio2/queue-view.mjs'
import {filterLorasForUse,filterLoraStackForUse,loraMatchesImageEngine} from '../utils/loras.ts'
import {cachedLoras} from '../shared/studio2/lora-cache.mjs'
import {resolveQwen21Size} from '../shared/studio2/qwen21-size.mjs'
import {ensureQwen21EditPrompt,stitchQwen21PeEditPrompt,QWEN21_EDIT_KEEP_CHANGE} from '../shared/studio2/qwen21-edit.mjs'
@@ -105,7 +106,11 @@ test('moss is generate-only with its own steps and CFG',()=>{
assert.equal(q.settings.height,1024)
assert.equal(q.turbo,false)
assert.equal(q.enhancePrompt,false)
assert.deepEqual(q.settings.loraStack,[])
assert.deepEqual(q.settings.loraStack,[{name:'klein-anime.safetensors'}])
assert.deepEqual(filterLoraStackForUse(q.settings.loraStack,'moss',true),[])
assert.deepEqual(filterLorasForUse(['moss-style.safetensors','klein-anime.safetensors','krea-look.safetensors'],'moss'),['moss-style.safetensors'])
assert.equal(loraMatchesImageEngine('moss-style.safetensors','moss'),true)
assert.equal(loraMatchesImageEngine('klein-anime.safetensors','moss'),false)
assert.equal(q.identityStillId,'')
const fresh=validateRequest({mode:'generate',engine:'moss',folderId:'f',promptSections:{action:'cup'},settings:{aspect:'auto'}})
assert.equal(fresh.settings.steps,25)
+1 -1
View File
@@ -7,7 +7,7 @@ import {restoreAll,restoreAsset,bindClip,extendSelected,useAsHero,useAsSource} f
const stack=name=>[{name:name+'.safetensors',strengthModel:.6,strengthClip:.35}]
test('engine token matrix uses paths and names, omits unknown and system picker entries',()=>{
const cases={'xaigen-klein_car':'flux','klein/style':'flux','XAIgen-flux_test':'flux','Flux2-Klein/test':'flux','MiniMax/car':'minimax','folder/LTX_style':'ltx','xiagen-Krea_look':'krea','xaigen-krea/style':'krea','unlabelled':null}
const cases={'xaigen-klein_car':'flux','klein/style':'flux','XAIgen-flux_test':'flux','Flux2-Klein/test':'flux','MiniMax/car':'minimax','folder/LTX_style':'ltx','xiagen-Krea_look':'krea','xaigen-krea/style':'krea','moss-style':'moss','folder/MOSS_look':'moss','unlabelled':null}
for(const [name,use] of Object.entries(cases)) {
assert.deepEqual(inferLoraUse(name+'.safetensors'),use?[use]:null)
for(const current of ['flux','krea','minimax','ltx']) assert.equal(filterLorasForUse([name+'.safetensors'],current).length,use===current?1:0)
+1 -1
View File
@@ -338,7 +338,7 @@ export function mergeLegacyImageV2Loras(stack: unknown, opts: {
consistencyClip?: number
kreaConcept?: string
}): LoraStackItem[] {
if (opts.engine === 'moss') return []
if (opts.engine === 'moss') return filterLoraStackForImageEngine(stack, 'moss')
let items = filterLoraStackForImageEngine(stack, opts.engine)
if (opts.engine === 'krea') {
const name = String(opts.kreaConcept || '').trim()
+13 -12
View File
@@ -230,10 +230,10 @@ export function isKleinImageLora(name: string) {
return /flux-?2-klein|klein_snofs|flux2-klein-9b-consistency|(^|[^a-z0-9])klein([^a-z0-9]|$)/i.test(id)
}
function hasImageEngineToken(source: string, engine: 'flux' | 'krea') {
function hasImageEngineToken(source: string, engine: 'flux' | 'krea' | 'moss') {
const value = String(source || '').replace(/\\/g, '/').toLowerCase()
if (!value) return false
const token = engine === 'krea' ? 'krea' : 'flux'
const token = engine === 'krea' ? 'krea' : engine === 'moss' ? 'moss' : 'flux'
return new RegExp(`(?:^|[/_.-])${token}`).test(value)
}
@@ -241,10 +241,15 @@ function hasImageEngineToken(source: string, engine: 'flux' | 'krea') {
* Image engine from the filename: `xaigen-flux-…` / `flux-…` vs `xaigen-krea-…` / `krea-…`.
* Klein / SNOFS files without that prefix still count as Flux or Krea.
*/
export function imageLoraEngineOf(name: string): 'flux' | 'krea' | null {
export function imageLoraEngineOf(name: string): 'flux' | 'krea' | 'moss' | null {
const raw = String(name || '')
const base = loraBasename(raw)
const id = loraIdentityKey(raw)
if (
hasImageEngineToken(raw, 'moss')
|| hasImageEngineToken(base, 'moss')
|| hasImageEngineToken(id, 'moss')
) return 'moss'
if (
hasImageEngineToken(raw, 'krea')
|| hasImageEngineToken(base, 'krea')
@@ -262,25 +267,22 @@ export function imageLoraEngineOf(name: string): 'flux' | 'krea' | null {
}
export function loraMatchesImageEngine(name: string, engine: 'flux' | 'krea' | 'moss') {
if (engine === 'moss') return false
return imageLoraEngineOf(name) === engine
}
export function filterLorasForImageEngine(names: string[], engine: 'flux' | 'krea' | 'moss') {
if (engine === 'moss') return []
return names.filter(name => loraMatchesImageEngine(name, engine))
}
export function filterLoraStackForImageEngine(stack: unknown, engine: 'flux' | 'krea' | 'moss') {
if (engine === 'moss') return []
return normalizeLoraStack(stack).filter(item => loraMatchesImageEngine(item.name, engine))
}
export function imageLoraEngineMismatchMessage(name: string, engine: 'flux' | 'krea' | 'moss') {
if (engine === 'moss') return `${loraDisplayName(name)} cannot be used with MOSS-Image.`
const other = engine === 'krea' ? 'Flux' : 'Krea'
const current = engine === 'krea' ? 'Krea' : 'Flux'
return `${loraDisplayName(name)} is a ${other} LoRA and cannot be used with ${current}.`
const labels = { flux: 'Flux', krea: 'Krea', moss: 'MOSS-Image' } as const
const tagged = imageLoraEngineOf(name)
const other = tagged ? labels[tagged] : 'other'
return `${loraDisplayName(name)} is a ${other} LoRA and cannot be used with ${labels[engine]}.`
}
export function kleinLoraOnKreaMessage(name: string) {
@@ -305,6 +307,7 @@ export function inferLoraUse(name: string): LoraUse[] | null {
if (/ltx/.test(value)) uses.push('ltx')
if (/klein|flux/.test(value)) uses.push('flux')
if (/krea/.test(value)) uses.push('krea')
if (/moss/.test(value)) uses.push('moss')
if (/qwen/.test(value)) uses.push('qwen21')
return uses.length ? uses : null
}
@@ -317,14 +320,12 @@ export function isQwenImageLora(name: string) {
export function loraMatchesUse(name: string, use: LoraUse) {
if (isSystemGraphLora(name)) return false
if (use === 'moss') return false
if (use === 'qwen21') return isQwenImageLora(name)
return !!inferLoraUse(name)?.includes(use)
}
/** Saved stacks may contain unlabelled adapters; never carry a known wrong engine. */
export function filterLoraStackForUse(stack: unknown, use: LoraUse, xaigen: boolean) {
if (use === 'moss') return []
if (use === 'ltx' && !xaigen) return []
return filterLoraStackForStudio(stack, xaigen).filter(item => {
if (isSystemGraphLora(item.name)) return false