Only list LoRAs tagged for the selected image engine in the dropdown.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-02 21:49:21 -05:00
co-authored by Cursor
parent 46629ca51b
commit eccf8c0081
3 changed files with 33 additions and 6 deletions
+25 -5
View File
@@ -229,20 +229,39 @@ 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') {
const value = String(source || '').replace(/\\/g, '/').toLowerCase()
if (!value) return false
const token = engine === 'krea' ? 'krea' : 'flux'
return new RegExp(`(?:^|[/_.-])${token}`).test(value)
}
/**
* 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'
const raw = String(name || '')
const base = loraBasename(raw)
const id = loraIdentityKey(raw)
if (
hasImageEngineToken(raw, 'krea')
|| hasImageEngineToken(base, 'krea')
|| hasImageEngineToken(id, 'krea')
|| /snofs_krea/i.test(id)
) return 'krea'
if (
hasImageEngineToken(raw, 'flux')
|| hasImageEngineToken(base, 'flux')
|| hasImageEngineToken(id, 'flux')
|| isKleinImageLora(raw)
|| /flux-?2-klein|flux2-klein/i.test(id)
) return 'flux'
return null
}
export function loraMatchesImageEngine(name: string, engine: 'flux' | 'krea') {
const tagged = imageLoraEngineOf(name)
return !tagged || tagged === engine
return imageLoraEngineOf(name) === engine
}
export function filterLorasForImageEngine(names: string[], engine: 'flux' | 'krea') {
@@ -285,6 +304,7 @@ export function inferLoraUse(name: string): LoraUse[] | null {
export function loraMatchesUse(name: string, use: LoraUse) {
if (isSystemGraphLora(name)) return false
if (use === 'flux' || use === 'krea') return imageLoraEngineOf(name) === use
const inferred = inferLoraUse(name)
if (!inferred) return true
return inferred.includes(use)