arrange_workspace
Automatically layout a ComfyUI workflow left to right in data-flow order, keeping groups intact and arranging only selected nodes if needed. Fixes cluttered canvases by computing or applying tidy positions.
Instructions
Lay the workflow out left to right, in the order the data flows through it.
Each node goes as far right as its consumers allow, so a loader sits beside the sampler that reads it rather than in a column of loaders at the far edge, and the nodes in a column are ordered and placed to face what they are wired to. The result keeps the top-left corner it already had, so it lands where the author left it rather than at the origin.
Groups are laid out as groups. A group is a rectangle with no membership - what is in it is whatever falls inside - so arranging a grouped canvas flat scatters each group across the columns and its box stretches to follow, which on a real workflow turned eight tidy groups into overlapping sheets covering everything. So the layout runs inside each group first and then over the blocks they form, and ungrouped nodes travel together as one more block.
It still moves every node it is given, which is the blunt instrument. only
is the narrow one: it arranges just those nodes and leaves the rest of the
canvas alone - and since the caller has already said which nodes they mean,
groups are not consulted in that case.
Args: only: node ids to arrange, leaving every other node where it is. Links to nodes outside the list are ignored, since they cannot place anything. spacing_x: gap between columns, past the widest node in the left one. spacing_y: gap between nodes stacked in one column. origin: [x, y] for the top-left of the result. Defaults to the top-left of what is being arranged, so nothing wanders off. apply: write the positions. False computes and reports them without touching the canvas - the same dict can then be passed to set_workspace_layout. scope: "root" for the top level, "active" for the subgraph on screen. Not "all": a subgraph is a canvas of its own with its own coordinates, so there is no one layout that covers several. Use navigate_workspace to go in and arrange with "active". client_id: which tab to arrange; defaults to the most recently focused one.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| only | No | ||
| apply | No | ||
| scope | No | root | |
| origin | No | ||
| client_id | No | ||
| spacing_x | No | ||
| spacing_y | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||