Skip to content

Microflow auto-layout: long flows never wrap, guards waste the main line, 4+ case splits draw crossing lines #1154

Description

@tgolembiewski

mxcli version: v0.23.0 (Mendix 11.12.1, MPR v2, macOS)

Context

An agent builds a whole app from MDL and writes no @position — so every microflow is laid out by the builder's own auto-layout. On a generated B2B ordering app of 41 microflows, mx check is clean and nothing overlaps, but the more complex flows are hard to read on the Studio Pro canvas. Five separate things, each measured on that app:

1. The main line never wraps

Every top-level statement advances posX, nothing ever moves down. The widest flow came out 6930 × 160 px (43:1) — four screens of sideways scrolling for something 160 px tall.

2. A guard makes the main line wait for its own branch

if X then …; return; end if draws its branch in the lane below and ends it there, yet the next element on the main line is placed past the branch's far end: 370 px from the split, against 40 px between any two activities. Similarly a merge stands 120 px after its branch (a half pitch is added to a width that is already edge-to-edge), and a branch ending in return is measured without the end event it draws.

3. Enumeration splits with 4+ cases draw crossing lines

The anchor pair on each case flow stores the CASE order (splitCaseOrderAnchors, from 0e69243). From the fourth case on, that means sides no drawing would choose: case 4 leaves the split's left corner, cases 5–8 arrive on top of their activity, 9+ on its far side. A 7-case split is a tangle of lines crossing each other and the activities between them.

4. A note on a loop lands inside the loop

A note is placed 100 px above its element's centre. On a loop box several hundred px tall that is inside the box, on top of the body. The note's connector is also written top-to-top, so the line is attached to the top of the note rather than its bottom.

5. Loop boxes get no gap

An activity before or after a loop box touches it, because the cursor treats the box as an activity-width element.

Proposed fix

I have a branch that addresses all five, geometry and anchors only — no execution semantics, no MDL syntax change, @position-ed statements are never moved, and describe → exec still reports Unchanged microflow:

  • wrap the main line onto rows past a width limit (rows placed under the real extent of the row above; the joining line runs bottom → top through the band between rows);
  • let the main line resume right after a guard and track how far the lane below is taken, so only an element that reaches into that lane waits for it; tighten the merge gap; measure a returning branch with its end event;
  • for 4+ cases, group case lines by side — upper third from the split's top corner, middle from the right, lower from the bottom, all arriving on the left — and have describe read the case order from side + canvas position (models written with the pair table are still read through it; ≤ 3 cases are unchanged);
  • place notes above the element's top edge, connector bottom → top;
  • give loop boxes the same 40 px gap as activities.

Same app after the change: widest flow 3220 px on one row, the 7-case flow has no crossing lines, 0 overlaps, mx check 0 errors. Unit tests for each item (each verified to fail with its fix reverted), make test, make lint-go, make check-mdl and the integration suite pass locally.

Related: #724 (opt-in beautify pass for one flow family — this is the default layout instead), #884, #990.

Happy to open the PR if this direction is OK — or to split it if you would rather take the items separately.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions