Comfy-Org / Comfy-Org/ComfyUI_frontend
refactor: split insertImagesAt dual behavior into separate functions in ComfyHubExamplesStep
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Summary
The `insertImagesAt` function in `src/platform/workflow/sharing/components/publish/ComfyHubExamplesStep.vue` has non-obvious dual behavior:
- When there is remaining capacity below `MAX_EXAMPLES`, it **inserts** new images at the given index.
- When the gallery is already at max capacity (`remaining <= 0`), it silently **replaces** existing images starting at the given index.
The name `insertImagesAt` implies insertion only, which makes the replacement path surprising to maintainers.
## Suggested Refactor
Consider splitting into two clearly named helpers:
- `insertNewImagesAt(index, files)` — only inserts when capacity is available
- `replaceImagesAt(index, files)` — replaces existing images when at max capacity
Or, alternatively, add an explicit comment block in the function body describing the dual-path intent.
## Context
Flagged as a nitpick (non-blocking) during review of PR #10128 by @christian-byrne:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/10128#discussion_r2970254279
Requested by: @christian-byrne
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10372-refactor-split-insertImagesAt-dual-behavior-into-separate-functions-in-ComfyHubExamp-32a6d73d36508199a839ffea100d64b4) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.