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:
+1
-1
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user