mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 22:52:12 -03:00
feat(lora-cycler): implement batch queue synchronization with dual-index mechanism
- Add execution_index and next_index fields to CyclerConfig interface - Introduce beforeQueued hook in widget to handle index shifting for batch executions - Use execution_index when provided, fall back to current_index for single executions - Track execution state with Symbol to differentiate first vs subsequent executions - Update state management to handle dual-index logic for proper LoRA cycling in batch queues
This commit is contained in:
@@ -34,6 +34,9 @@ const props = defineProps<{
|
||||
// State management
|
||||
const state = useLoraCyclerState(props.widget)
|
||||
|
||||
// Symbol to track if the widget has been executed at least once
|
||||
const HAS_EXECUTED = Symbol('HAS_EXECUTED')
|
||||
|
||||
// Track last known pool config hash
|
||||
const lastPoolConfigHash = ref('')
|
||||
|
||||
@@ -124,6 +127,28 @@ onMounted(async () => {
|
||||
state.restoreFromConfig(props.widget.value as CyclerConfig)
|
||||
}
|
||||
|
||||
// Add beforeQueued hook to handle index shifting for batch queue synchronization
|
||||
// This ensures each execution uses a different LoRA in the cycle
|
||||
;(props.widget as any).beforeQueued = () => {
|
||||
if ((props.widget as any)[HAS_EXECUTED]) {
|
||||
// After first execution: shift indices (previous next_index becomes execution_index)
|
||||
state.generateNextIndex()
|
||||
} else {
|
||||
// First execution: just initialize next_index (execution_index stays null)
|
||||
// This means first execution uses current_index from widget
|
||||
state.initializeNextIndex()
|
||||
;(props.widget as any)[HAS_EXECUTED] = true
|
||||
}
|
||||
|
||||
// Update the widget value so the indices are included in the serialized config
|
||||
const config = state.buildConfig()
|
||||
if ((props.widget as any).updateConfig) {
|
||||
;(props.widget as any).updateConfig(config)
|
||||
} else {
|
||||
props.widget.value = config
|
||||
}
|
||||
}
|
||||
|
||||
// Mark component as mounted
|
||||
isMounted.value = true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user