Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mdl/executor/cmd_microflows_show_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ func emitAnchorAnnotationWithActivityMap(
id := obj.GetID()

if _, isSplit := obj.(*microflows.ExclusiveSplit); isSplit {
emitSplitAnchorAnnotation(id, flowsByOrigin, flowsByDest, lines, indentStr)
emitSplitAnchorAnnotation(id, flowsByOrigin, flowsByDest, lines, indentStr, false)
return
}
if _, isSplit := obj.(*microflows.InheritanceSplit); isSplit {
emitSplitAnchorAnnotation(id, flowsByOrigin, flowsByDest, lines, indentStr)
emitSplitAnchorAnnotation(id, flowsByOrigin, flowsByDest, lines, indentStr, true)
return
}
if loop, isLoop := obj.(*microflows.LoopedActivity); isLoop {
Expand Down Expand Up @@ -203,6 +203,7 @@ func emitSplitAnchorAnnotation(
flowsByDest map[model.ID][]*microflows.SequenceFlow,
lines *[]string,
indentStr string,
preserveDefaultIncoming bool,
) {
// Incoming flow anchor (where the previous activity's flow lands on the split).
var inTo string
Expand All @@ -227,12 +228,12 @@ func emitSplitAnchorAnnotation(
}

var parts []string
splitDefaultIn := anchorSideKeyword(AnchorLeft)
trueDefaultFroms := []string{anchorSideKeyword(AnchorRight), anchorSideKeyword(AnchorBottom)}
trueDefaultTos := []string{anchorSideKeyword(AnchorLeft)}
falseDefaultFroms := []string{anchorSideKeyword(AnchorBottom), anchorSideKeyword(AnchorRight)}
falseDefaultTos := []string{anchorSideKeyword(AnchorTop), anchorSideKeyword(AnchorLeft)}
if inTo != "" && inTo != splitDefaultIn {
splitDefaultIn := anchorSideKeyword(AnchorLeft)
if inTo != "" && (preserveDefaultIncoming || inTo != splitDefaultIn) {
parts = append(parts, "to: "+inTo)
}
if p := branchAnchorFragmentWithDefaultSides("true", trueFrom, trueTo, trueDefaultFroms, trueDefaultTos); p != "" {
Expand Down
30 changes: 28 additions & 2 deletions mdl/executor/cmd_microflows_split_incoming_anchor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
// on the flow entering the split, but the describer never read it back.
//
// The fix moves split anchors into a dedicated emitSplitAnchorAnnotation path
// that emits `@anchor(to: X, true: (...), false: (...))` whenever any of the
// three has a non-default value.
// that emits `@anchor(to: X, true: (...), false: (...))` whenever any split
// has a non-default value. For inheritance splits the incoming side is also
// preserved when it is `left`: omitting it can make the builder relayout
// negative-X split-type branches and change branch scoping.
package executor

import (
Expand Down Expand Up @@ -49,6 +51,30 @@ func TestEmitSplitAnchor_EmitsIncomingToSide(t *testing.T) {
}
}

func TestEmitSplitAnchor_PreservesIncomingLeftSide(t *testing.T) {
splitID := model.ID("split-left-incoming")
split := &microflows.InheritanceSplit{}
split.ID = splitID

incoming := &microflows.SequenceFlow{
DestinationID: splitID,
DestinationConnectionIndex: AnchorLeft,
}
flowsByDest := map[model.ID][]*microflows.SequenceFlow{
splitID: {incoming},
}

var lines []string
emitAnchorAnnotation(split, nil, flowsByDest, &lines, "")

if len(lines) != 1 {
t.Fatalf("expected incoming anchor line, got %d: %v", len(lines), lines)
}
if lines[0] != "@anchor(to: left)" {
t.Fatalf("anchor line = %q, want @anchor(to: left)", lines[0])
}
}

func TestEmitSplitAnchor_EmitsBranchAnchors(t *testing.T) {
splitID := model.ID("split-2")
split := &microflows.ExclusiveSplit{}
Expand Down
Loading