Comfy-Org / Comfy-Org/ComfyUI_frontend
RFC: Replace hardcoded CANVAS_IMAGE_PREVIEW_NODE_TYPES with declarative/dynamic preview support detection
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Problem
`CANVAS_IMAGE_PREVIEW_NODE_TYPES` is a hardcoded `Set` of node type strings that determines which interior nodes get a `$$canvas-image-preview` pseudo-widget promoted to their parent subgraph node. Every new node type that shows previews must be manually added — and omissions cause silent failures (no preview on subgraph, no error).
Recent examples of this gap:
- `GLSLShader` was missing until #9198
- `LoadImage` and `LoadVideo` were missing until #10530
- Any custom node implementing image previews would never get promotion
Additionally, `LoadImage` writes previews through a different codepath (`setNodeOutputs` with `type: "input"`) than `SaveImage`/`PreviewImage` (execution output). The preview store has two separate data paths (`nodeOutputs` vs `nodePreviewImages`) that converge in `getNodeImageUrls`, but diverge in reactivity tracking — which caused #10165.
## Proposed Direction
### Option A: Declarative node definition flag
Add a `supportsPreview: true` field to `ComfyNodeDef` schema. Node authors declare preview support; the promotion system reads it instead of checking a hardcoded Set.
### Option B: Dynamic detection
If a node has `node.imgs` populated or has a widget matching `isPreviewPseudoWidget()`, it qualifies for preview promotion. The `showCanvasImagePreview` function already gates on `node.imgs?.length` — the promotion system should mirror this.
### Option C: Unify preview data paths
Merge `nodeOutputs` and `nodePreviewImages` into a single reactive store with typed entries, eliminating the split that caused #10165 and #9123. This would make all preview sources automatically tracked.
## Scope
- Remove `CANVAS_IMAGE_PREVIEW_NODE_TYPES` hardcoded set
- Ensure custom nodes with previews auto-promote without frontend changes
- Unify or clearly document the `nodeOutputs` vs `nodePreviewImages` split
- Maintain backward compatibility with existing promotion serialization (`proxyWidgets`)
## Related PRs
- #9198 (added GLSLShader)
- #10165 / #10198 (nodePreviewImages reactivity fix)
- #9123 (preserve input asset previews)
- #10530 (added LoadImage/LoadVideo)
- #8856 (proxy-widget-v2 architecture)
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10531-RFC-Replace-hardcoded-CANVAS_IMAGE_PREVIEW_NODE_TYPES-with-declarative-dynamic-previ-32e6d73d36508159bc08de0d4ef24867) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.