Filter image LoRAs by flux- / krea- filename so each engine only lists its own.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-02 21:37:12 -05:00
co-authored by Cursor
parent 9fd96cb990
commit 46629ca51b
3 changed files with 52 additions and 29 deletions
+27 -8
View File
@@ -229,19 +229,38 @@ 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)
}
/**
* 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 {
const id = loraIdentityKey(name)
if (/snofs_krea|(^|[_-])krea([_-]|$)/i.test(id) || /^krea\d*[-_.]/i.test(id)) return 'krea'
if (isKleinImageLora(name) || /flux-?2-klein|flux2-klein/i.test(id) || /^flux\d*[-_.]/i.test(id)) return 'flux'
return null
}
export function loraMatchesImageEngine(name: string, engine: 'flux' | 'krea') {
const tagged = imageLoraEngineOf(name)
return !tagged || tagged === engine
}
export function filterLorasForImageEngine(names: string[], engine: 'flux' | 'krea') {
if (engine !== 'krea') return names
return names.filter(name => !isKleinImageLora(name))
return names.filter(name => loraMatchesImageEngine(name, engine))
}
export function filterLoraStackForImageEngine(stack: unknown, engine: 'flux' | 'krea') {
const items = normalizeLoraStack(stack)
if (engine !== 'krea') return items
return items.filter(item => !isKleinImageLora(item.name))
return normalizeLoraStack(stack).filter(item => loraMatchesImageEngine(item.name, engine))
}
export function imageLoraEngineMismatchMessage(name: string, engine: 'flux' | 'krea') {
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}.`
}
export function kleinLoraOnKreaMessage(name: string) {
return `${loraDisplayName(name)} is a Flux LoRA and cannot be used with Krea.`
return imageLoraEngineMismatchMessage(name, 'krea')
}
export type LoraUse = 'minimax' | 'ltx' | 'flux' | 'krea'
@@ -256,9 +275,9 @@ export function isSystemGraphLora(name: string) {
/** Filename hints. `null` means the LoRA can appear in any picker. */
export function inferLoraUse(name: string): LoraUse[] | null {
const imageEngine = imageLoraEngineOf(name)
if (imageEngine) return [imageEngine]
const id = loraIdentityKey(name)
if (/snofs_krea|(^|[_-])krea([_-]|$)/i.test(id)) return ['krea']
if (isKleinImageLora(name) || /flux-?2-klein|flux2-klein/i.test(id)) return ['flux']
if (/(^|[_-])ltx([_-]|$)|ltx-2/i.test(id)) return ['ltx']
if (/minimax|h3_fl2v|fl2v_turbo/i.test(id)) return ['minimax']
return null