feat: initial release of ComfyUI-LM-Remote
Remote-aware LoRA Manager nodes that fetch metadata via HTTP from a remote Docker instance while loading LoRA files from local NFS/SMB mounts. Includes reverse-proxy middleware for transparent web UI access. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
166
web/comfyui/lora_loader_remote.js
Normal file
166
web/comfyui/lora_loader_remote.js
Normal file
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* JS shim for Remote Lora Loader / Remote Lora Text Loader nodes.
|
||||
*
|
||||
* Re-uses all widget infrastructure from the original ComfyUI-Lora-Manager;
|
||||
* the only difference is matching on the remote node NAMEs.
|
||||
*/
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { api } from "../../scripts/api.js";
|
||||
import {
|
||||
collectActiveLorasFromChain,
|
||||
updateConnectedTriggerWords,
|
||||
chainCallback,
|
||||
mergeLoras,
|
||||
getAllGraphNodes,
|
||||
getNodeFromGraph,
|
||||
} from "/extensions/ComfyUI-Lora-Manager/utils.js";
|
||||
import { addLorasWidget } from "/extensions/ComfyUI-Lora-Manager/loras_widget.js";
|
||||
import { applyLoraValuesToText, debounce } from "/extensions/ComfyUI-Lora-Manager/lora_syntax_utils.js";
|
||||
import { applySelectionHighlight } from "/extensions/ComfyUI-Lora-Manager/trigger_word_highlight.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "LoraManager.LoraLoaderRemote",
|
||||
|
||||
setup() {
|
||||
api.addEventListener("lora_code_update", (event) => {
|
||||
this.handleLoraCodeUpdate(event.detail || {});
|
||||
});
|
||||
},
|
||||
|
||||
handleLoraCodeUpdate(message) {
|
||||
const nodeId = message?.node_id ?? message?.id;
|
||||
const graphId = message?.graph_id;
|
||||
const loraCode = message?.lora_code ?? "";
|
||||
const mode = message?.mode ?? "append";
|
||||
const numericNodeId = typeof nodeId === "string" ? Number(nodeId) : nodeId;
|
||||
|
||||
if (numericNodeId === -1) {
|
||||
const loraLoaderNodes = getAllGraphNodes(app.graph)
|
||||
.map(({ node }) => node)
|
||||
.filter((node) => node?.comfyClass === "Lora Loader (Remote, LoraManager)");
|
||||
|
||||
if (loraLoaderNodes.length > 0) {
|
||||
loraLoaderNodes.forEach((node) => {
|
||||
this.updateNodeLoraCode(node, loraCode, mode);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const node = getNodeFromGraph(graphId, numericNodeId);
|
||||
if (
|
||||
!node ||
|
||||
(node.comfyClass !== "Lora Loader (Remote, LoraManager)" &&
|
||||
node.comfyClass !== "Lora Stacker (Remote, LoraManager)" &&
|
||||
node.comfyClass !== "WanVideo Lora Select (Remote, LoraManager)")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
this.updateNodeLoraCode(node, loraCode, mode);
|
||||
},
|
||||
|
||||
updateNodeLoraCode(node, loraCode, mode) {
|
||||
const inputWidget = node.inputWidget;
|
||||
if (!inputWidget) return;
|
||||
|
||||
const currentValue = inputWidget.value || "";
|
||||
if (mode === "replace") {
|
||||
inputWidget.value = loraCode;
|
||||
} else {
|
||||
inputWidget.value = currentValue.trim()
|
||||
? `${currentValue.trim()} ${loraCode}`
|
||||
: loraCode;
|
||||
}
|
||||
|
||||
if (typeof inputWidget.callback === "function") {
|
||||
inputWidget.callback(inputWidget.value);
|
||||
}
|
||||
},
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeType.comfyClass === "Lora Loader (Remote, LoraManager)") {
|
||||
chainCallback(nodeType.prototype, "onNodeCreated", function () {
|
||||
this.serialize_widgets = true;
|
||||
|
||||
this.addInput("clip", "CLIP", { shape: 7 });
|
||||
this.addInput("lora_stack", "LORA_STACK", { shape: 7 });
|
||||
|
||||
let isUpdating = false;
|
||||
let isSyncingInput = false;
|
||||
|
||||
const self = this;
|
||||
let _mode = this.mode;
|
||||
Object.defineProperty(this, "mode", {
|
||||
get() { return _mode; },
|
||||
set(value) {
|
||||
const oldValue = _mode;
|
||||
_mode = value;
|
||||
if (self.onModeChange) self.onModeChange(value, oldValue);
|
||||
},
|
||||
});
|
||||
|
||||
this.onModeChange = function (newMode) {
|
||||
const allActiveLoraNames = collectActiveLorasFromChain(self);
|
||||
updateConnectedTriggerWords(self, allActiveLoraNames);
|
||||
};
|
||||
|
||||
const inputWidget = this.widgets[0];
|
||||
this.inputWidget = inputWidget;
|
||||
|
||||
const scheduleInputSync = debounce((lorasValue) => {
|
||||
if (isSyncingInput) return;
|
||||
isSyncingInput = true;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const nextText = applyLoraValuesToText(inputWidget.value, lorasValue);
|
||||
if (inputWidget.value !== nextText) inputWidget.value = nextText;
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
isSyncingInput = false;
|
||||
}
|
||||
});
|
||||
|
||||
this.lorasWidget = addLorasWidget(
|
||||
this, "loras",
|
||||
{ onSelectionChange: (selection) => applySelectionHighlight(this, selection) },
|
||||
(value) => {
|
||||
if (isUpdating) return;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const allActiveLoraNames = collectActiveLorasFromChain(this);
|
||||
updateConnectedTriggerWords(this, allActiveLoraNames);
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
}
|
||||
scheduleInputSync(value);
|
||||
}
|
||||
).widget;
|
||||
|
||||
inputWidget.callback = (value) => {
|
||||
if (isUpdating) return;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const currentLoras = this.lorasWidget.value || [];
|
||||
const mergedLoras = mergeLoras(value, currentLoras);
|
||||
this.lorasWidget.value = mergedLoras;
|
||||
const allActiveLoraNames = collectActiveLorasFromChain(this);
|
||||
updateConnectedTriggerWords(this, allActiveLoraNames);
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async loadedGraphNode(node) {
|
||||
if (node.comfyClass === "Lora Loader (Remote, LoraManager)") {
|
||||
let existingLoras = [];
|
||||
if (node.widgets_values && node.widgets_values.length > 0) {
|
||||
existingLoras = node.widgets_values[1] || [];
|
||||
}
|
||||
const mergedLoras = mergeLoras(node.widgets[0].value, existingLoras);
|
||||
node.lorasWidget.value = mergedLoras;
|
||||
}
|
||||
},
|
||||
});
|
||||
97
web/comfyui/lora_stacker_remote.js
Normal file
97
web/comfyui/lora_stacker_remote.js
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* JS shim for Remote Lora Stacker node.
|
||||
*/
|
||||
import { app } from "../../scripts/app.js";
|
||||
import {
|
||||
getActiveLorasFromNode,
|
||||
updateConnectedTriggerWords,
|
||||
updateDownstreamLoaders,
|
||||
chainCallback,
|
||||
mergeLoras,
|
||||
} from "/extensions/ComfyUI-Lora-Manager/utils.js";
|
||||
import { addLorasWidget } from "/extensions/ComfyUI-Lora-Manager/loras_widget.js";
|
||||
import { applyLoraValuesToText, debounce } from "/extensions/ComfyUI-Lora-Manager/lora_syntax_utils.js";
|
||||
import { applySelectionHighlight } from "/extensions/ComfyUI-Lora-Manager/trigger_word_highlight.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "LoraManager.LoraStackerRemote",
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeType.comfyClass === "Lora Stacker (Remote, LoraManager)") {
|
||||
chainCallback(nodeType.prototype, "onNodeCreated", async function () {
|
||||
this.serialize_widgets = true;
|
||||
this.addInput("lora_stack", "LORA_STACK", { shape: 7 });
|
||||
|
||||
let isUpdating = false;
|
||||
let isSyncingInput = false;
|
||||
|
||||
const inputWidget = this.widgets[0];
|
||||
this.inputWidget = inputWidget;
|
||||
|
||||
const scheduleInputSync = debounce((lorasValue) => {
|
||||
if (isSyncingInput) return;
|
||||
isSyncingInput = true;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const nextText = applyLoraValuesToText(inputWidget.value, lorasValue);
|
||||
if (inputWidget.value !== nextText) inputWidget.value = nextText;
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
isSyncingInput = false;
|
||||
}
|
||||
});
|
||||
|
||||
const result = addLorasWidget(
|
||||
this, "loras",
|
||||
{ onSelectionChange: (selection) => applySelectionHighlight(this, selection) },
|
||||
(value) => {
|
||||
if (isUpdating) return;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const isNodeActive = this.mode === undefined || this.mode === 0 || this.mode === 3;
|
||||
const activeLoraNames = new Set();
|
||||
if (isNodeActive) {
|
||||
value.forEach((lora) => { if (lora.active) activeLoraNames.add(lora.name); });
|
||||
}
|
||||
updateConnectedTriggerWords(this, activeLoraNames);
|
||||
updateDownstreamLoaders(this);
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
}
|
||||
scheduleInputSync(value);
|
||||
}
|
||||
);
|
||||
|
||||
this.lorasWidget = result.widget;
|
||||
|
||||
inputWidget.callback = (value) => {
|
||||
if (isUpdating) return;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const currentLoras = this.lorasWidget?.value || [];
|
||||
const mergedLoras = mergeLoras(value, currentLoras);
|
||||
if (this.lorasWidget) this.lorasWidget.value = mergedLoras;
|
||||
const isNodeActive = this.mode === undefined || this.mode === 0 || this.mode === 3;
|
||||
const activeLoraNames = isNodeActive ? getActiveLorasFromNode(this) : new Set();
|
||||
updateConnectedTriggerWords(this, activeLoraNames);
|
||||
updateDownstreamLoaders(this);
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async loadedGraphNode(node) {
|
||||
if (node.comfyClass === "Lora Stacker (Remote, LoraManager)") {
|
||||
let existingLoras = [];
|
||||
if (node.widgets_values && node.widgets_values.length > 0) {
|
||||
existingLoras = node.widgets_values[1] || [];
|
||||
}
|
||||
const inputWidget = node.inputWidget || node.widgets[0];
|
||||
const mergedLoras = mergeLoras(inputWidget.value, existingLoras);
|
||||
node.lorasWidget.value = mergedLoras;
|
||||
}
|
||||
},
|
||||
});
|
||||
89
web/comfyui/wanvideo_remote.js
Normal file
89
web/comfyui/wanvideo_remote.js
Normal file
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* JS shim for Remote WanVideo Lora Select node.
|
||||
*/
|
||||
import { app } from "../../scripts/app.js";
|
||||
import {
|
||||
getActiveLorasFromNode,
|
||||
updateConnectedTriggerWords,
|
||||
chainCallback,
|
||||
mergeLoras,
|
||||
} from "/extensions/ComfyUI-Lora-Manager/utils.js";
|
||||
import { addLorasWidget } from "/extensions/ComfyUI-Lora-Manager/loras_widget.js";
|
||||
import { applyLoraValuesToText, debounce } from "/extensions/ComfyUI-Lora-Manager/lora_syntax_utils.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "LoraManager.WanVideoLoraSelectRemote",
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeType.comfyClass === "WanVideo Lora Select (Remote, LoraManager)") {
|
||||
chainCallback(nodeType.prototype, "onNodeCreated", async function () {
|
||||
this.serialize_widgets = true;
|
||||
|
||||
this.addInput("prev_lora", "WANVIDLORA", { shape: 7 });
|
||||
this.addInput("blocks", "SELECTEDBLOCKS", { shape: 7 });
|
||||
|
||||
let isUpdating = false;
|
||||
let isSyncingInput = false;
|
||||
|
||||
// text widget is at index 2 (after low_mem_load, merge_loras)
|
||||
const inputWidget = this.widgets[2];
|
||||
this.inputWidget = inputWidget;
|
||||
|
||||
const scheduleInputSync = debounce((lorasValue) => {
|
||||
if (isSyncingInput) return;
|
||||
isSyncingInput = true;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const nextText = applyLoraValuesToText(inputWidget.value, lorasValue);
|
||||
if (inputWidget.value !== nextText) inputWidget.value = nextText;
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
isSyncingInput = false;
|
||||
}
|
||||
});
|
||||
|
||||
const result = addLorasWidget(this, "loras", {}, (value) => {
|
||||
if (isUpdating) return;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const activeLoraNames = new Set();
|
||||
value.forEach((lora) => { if (lora.active) activeLoraNames.add(lora.name); });
|
||||
updateConnectedTriggerWords(this, activeLoraNames);
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
}
|
||||
scheduleInputSync(value);
|
||||
});
|
||||
|
||||
this.lorasWidget = result.widget;
|
||||
|
||||
inputWidget.callback = (value) => {
|
||||
if (isUpdating) return;
|
||||
isUpdating = true;
|
||||
try {
|
||||
const currentLoras = this.lorasWidget?.value || [];
|
||||
const mergedLoras = mergeLoras(value, currentLoras);
|
||||
if (this.lorasWidget) this.lorasWidget.value = mergedLoras;
|
||||
const activeLoraNames = getActiveLorasFromNode(this);
|
||||
updateConnectedTriggerWords(this, activeLoraNames);
|
||||
} finally {
|
||||
isUpdating = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async loadedGraphNode(node) {
|
||||
if (node.comfyClass === "WanVideo Lora Select (Remote, LoraManager)") {
|
||||
let existingLoras = [];
|
||||
if (node.widgets_values && node.widgets_values.length > 0) {
|
||||
// 0=low_mem_load, 1=merge_loras, 2=text, 3=loras
|
||||
existingLoras = node.widgets_values[3] || [];
|
||||
}
|
||||
const inputWidget = node.inputWidget || node.widgets[2];
|
||||
const mergedLoras = mergeLoras(inputWidget.value, existingLoras);
|
||||
node.lorasWidget.value = mergedLoras;
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user