diff --git a/web/comfyui/loras_widget.js b/web/comfyui/loras_widget.js index 094c83b1..23377793 100644 --- a/web/comfyui/loras_widget.js +++ b/web/comfyui/loras_widget.js @@ -14,6 +14,7 @@ import { initDrag, createContextMenu, initHeaderDrag, initReorderDrag, handleKey import { forwardMiddleMouseToCanvas } from "./utils.js"; import { PreviewTooltip } from "./preview_tooltip.js"; import { ensureLmStyles } from "./lm_styles_loader.js"; +import { getStrengthStepPreference } from "./settings.js"; export function addLorasWidget(node, name, opts, callback) { ensureLmStyles(); @@ -416,7 +417,7 @@ export function addLorasWidget(node, name, opts, callback) { const loraIndex = lorasData.findIndex(l => l.name === name); if (loraIndex >= 0) { - lorasData[loraIndex].strength = (parseFloat(lorasData[loraIndex].strength) - 0.05).toFixed(2); + lorasData[loraIndex].strength = (parseFloat(lorasData[loraIndex].strength) - getStrengthStepPreference()).toFixed(2); // Sync clipStrength if collapsed syncClipStrengthIfCollapsed(lorasData[loraIndex]); @@ -488,7 +489,7 @@ export function addLorasWidget(node, name, opts, callback) { const loraIndex = lorasData.findIndex(l => l.name === name); if (loraIndex >= 0) { - lorasData[loraIndex].strength = (parseFloat(lorasData[loraIndex].strength) + 0.05).toFixed(2); + lorasData[loraIndex].strength = (parseFloat(lorasData[loraIndex].strength) + getStrengthStepPreference()).toFixed(2); // Sync clipStrength if collapsed syncClipStrengthIfCollapsed(lorasData[loraIndex]); @@ -541,7 +542,7 @@ export function addLorasWidget(node, name, opts, callback) { const loraIndex = lorasData.findIndex(l => l.name === name); if (loraIndex >= 0) { - lorasData[loraIndex].clipStrength = (parseFloat(lorasData[loraIndex].clipStrength) - 0.05).toFixed(2); + lorasData[loraIndex].clipStrength = (parseFloat(lorasData[loraIndex].clipStrength) - getStrengthStepPreference()).toFixed(2); const newValue = formatLoraValue(lorasData); updateWidgetValue(newValue); @@ -611,7 +612,7 @@ export function addLorasWidget(node, name, opts, callback) { const loraIndex = lorasData.findIndex(l => l.name === name); if (loraIndex >= 0) { - lorasData[loraIndex].clipStrength = (parseFloat(lorasData[loraIndex].clipStrength) + 0.05).toFixed(2); + lorasData[loraIndex].clipStrength = (parseFloat(lorasData[loraIndex].clipStrength) + getStrengthStepPreference()).toFixed(2); const newValue = formatLoraValue(lorasData); updateWidgetValue(newValue); diff --git a/web/comfyui/settings.js b/web/comfyui/settings.js index 4a1c3f9b..54b6a02d 100644 --- a/web/comfyui/settings.js +++ b/web/comfyui/settings.js @@ -24,6 +24,9 @@ const NEW_TAB_TEMPLATE_DEFAULT = "Default"; const NEW_TAB_ZOOM_LEVEL = 0.8; +const STRENGTH_STEP_SETTING_ID = "loramanager.strength_step"; +const STRENGTH_STEP_DEFAULT = 0.05; + // ============================================================================ // Helper Functions // ============================================================================ @@ -232,6 +235,32 @@ const getNewTabTemplatePreference = (() => { }; })(); +const getStrengthStepPreference = (() => { + let settingsUnavailableLogged = false; + + return () => { + const settingManager = app?.extensionManager?.setting; + if (!settingManager || typeof settingManager.get !== "function") { + if (!settingsUnavailableLogged) { + console.warn("LoRA Manager: settings API unavailable, using default strength step."); + settingsUnavailableLogged = true; + } + return STRENGTH_STEP_DEFAULT; + } + + try { + const value = settingManager.get(STRENGTH_STEP_SETTING_ID); + return value ?? STRENGTH_STEP_DEFAULT; + } catch (error) { + if (!settingsUnavailableLogged) { + console.warn("LoRA Manager: unable to read strength step setting, using default.", error); + settingsUnavailableLogged = true; + } + return STRENGTH_STEP_DEFAULT; + } + }; +})(); + // ============================================================================ // Register Extension with All Settings // ============================================================================ @@ -293,6 +322,19 @@ app.registerExtension({ tooltip: "Choose a template workflow to load when creating a new workflow tab. 'Default (Blank)' keeps ComfyUI's original blank workflow behavior.", category: ["LoRA Manager", "Workflow", "New Tab Template"], }, + { + id: STRENGTH_STEP_SETTING_ID, + name: "Strength Adjustment Step", + type: "slider", + attrs: { + min: 0.01, + max: 0.1, + step: 0.01, + }, + defaultValue: STRENGTH_STEP_DEFAULT, + tooltip: "Step size for adjusting LoRA strength via arrow buttons or keyboard (default: 0.05)", + category: ["LoRA Manager", "LoRA Widget", "Strength Step"], + }, ], async setup() { await loadWorkflowOptions(); @@ -375,4 +417,5 @@ export { getTagSpaceReplacementPreference, getUsageStatisticsPreference, getNewTabTemplatePreference, + getStrengthStepPreference, };