Comfy-Org / Comfy-Org/ComfyUI_frontend
Investigate simplification of `promptRenameWidget` in `widgetUtil.ts`
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Overview
Investigate whether the `promptRenameWidget` function in `src/utils/widgetUtil.ts` can be further simplified.
## Context
This was flagged during the review of #10245 (fix: App mode - renaming widgets on subgraphs) by @pythongosssss.
## Current Implementation
The function currently (lines 96–113 of `src/utils/widgetUtil.ts`):
1. Prompts the user for a new widget label via `promptWidgetLabel`.
2. Returns `null` if the prompt was cancelled or the input is empty after trimming.
3. Delegates to `renameWidget` to apply the rename (handling subgraph promotion and input propagation).
4. Fires `widget.callback` and marks the canvas dirty.
## Investigation Points
- Can the `null`-check / early-return logic be collapsed or moved into a shared utility?
- Can `renameWidget` absorb the canvas-dirty / callback side effects, removing them from `promptRenameWidget`?
- Are there other call sites that duplicate parts of this logic that could be unified?
- Consider whether the `parents` parameter handling (now broadened to include subgraph nodes without explicit parents as of #10245) can be made more ergonomic.
## References
- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10245
- File: `src/utils/widgetUtil.ts`
- Requested by: @pythongosssss
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10305-Investigate-simplification-of-promptRenameWidget-in-widgetUtil-ts-3286d73d3650816f87c0db8648e73e62) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.