Comfy-Org / Comfy-Org/ComfyUI_frontend

refactor(changeTracker): replace local clone() with shared clone util from @/scripts/utils

Open
#9,414 0 comments 0 reactions 1 assignee Claimed by @DrJKL View on GitHub
developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

Follow-up to #9387. The PR replaced `clone(app.nodeOutputs)` in `changeTracker.store()` with `useNodeOutputStore().snapshotOutputs()`, which internally uses the shared `clone()` utility from `@/scripts/utils` (preferring `structuredClone` with a JSON fallback over the local `JSON.parse(JSON.stringify(...))` implementation).

The remaining usages of the local `clone` function in `src/scripts/changeTracker.ts` should be migrated to use the shared utility as well.

## Remaining call sites

- `reset()`: `this.activeState = clone(state)`
- `reset()`: `this.initialState = clone(this.activeState)`
- `checkState()`: `const currentState = clone(app.rootGraph.serialize()) as ComfyWorkflowJSON`

## Proposed change

1. Remove the local `clone` function definition (~line 22 in `src/scripts/changeTracker.ts`).
2. Add `import { clone } from '@/scripts/utils'`.
3. Replace all remaining local `clone()` call sites with the imported utility.

## Context

- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/9387
- Review comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/9387#discussion_r2887461142
- Requested by: @DrJKL

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-9414-refactor-changeTracker-replace-local-clone-with-shared-clone-util-from-scripts-u-31a6d73d365081e9a7a0c46e658cc488) 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.