Feat/maestro repeat while

Merged
AH
2mo ago
+842-109

Summary

Maestro flows that used repeat.while were rejected with "repeat.while is not supported; use repeat.times". This adds support that follows the Maestro repeat reference:

- repeat:
    while:
      notVisible: "ValueX"
    commands:
      - tapOn: Button
- evalScript: ${output.counter = 0}
- repeat:
    times: 4            # optional upper bound
    while:
      true: ${output.counter < 3}
    commands:
      - evalScript: ${output.counter++}
  • Parser: repeat now needs times, while, or both. while accepts platform, visible, notVisible, and true.
  • Execution: the condition is checked before each iteration. The loop stops when the condition is false or when times is reached, whichever comes first.
    • Visibility checks use the same lookup timeout as runFlow.when.
    • true expressions run JavaScript through the same evaluator as evalScript. Results count as false using the same rule as assertTrue. So "false", "0", "", "null", and "undefined" from string output values are false.
    • Changes the expression makes to output.* carry into later steps.
  • Security: while.true is refused for flows received over the remote daemon connection, the same as evalScript.
  • Conformance and docs: added an authored repeat-while flow and regenerated the layer-1 fixtures. Updated the support matrix and replay-e2e.md.

19 files changed. No scope expansion.

Test plan

  • Ran pnpm check:affected --run on e4dc41a24 and it passed.
    • The first run had two unrelated timeouts (interaction-response-shape, apple-platform-output-guard). Both passed when run alone and on the rerun.
  • New unit tests cover:
    • parsing, including the errors for a missing or empty while
    • a JavaScript loop
    • a visibility loop
    • stopping at the times bound
    • refusal for untrusted remote flows
    • true/false handling of script results
  • pnpm maestro:conformance passes.
  • Not tested on a device yet. To check manually, run the YAML above with agent-device replay on an iOS simulator or Android emulator.