Skip to main content

panel_auto_layout β€” one-shot canvas auto-arrange

Status: implemented (this PR) Β· Implementation branch: spec/panel-auto-layout Β· Pairs with: comfyui-mcp-panel PR #75 (docs/design/auto-layout-engine.md β€” the engine + graph_auto_layout bridge command)
Prior art: filliptm/ComfyUI_FL-MCP modify_layout. The engine, algorithm, and improvements over FL-MCP (groups, reroutes, barycenter, overlap resolution) are specified in the paired panel RFC; this doc covers only the orchestrator tool surface.

Motivation

Agents can make targeted layout adjustments with panel_edit_node; auto-layout avoids dozens of individual round-trips. The panel gains a graph_auto_layout bridge command (see paired RFC); this tool exposes it to the agent.

Tool API

Added to buildPanelToolDefs() in src/orchestrator/panel-tools.ts β€” both transports (Claude in-process SDK server + Codex HTTP MCP) pick it up automatically:
The bridge command additionally accepts align/anchor; those stay panel-side defaults for now (not exposed to the agent until needed β€” the frame contract already carries them for a later tool rev or panel UI use). Result/error shapes are defined by the paired RFC ({applied, columns, moved[], groups[], skipped[]}; agent-readable error strings). The result JSON is passed through as text like every other panel_* tool.

Gating

Ships ungated, exactly like the other mutating panel tools today (panel_edit_node, panel_add_node, …). Safety gates were closed as won’t-do (issue #168; spec PR #172 closed, design archived under ROADMAP Theme G).

Implementation plan

  1. src/orchestrator/panel-tools.ts β€” the def above (15 s timeout: layout is O(n) but big graphs + redraw need headroom).
  2. docs/panel.mdx β€” add the tool row (the only doc enumerating panel_* tools).
  3. No ui-bridge.ts changes β€” the bridge is command-agnostic (ctx.call forwards any {cmd, ...} frame with rid correlation).

Test plan

No runtime logic beyond the def: extend the existing panel-tools def-shape coverage (or snapshot buildPanelToolDefs().map(d => d.name)). Behavior is covered by the paired repo’s unit + Playwright suites.

Rollout / compat

Panel PR ships first. New orchestrator + old panel: the tool errors with Unknown command "graph_auto_layout" β€” agent-readable; the description must not promise availability. Changelog note in both repos.