Comfy-Org / Comfy-Org/ComfyUI_frontend

The KSampler's seed can't update automatically in Vue nodes, even though I have set the mode to randomzie

Open
#5,704 1 comment 0 reactions 0 assignees View on GitHub
area:nodes area:ui area:vue-migration
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Problem Summary

**Issue**: KSampler seed values with `control_after_generate: "randomize"` work correctly in LiteGraph nodes but fail to update in Vue-rendered nodes.

**Current Behavior**:
- LiteGraph nodes: Seed randomizes after each execution ✅
- Vue nodes: Seed stays fixed despite "randomize" setting ❌

## Technical Root Cause

Vue widgets are missing the `beforeQueued`/`afterQueued` callback implementations that drive the `control_after_generate` mechanism.

### How control_after_generate Actually Works

**Control Widget Creation** (src/scripts/widgets.ts):
- Widgets with control_after_generate: true or named "seed"/"noise_seed" automatically get control widgets
- Control widgets have beforeQueued/afterQueued callbacks that execute value updates

**Execution Flow** (src/scripts/app.ts):
- Before prompt: executeWidgetsCallback(nodes, "beforeQueued")
- After prompt: executeWidgetsCallback(nodes, "afterQueued")

**Widget Callbacks** (src/utils/litegraphUtil.ts):
- executeWidgetsCallback() iterates through node widgets and calls widget[callbackName]()
- This triggers randomization, increment, decrement based on control setting

### Missing Implementation in Vue Widgets

**Problem**: Vue integer widgets create control widgets correctly but Vue rendering does not execute the lifecycle callbacks.

The executeWidgetsCallback() function only affects LiteGraph widget instances, not Vue component state.

## Affected Components

- Widget Type: Integer widgets with control_after_generate (seeds)
- Nodes: KSampler, KSamplerAdvanced, any node with seed controls
- System: Vue node rendering system

## Solution Required

Implement callback synchronization between LiteGraph widget callbacks and Vue component state in the Vue widget system.

## Reproduction

1. Add KSampler in Vue node mode
2. Set seed control to "randomize"
3. Execute workflow multiple times
4. Observe: Seed value does not change in Vue UI (but would change in LiteGraph mode)

---

**Attachments**: https://github.com/user-attachments/assets/1ebdd8b1-5e14-4643-96a8-888babb3a43c

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-5704-The-KSampler-s-seed-can-t-update-automatically-in-Vue-nodes-even-though-I-have-set-th-2746d73d365081c5a3d1e4bec90ff9b0) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.