Skip to content

d2sequence: account for self and sibling message height in note placement - #2940

Open
AdamMagued wants to merge 1 commit into
d2lang:masterfrom
AdamMagued:fix-issue-2939
Open

AdamMagued wants to merge 1 commit into
d2lang:masterfrom
AdamMagued:fix-issue-2939

Conversation

@AdamMagued

Copy link
Copy Markdown

Fixes #2939

Problem

When notes are positioned in sequence diagrams, vertical offsets only accounted for self-messages where source matched destination directly (msg.Src == msg.Dst). Messages between descendant spans or sibling spans sharing the same actor root are routed as multi-point self-loops, which occupy extra vertical space. Because note placement overlooked these messages, notes following sibling messages were positioned prematurely along the Y axis. Consequently, subsequent groups containing or starting with such notes computed overlapping bounding boxes.

Solution

  1. Introduce isSelfOrSibling helper to consistently classify self-messages, descendant messages, and sibling messages sharing the same actor root.
  2. Use isSelfOrSibling in placeNotes to add the full vertical space occupied by loop routes when calculating vertical offsets.
  3. Replace duplicate inline message classification logic in routeMessages with isSelfOrSibling.
  4. Add automated unit test coverage in layout_test.go verifying that groups starting with notes after sibling messages do not overlap.

…ment

When positioning notes in sequence diagrams, vertical offsets only accounted
for self-messages where source matched destination directly. Messages between
spans of the same actor or descendant/sibling relations also consume extra
vertical space for loop routing. Because note placement ignored that space,
notes appearing after sibling messages were placed too high, causing
subsequent groups to overlap preceding groups.

Extract an isSelfOrSibling helper shared by routeMessages and placeNotes,
and account for the full height of self and sibling messages during note
positioning. Add tests covering group overlap prevention with notes.

This branch has not been deployed

No deployments
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.

[sequence_diagram] Possible overlap when a group starts with a note

1 participant