Comfy-Org / Comfy-Org/ComfyUI_frontend
Reduce minimap redraws from non-rendered graphChanged mutations
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 704
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 512
Description
## Summary
Investigate and reduce unnecessary minimap full redraws caused by the existing `graphChanged` event path when a graph mutation does not change minimap output.
## Background
The minimap change-detection optimization in PR #15029 avoids digest changes for `layoutStore` mutations such as node z-index updates and reroute dragging. However, `useMinimapGraph.init()` still registers `api.addEventListener('graphChanged', handleGraphChangedThrottled)`. A non-rendered graph mutation can trigger this path and cause `onGraphChanged()` to run `forceFullRedraw()` and `updateMinimap()`.
For example, bringing a Vue node to the front can produce a full minimap data rebuild even when node geometry is byte-identical. This is pre-existing behavior. The handler is throttled to 500 ms, not the new 100 ms polling interval.
Do not add `bgcolor` to the digest or gate the existing handler in PR #15029. That would change redraw behavior and can introduce missed colour updates. Evaluate the behavior separately in a future PR.
## Affected area
- `src/renderer/extensions/minimap/composables/useMinimapGraph.ts`
- The minimap redraw path initiated by `api` `graphChanged` events
## Required changes
1. Identify which `graphChanged` mutations require a minimap redraw.
2. Design a safe mechanism that avoids full minimap rebuilds for mutations that do not affect rendered minimap output.
3. Preserve redraws for every minimap-visible change, including node colour changes.
4. Add focused tests for non-rendered mutations and minimap-visible mutations.
## Acceptance criteria
- A node z-index-only mutation does not cause an unnecessary full minimap rebuild through the `graphChanged` path.
- Reroute-only mutations do not cause an unnecessary full minimap rebuild through the `graphChanged` path.
- Node geometry, connection, mode, error-state, and minimap-visible colour changes still refresh the minimap.
- The solution has tests for both skipped and required redraws.
## Backlinks
- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/15029
- Review discussion: https://github.com/Comfy-Org/ComfyUI_frontend/pull/15029#discussion_r3779395721
Requested by @christian-byrne.
Contributor guide
Assessment
This issue has not been assessed yet.