mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
feat(lora-stacker): conditionally update trigger words based on node mode
Add node mode checks to ensure trigger words are only updated when the stacker node is active (mode 0 for Always or mode 3 for On Trigger). This prevents unnecessary updates when the node is inactive (mode 2 for Never or mode 4 for Bypass), improving performance and ensuring trigger words reflect the actual active state of the node. The changes include: - Adding mode checks before updating active LoRA names in the stacker callback - Modifying collectActiveLorasFromChain to only include active nodes - Adding comments to clarify node mode behavior
This commit is contained in:
@@ -63,12 +63,16 @@ app.registerExtension({
|
||||
|
||||
try {
|
||||
// Update this stacker's direct trigger toggles with its own active loras
|
||||
// Only if the stacker node itself is active (mode 0 for Always, mode 3 for On Trigger)
|
||||
const isNodeActive = this.mode === undefined || this.mode === 0 || this.mode === 3;
|
||||
const activeLoraNames = new Set();
|
||||
value.forEach((lora) => {
|
||||
if (lora.active) {
|
||||
activeLoraNames.add(lora.name);
|
||||
}
|
||||
});
|
||||
if (isNodeActive) {
|
||||
value.forEach((lora) => {
|
||||
if (lora.active) {
|
||||
activeLoraNames.add(lora.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
updateConnectedTriggerWords(this, activeLoraNames);
|
||||
|
||||
// Find all Lora Loader nodes in the chain that might need updates
|
||||
@@ -94,7 +98,9 @@ app.registerExtension({
|
||||
this.lorasWidget.value = mergedLoras;
|
||||
|
||||
// Update this stacker's direct trigger toggles with its own active loras
|
||||
const activeLoraNames = getActiveLorasFromNode(this);
|
||||
// Only if the stacker node itself is active (mode 0 for Always, mode 3 for On Trigger)
|
||||
const isNodeActive = this.mode === undefined || this.mode === 0 || this.mode === 3;
|
||||
const activeLoraNames = isNodeActive ? getActiveLorasFromNode(this) : new Set();
|
||||
updateConnectedTriggerWords(this, activeLoraNames);
|
||||
|
||||
// Find all Lora Loader nodes in the chain that might need updates
|
||||
@@ -103,6 +109,7 @@ app.registerExtension({
|
||||
isUpdating = false;
|
||||
}
|
||||
};
|
||||
|
||||
inputWidget.callback = setupInputWidgetWithAutocomplete(
|
||||
this,
|
||||
inputWidget,
|
||||
|
||||
@@ -287,6 +287,7 @@ export function getActiveLorasFromNode(node) {
|
||||
}
|
||||
|
||||
// Recursively collect all active loras from a node and its input chain
|
||||
// A node is considered active only if its mode is 0 (Always) or 3 (On Trigger)
|
||||
export function collectActiveLorasFromChain(node, visited = new Set()) {
|
||||
// Prevent infinite loops from circular references
|
||||
const nodeKey = getNodeKey(node);
|
||||
@@ -298,8 +299,12 @@ export function collectActiveLorasFromChain(node, visited = new Set()) {
|
||||
}
|
||||
visited.add(nodeKey);
|
||||
|
||||
// Get active loras from current node
|
||||
const allActiveLoraNames = getActiveLorasFromNode(node);
|
||||
// Check if node is active (mode 0 for Always, mode 3 for On Trigger)
|
||||
// Mode 2 is Never, Mode 4 is Bypass
|
||||
const isNodeActive = node.mode === undefined || node.mode === 0 || node.mode === 3;
|
||||
|
||||
// Get active loras from current node only if node is active
|
||||
const allActiveLoraNames = isNodeActive ? getActiveLorasFromNode(node) : new Set();
|
||||
|
||||
// Get connected input stackers and collect their active loras
|
||||
const inputStackers = getConnectedInputStackers(node);
|
||||
|
||||
Reference in New Issue
Block a user