Skip to content

fix: emit loop captions during microflow describe#444

Merged
ako merged 2 commits intomendixlabs:mainfrom
hjotha:submit/describer-loop-caption-annotations
Apr 30, 2026
Merged

fix: emit loop captions during microflow describe#444
ako merged 2 commits intomendixlabs:mainfrom
hjotha:submit/describer-loop-caption-annotations

Conversation

@hjotha
Copy link
Copy Markdown
Contributor

@hjotha hjotha commented Apr 30, 2026

Closes #443.

Summary

  • Emit @caption for microflows.LoopedActivity during microflow describe.
  • Use the same mdlQuote path as other activity captions.
  • Add a focused regression test covering apostrophe and newline escaping in loop captions.

Validation

  • make build
  • go test ./mdl/executor -run 'TestEmitObjectAnnotations_LoopCaption|TestLoopCaptionPreserved|TestWhileLoopCaptionPreserved' -v
  • make test
  • make lint-go

Symptom: describe emitted @caption for action activities and split activities, but captions stored on LoopedActivity objects were omitted.

Root cause: emitObjectAnnotations did not handle LoopedActivity.Caption even though the builder already preserves captions for loop and while statements.

Fix: emit a quoted @caption annotation for LoopedActivity before attached @annotation lines, matching the existing ExclusiveSplit and InheritanceSplit handling.

Tests: added a focused emitObjectAnnotations regression covering loop captions with apostrophe and newline escaping; ran make build, targeted executor tests, make test, and make lint-go.
@ako ako added this to the v0.8.0 milestone Apr 30, 2026
Copy link
Copy Markdown
Collaborator

@ako ako left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #444 Review — fix: emit loop captions during microflow describe

Clean, focused fix. Three lines of production code that mirror the adjacent ExclusiveSplit and InheritanceSplit handlers exactly. The write side (applyAnnotations in cmd_microflows_builder_annotations.go) already set Caption on LoopedActivity — this completes the roundtrip by emitting it on the describe side.

The unit test is good: covers apostrophe doubling and newline escaping through mdlQuote, which are the two failure modes that matter.

Minor

No doctype-level example for @caption on a loop

02-microflow-examples.mdl has @caption examples on activities and splits but nothing on a loop or while-loop statement. TestMxCheck_DoctypeScripts would never have caught this regression. Worth adding one microflow in that file with a loop that carries @caption, e.g.:

@caption 'Process each item'
loop $Item in $Items
  log info $Item/Name;
end loop;

This doubles as living documentation that @caption is valid on loop statements.


Otherwise looks good to merge.

@ako
Copy link
Copy Markdown
Collaborator

ako commented Apr 30, 2026

PR #444 Review — fix: emit loop captions during microflow describe

Clean, focused fix. Three lines of production code that mirror the adjacent ExclusiveSplit and InheritanceSplit handlers exactly. The write side (applyAnnotations in cmd_microflows_builder_annotations.go) already set Caption on LoopedActivity — this completes the roundtrip by emitting it on the describe side.

The unit test is good: covers apostrophe doubling and newline escaping through mdlQuote, which are the two failure modes that matter.

Minor

No doctype-level example for @caption on a loop

02-microflow-examples.mdl has @caption examples on activities and splits but nothing on a loop or while-loop statement. TestMxCheck_DoctypeScripts would never have caught this regression. Worth adding one microflow in that file with a loop that carries @caption, e.g.:

@caption 'Process each item'
loop $Item in $Items
  log info $Item/Name;
end loop;

This doubles as living documentation that @caption is valid on loop statements.


Otherwise looks good to merge.

@ako ako merged commit 3bdf2d6 into mendixlabs:main Apr 30, 2026
1 of 2 checks passed
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.

describe drops captions on loop and while activities

3 participants