Comfy-Org / Comfy-Org/ComfyUI_frontend

Migrate stringified numeric COMBO values when loading workflows

Open
#14,641 2 comments 1 reaction 1 assignee Claimed by @christian-byrne View on GitHub
area:widgets
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

Add a load-time migration for numeric COMBO widget values that were persisted as strings during the regression window.

For example, a workflow can contain `"duration": "10"` when the combo options are `[6, 8, 10]`. The widget can render as valid, but the queued prompt still sends the string value and pricing output can remain empty.

## Required changes

- During workflow load or graph configuration, detect a persisted string value that exactly represents a numeric combo option.
- Restore the value using the option's original numeric type.
- Do not reset a valid value to the first option.
- Do not use a render-time watcher or direct UI-side write-back. The migration must follow the repository command and graph-state rules.
- Ensure pricing cache behavior can recover after migration. Current cache signatures collapse `10` and `'10'`, which can reuse an empty-label cache entry.

## Affected areas

- `LGraphNode.configure` load behavior
- Combo reset and validation logic in `app.ts`
- Numeric COMBO value handling
- Pricing cache logic in `useNodePricing.ts`

## Rationale

`LGraphNode.configure` assigns persisted widget values without coercion. The combo reset path in `app.ts` runs only for nullish values or when `reset_invalid_values` is set. A string value such as `"10"` therefore remains persisted and reaches prompt generation as a string.

Users can manually re-select the COMBO value as a temporary workaround. The migration should repair affected workflows without requiring manual re-selection.

## Acceptance criteria

- A workflow loaded with `"duration": "10"` and numeric options `[6, 8, 10]` stores and queues `10` as a number after the migration.
- A string that does not exactly match a numeric option remains invalid or follows existing invalid-value handling. The migration must not silently select a different option.
- Loading a workflow does not introduce a render-phase graph mutation or dirty the workflow solely because it was opened.
- Pricing information recomputes correctly after the value is migrated and does not reuse a stale entry that conflates `10` with `'10'`.
- Add focused automated coverage for load, prompt serialization, and pricing-cache recovery.

## Context

Requested by @christian-byrne.

Related pull request: https://github.com/Comfy-Org/ComfyUI_frontend/pull/14460

Related discussion: https://github.com/Comfy-Org/ComfyUI_frontend/pull/14460#discussion_r3695283226

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.