Skip to content

Emit the document canvas from ImageCompositor for the layer editor - #15742

Open
jtydhr88 wants to merge 1 commit into
masterfrom
fix/compositor-canvas-emit
Open

Emit the document canvas from ImageCompositor for the layer editor#15742
jtydhr88 wants to merge 1 commit into
masterfrom
fix/compositor-canvas-emit

Conversation

@jtydhr88

@jtydhr88 jtydhr88 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

The compositor only returned per-layer refs, fingerprints, and bboxes to the frontend.

When the editor opened without a matching saved state it sized its canvas to the max natural size of the layers, which is wrong for cropped and placed layers (e.g. See-through's decomposed parts): a 1280x1280 document opened as ~855x762.
Worse, saving from that state persisted the wrong canvas back into the widget, so the replayed composite was also clipped.

Report the canvas the composite was actually rendered at via ui[compositor_canvas] (the saved state's canvas on replay, otherwise the document canvas or the placed-layer extent) so the editor can size to it.

Need FE PR Comfy-Org/ComfyUI_frontend#14941

before

2026-08-19.22-50-55.mp4

after

2026-08-19.23-12-04.mp4

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 50f6476f-85e2-4ed8-bbea-d6be45d9af20

📥 Commits

Reviewing files that changed from the base of the PR and between 5ab2f7a and 6d44b79.

📒 Files selected for processing (2)
  • comfy_extras/nodes_compositor.py
  • tests-unit/comfy_extras_test/compositor_node_test.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (8)
  • GitHub Check: test (windows-latest)
  • GitHub Check: test (macos-latest)
  • GitHub Check: Run Pylint
  • GitHub Check: test (macos-latest)
  • GitHub Check: test (windows-2022)
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test
🧰 Additional context used
📓 Path-based instructions (6)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Keep changes small, direct, and limited to the narrowest necessary code path and smallest number of files.
Prefer practical fixes, minimal dependencies, and existing repository patterns; remove obsolete, dead, unreachable, or unused code.
Preserve existing APIs, node names, model-loading behavior, file layout, and workflow compatibility unless replacement is explicitly intended.
Core ComfyUI must not add outbound internet requests, telemetry, tracking, reporting, remote configuration, or background network activity. User-authorized model downloads are limited to the requested artifact and must exclude telemetry and unrelated metadata.

Files:

  • comfy_extras/nodes_compositor.py
  • tests-unit/comfy_extras_test/compositor_node_test.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Keep state and capability flags on the object that owns the behavior. Prefer explicit parent-owned attributes over probing child objects with getattr; use child checks only when the child owns the delegated behavior.
Preserve shared method signatures, argument order, return shapes, side effects, and error behavior unless every affected caller and interface is intentionally updated.
Do not add unused compatibility parameters, flags, attributes, constructor options, or model-specific options to shared helpers; keep one-off behavior at the integration boundary.
Normalize third-party return conventions at integration boundaries so core code receives the expected type and shape; avoid undocumented caller-side unwrapping.
Do not add torch.no_grad, torch.inference_mode, or inference-mode wrappers. Do not add model freeze/unfreeze toggles; only disable globally enabled inference mode when a training path requires gradients.
Remove inference-only training behavior such as dropout while preserving checkpoint and state-dict compatibility; use nn.Identity when deleting a module would alter keys or ordering.
Keep imports at module scope except established optional-backend probes or imports required to avoid cycles; avoid unnecessary try/except blocks and use specific exceptions with useful fallbacks.
Do not add workarounds for unsupported library versions, especially PyTorch exception-and-float-cast retries, unless a comment names the exact versions still requiring them.
Let unsupported model formats, invalid quantization metadata, and bad states fail with clear errors instead of silently degrading output.
Match local style, keep comments sparse and useful, and remove comments that merely restate obvious code.
Treat dtype, device placement, VRAM use, and offloading as correctness concerns across CPU, CUDA, ROCm, MPS, DirectML, XPU, NPU, and low-VRAM environments.
Prefer existing ComfyUI and Comfy Kitchen operations, quantization helpers, cast/offload helpe...

Files:

  • comfy_extras/nodes_compositor.py
  • tests-unit/comfy_extras_test/compositor_node_test.py
**/*.{py,json}

📄 CodeRabbit inference engine (AGENTS.md)

Treat legacy combo, io.Combo, and io.DynamicCombo values affecting filesystem access as untrusted; revalidate them at load/save boundaries with folder_paths, containment checks, or fixed allowlists.

Files:

  • comfy_extras/nodes_compositor.py
  • tests-unit/comfy_extras_test/compositor_node_test.py
**/*.{py,md,txt,json}

📄 CodeRabbit inference engine (AGENTS.md)

Keep warning and info messages short and actionable, remove noisy or misleading logging, and make documentation edits concise, factual, and tied to changed behavior.

Files:

  • comfy_extras/nodes_compositor.py
  • tests-unit/comfy_extras_test/compositor_node_test.py
**

⚙️ CodeRabbit configuration file

**: IMPORTANT: Only comment on issues directly introduced by this PR's code changes.
Treat AGENTS.md as mandatory repository policy, not optional style guidance.
Flag PR changes that violate AGENTS.md even when the code is otherwise functional.
In particular, enforce architecture boundaries, dtype/device/memory rules,
interface contracts, import style, no unnecessary try/except blocks, no inline
imports, no outbound internet paths in core ComfyUI, and narrow scoped fixes.
Prefer direct findings over suggestions when a rule is violated. Only ignore
AGENTS.md when it clearly conflicts with a newer explicit maintainer instruction
in the PR.
Do NOT flag pre-existing issues in code that was merely moved, re-indented,
de-indented, or reformatted without logic changes. If code appears in the diff
only due to whitespace or structural reformatting (e.g., removing a with: block),
treat it as unchanged. Contributors should not feel obligated to address
pre-existing issues outside the scope of their contribution.

Files:

  • comfy_extras/nodes_compositor.py
  • tests-unit/comfy_extras_test/compositor_node_test.py
comfy_extras/**

⚙️ CodeRabbit configuration file

comfy_extras/**: Community-contributed extra nodes. Focus on:

  • Consistency with node patterns (INPUT_TYPES, RETURN_TYPES, FUNCTION, CATEGORY)
  • No breaking changes to existing node interfaces

Files:

  • comfy_extras/nodes_compositor.py
🔇 Additional comments (4)
comfy_extras/nodes_compositor.py (2)

531-533: LGTM!


549-550: 🗄️ Data Integrity & Integration

Add or identify the frontend consumer for compositor_canvas. This repository contains no tracked frontend reader for this metadata, so the emitted field is unconsumed here. If the consumer is maintained externally, confirm that it uses [{w, h}] only when present and preserves the previous fallback when absent.

tests-unit/comfy_extras_test/compositor_node_test.py (2)

13-13: LGTM!


74-113: LGTM!


📝 Walkthrough

Walkthrough

ImageCompositor.execute now restores the saved canvas during replay. It emits compositor_canvas metadata when canvas dimensions are available. Tests cover explicit dimensions, replayed dimensions, and documents without layers.

Merge Risk: ⚪ Minimal · up to 6d44b

This change reports the rendered document canvas so the layer editor can size and save composites correctly. The backend update is localized, and no actionable merge-blocking risk remains beyond the separately tracked frontend follow-up.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: emitting the document canvas from ImageCompositor for the layer editor.
Description check ✅ Passed The description explains the canvas-sizing defect, the compositor change, replay behavior, and the required frontend follow-up.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants