Skip to content

feat: improve flow layout algorithm and add move_flow_components command#160

Draft
Ruari-Phipps wants to merge 15 commits into
mainfrom
ruari/fix/improve_flow_organisations
Draft

feat: improve flow layout algorithm and add move_flow_components command#160
Ruari-Phipps wants to merge 15 commits into
mainfrom
ruari/fix/improve_flow_organisations

Conversation

@Ruari-Phipps
Copy link
Copy Markdown
Collaborator

@Ruari-Phipps Ruari-Phipps commented May 26, 2026

Summary

Replaces the flow layout algorithm with a hierarchical Sugiyama-style layout using networkx, aligns layout constants with the actual Jupiter frontend rendering dimensions, and adds support for pushing position updates via the move_flow_components platform command.

Motivation

  • Flow positions computed by ADK didn't match what the frontend rendered — constants (node widths, heights, spacing, text reflow) were misaligned with actual CSS
  • Position updates on existing steps were silently dropped because update protos don't include position fields
  • No way to re-layout existing flows from scratch

Changes

  • Replace BFS grid layout with hierarchical layout using networkx (BFS layers + barycenter ordering)
  • Align layout constants with rendered dimensions (node widths, heights, line-height, chars-per-line, entity chip sizing, etc.)
  • Condition labels now positioned above the child node using child's x-coordinate
  • Add build_move_commands and clean_flow_positions to flow_layout_utils.py for building MoveFlowComponents protos
  • Add queue_command to sync_client and interface for queuing arbitrary command protos
  • Add --clean-flows flag to poly push — re-layouts changed flows and pushes positions via move_flow_components
  • New flows automatically get full layout on push; --clean-flows only processes flows with changes in the changeset
  • Function step conditions and extracted entity sizing now properly accounted for in height estimation

Test strategy

  • Added/updated unit tests
  • Manual CLI testing (poly <command>)
  • Tested against a live Agent Studio project
  • N/A (docs, config, or trivial change)

Checklist

  • ruff check . and ruff format --check . pass
  • pytest passes
  • No breaking changes to the poly CLI interface (or migration path documented)
  • Commit messages follow conventional commits

Ruari-Phipps and others added 9 commits May 22, 2026 17:15
…layout

Replaces the old recursive grid layout with a proper hierarchical layout
algorithm (BFS layers, barycenter ordering) that produces clean top-to-bottom
flow visualizations matching GLOT's dagre approach.

Key changes:
- New flow_layout_utils.py with Sugiyama-style layout algorithm
- Resolves edges from conditions, goto_step() calls, and {{ft:func}} prompts
- Estimates card height from prompt length for vertical spacing
- Centers function steps within step columns
- New flows get full clean layout; existing flows place new steps relative to parents
- Includes HTML visualizer script (scripts/visualize_flow.py)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report

Base (main) PR Change
70.1% 70.9% +0.8% ✅

Changed file coverage

File Coverage Change
poly/handlers/sync_client.py 25.2% -0.4% ⚠️
poly/handlers/interface.py 39.8% -0.6% ⚠️
poly/cli.py 52.2% +0.0% ✅
poly/project.py 67.9% +0.4% ✅
poly/resources/function.py 81.6% +0.4% ✅
poly/resources/flows.py 83.5% -2.5% ⚠️
poly/resources/resource_utils.py 93.2% +8.9% ✅

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.

1 participant