Comfy-Org / Comfy-Org/ComfyUI_frontend
fix: add node-level slot layout dirty flag to prevent drawConnections race
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Context
From PR #10195 review discussion: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10195#discussion_r2976974791
When switching from Vue to legacy mode, `drawConnections` (background canvas) can fire before `drawNode` (foreground canvas) in the same frame, leaving `input.pos` unset and causing links to fall back to the node header.
## Current workaround
PR #10195 forces `arrange()` on all nodes before `setDirty` during the Vue-to-legacy switch. This ensures slot positions are computed before the first legacy render pass.
## Proposed improvement
Add a node-level dirty flag (e.g. `_slotLayoutDirty`) that:
- Is set when node layout changes (resize, widget add/remove, collapse toggle)
- Is cleared by `arrange()`
- Is checked by `drawConnections` to trigger on-demand `arrange()` before reading `input.pos`
This would make slot positioning deterministic without needing the brute-force pre-pass.
Related: the broader question of whether we need an explicit readiness gate for the Vue-to-legacy transition rather than relying on timing.
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10404-fix-add-node-level-slot-layout-dirty-flag-to-prevent-drawConnections-race-32c6d73d3650813caba8e6ba730c0e71) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.