mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
feat(randomizer): add LoRA locking and roll modes
- Implement LoRA locking to prevent specific LoRAs from being changed during randomization - Add visual styling for locked state with amber accents and distinct backgrounds - Introduce `roll_mode` configuration with 'backend' (execute current selection while generating new) and 'frontend' (execute newly generated selection) behaviors - Move LoraPoolNode to 'Lora Manager/randomizer' category and remove standalone class mappings - Standardize RETURN_NAMES in LoraRandomizerNode for consistency
This commit is contained in:
@@ -6,6 +6,8 @@ import type { LoraPoolConfig, LegacyLoraPoolConfig, RandomizerConfig } from './c
|
||||
|
||||
// @ts-ignore - ComfyUI external module
|
||||
import { app } from '../../../scripts/app.js'
|
||||
// @ts-ignore
|
||||
import { getPoolConfigFromConnectedNode, getActiveLorasFromNode, updateConnectedTriggerWords, updateDownstreamLoaders } from '../../web/comfyui/utils.js'
|
||||
|
||||
const vueApps = new Map<number, VueApp>()
|
||||
|
||||
@@ -119,6 +121,9 @@ function createLoraRandomizerWidget(node) {
|
||||
internalValue = v
|
||||
}
|
||||
|
||||
// Add method to get pool config from connected node
|
||||
node.getPoolConfig = () => getPoolConfigFromConnectedNode(node)
|
||||
|
||||
// Handle roll event from Vue component
|
||||
widget.onRoll = (randomLoras: any[]) => {
|
||||
console.log('[createLoraRandomizerWidget] Roll event received:', randomLoras)
|
||||
@@ -181,10 +186,21 @@ app.registerExtension({
|
||||
// @ts-ignore
|
||||
async LORAS(node: any) {
|
||||
if (!addLorasWidgetCache) {
|
||||
// @ts-ignore
|
||||
const module = await import(/* @vite-ignore */ '../loras_widget.js')
|
||||
addLorasWidgetCache = module.addLorasWidget
|
||||
}
|
||||
return addLorasWidgetCache(node, 'loras', {}, null)
|
||||
// Check if this is a randomizer node to enable lock buttons
|
||||
const isRandomizerNode = node.comfyClass === 'Lora Randomizer (LoraManager)'
|
||||
|
||||
console.log(node)
|
||||
|
||||
// For randomizer nodes, add a callback to update connected trigger words
|
||||
const callback = isRandomizerNode ? (value: any) => {
|
||||
updateDownstreamLoaders(node)
|
||||
} : null
|
||||
|
||||
return addLorasWidgetCache(node, 'loras', { isRandomizerNode }, callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user