Comfy-Org / Comfy-Org/ComfyUI_frontend

Combo widget displays wrong model name when workflow loads despite correct model being executed

Open
#11,690 1 comment 0 reactions 0 assignees View on GitHub
area:ui area:widgets Potential Bug
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Bug Description

When loading a workflow that contains a model selector widget (e.g. UNetLoader), the UI displays an incorrect model name in the dropdown — specifically the first alphabetically sorted model in the merged model list — even though the `widgets_values` in the workflow JSON is correct and the correct model is actually loaded and executed.

## Steps to Reproduce

1. Configure ComfyUI with model paths from multiple directories (e.g. local `models/diffusion_models/` and an external path via `extra_model_paths.yaml`)
2. Ensure the external directory contains a model whose filename sorts alphabetically before the intended model (e.g. `Qwen-...` sorts before `wan2.2_...`)
3. Load a workflow that has a model selector widget pre-configured with the correct model (`wan2.2_i2v_high_noise_14B_fp16.safetensors` in `widgets_values`)
4. Observe: the UI dropdown shows `Qwen-...` (the first alphabetically) instead of `wan2.2_...`
5. The correct model (`wan2.2`) is still loaded and executed — this is purely a UI display bug

## Expected vs Actual Behavior

- **Expected**: The model dropdown should display `wan2.2_i2v_high_noise_14B_fp16.safetensors` (matching `widgets_values`)
- **Actual**: The dropdown displays `Qwen-...` (the first alphabetically in the merged/sorted model list)

## Environment

- ComfyUI version: 0.19.3
- Frontend package: `comfyui-frontend-package` v1.42.15
- Model paths: multiple directories merged via `extra_model_paths.yaml`

## Root Cause Analysis

The issue appears to be in the `WidgetValueStore` initialization sequence in `BaseWidget.setNodeId()` (`src/lib/litegraph/src/widgets/BaseWidget.ts`):

When a node is configured from serialized workflow data:
1. `LGraphNode.configure()` correctly sets `widget.value = widgets_values[i]` from the workflow JSON
2. `LGraphNode.addWidget()` is then called, which invokes `widget.setNodeId(nodeId)` to register the widget with `WidgetValueStore`
3. In `setNodeId()`, the widget value written to `WidgetValueStore` is `this.value` — but this may reference the value at registration time rather than the value set during `configure()`

This results in `WidgetValueStore` holding a stale/initial value while `widget.value` itself is correct. The Vue UI reads from `WidgetValueStore` via `widgetState.value`, producing the wrong display name.

## Additional Notes

- The bug is reproducible specifically when models from multiple directories are merged and the intended model is NOT the first alphabetically
- Clicking the dropdown and re-selecting the correct model corrects the display (since user interaction updates the store)
- The actual model execution uses the correct `widgets_values` — only the display is affected
- A similar issue was referenced in the `BaseWidget` code comments regarding initial value resolution: https://github.com/Comfy-Org/ComfyUI_frontend/issues/9194

## Suggested Investigation

- Verify the exact sequence of `configure()` → `addWidget()` → `setNodeId()` for widgets during graph deserialization
- Check whether `WidgetValueStore` registration should preserve the value set during `configure()` rather than re-reading from the widget's internal state at registration time
- Consider whether `setNodeId()` should update the stored value if a value was already set via `configure()`

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11690-Combo-widget-displays-wrong-model-name-when-workflow-loads-despite-correct-model-bein-34f6d73d365081409706db872d861d66) 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.