Comfy-Org / Comfy-Org/ComfyUI_frontend
refactor: create rename-aware detach/attach helper in workflowStore to avoid duplicate mutation paths
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Summary
In `src/platform/workflow/management/stores/workflowStore.ts`, the `renameWorkflow` function currently performs inline mutations of `workflowLookup` and `openWorkflowPaths` after the rename operation (introduced in #9345) instead of reusing the existing `detachWorkflow`/`attachWorkflow` helpers:
```ts
delete workflowLookup.value[oldPath]
workflowLookup.value[workflow.path] = workflow
const openIndex = openWorkflowPaths.value.indexOf(oldPath)
if (openIndex !== -1) {
openWorkflowPaths.value.splice(openIndex, 1, workflow.path)
}
```
This creates a second mutation path for the same data structures, so any future changes to lookup/open-paths logic need to be updated in two places.
## Suggested Follow-up
Consider introducing a rename-aware helper (e.g., `reattachWorkflow(workflow, oldPath, openIndex)`) or adapting the existing `detachWorkflow`/`attachWorkflow` helpers to accept an old-path argument, so that `renameWorkflow` can delegate through the same single code path.
## Context
- Raised by @christian-byrne during review of PR #9345
- Comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/9345#discussion_r2886742393
- Requested by @DrJKL
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-9407-refactor-create-rename-aware-detach-attach-helper-in-workflowStore-to-avoid-duplicate-31a6d73d3650812f9099dda7cfa14273) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.