Repository navigation
fix(executor): a runFlow's or a retry's file runs its own onFlowStart and onFlowComplete, as in Maestro - #277
Merged
omnarayan merged 1 commit intoNov 18, 2026
Conversation
… and onFlowComplete, as in Maestro A file reached by runFlow or retry applied only its env:; its header's onFlowStart and onFlowComplete never ran. Maestro runs them around the file's commands (Orchestra.kt runSubFlow, for runFlowCommand and retryCommand alike; the command's config is the file's header): the steps after onFlowStart, onFlowComplete in a finally. executeSubFlow now runs onFlowStart, then the steps unless it failed, then onFlowComplete, also after a failed step; the sub-flow fails when a hook fails, with the first failure, as a flow's own hooks report it. A retry runs them on each attempt. Once the run is cancelled or a runFlow's timeout: has passed, nothing more runs, onFlowComplete included (Maestro skips it on a cancel too). Unlike Maestro, the steps run when onFlowStart changed nothing on screen: runSubFlow takes executeSubflowCommands' "screen changed" result as onFlowStart's success, so a hook of only assertions skips the file's steps there. The pre-session scan for launchApp reads a sub-file's onFlowStart before its steps and its onFlowComplete after them, so a launchApp with permissions in a sub-file's hook arms the driver as one in its steps does.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
10 of 14 tasks
omnarayan
added a commit
that referenced
this pull request
Nov 18, 2026
A retry's final error is its last attempt's, and a failing onFlowStart or onFlowComplete put its name only in the attempt's message, so the result read "Retry failed after 3 attempts (cause: element not found)". Refs #277
omnarayan
added a commit
that referenced
this pull request
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A file reached by
runFloworretryapplies only itsenv:: its header'sonFlowStartandonFlowCompletenever run. Maestro runs them around the file's commands:runFlowCommandandretryCommandboth go throughrunSubFlow, whose config is the file's header, withonFlowStartbefore the commands andonFlowCompletein afinally. A sub-flow that sets something up and tears it down (a mocked server, a setting, airplane mode) in its own hooks left it in place here.Type of Change
Changes Made
executeSubFlow: the file'sonFlowStart, then its steps unlessonFlowStartfailed, then itsonFlowComplete, also after a failed step. The sub-flow fails when a hook fails ("onFlowStart failed: …" / "onFlowComplete failed: …"), with the first failure, as a flow's own hooks report it. Aretryruns them on each attempt.runFlow'stimeout:has passed, nothing more runs,onFlowCompleteincluded (Maestro skips it on a cancel too).executeSubflowCommands' result asonFlowStart's success, and that result says whether a command changed the screen (.any { it }), so a file whoseonFlowStartis only assertions,extendedWaitUntil,defineVariablesor an optional step that failed has its steps silently skipped there. Here they run.launchApp(iOS real device: WDA defaultAlertAction not armed from launchApp permissions in onFlowStart / runFlow subflows (silent; diverges from simulator) #108) reads a sub-file'sonFlowStartbefore its steps and itsonFlowCompleteafter them, so alaunchAppwithpermissionsin a sub-file's hook arms the driver as one in its steps does.--pause-on-failure, a failure inside arunFlow's file pauses at the top-level step, so the file'sonFlowCompletehas run by then: the device is no longer quite as the failure left it.runFloworretryof a file with hooks now runs those hooks.Related Issues
None open; found comparing runs with Maestro 2.12.1.
Testing
go test -race ./...,pkg/driver/browser/cdpleft out: it launches Chrome)TestRunFlowFileRunsItsOwnHooks(pkg/executor/subflow_hooks_test.go): arunFlowrun twice, aretry, aretrythat runs the hooks again after a failed attempt,onFlowCompleteafter a failing step, a failingonFlowStartskipping the steps, a failingonFlowCompletefailing therunFlow, an optional hook step that fails, awhen:false (no hook runs) and inlinecommands:(no hooks).TestCollectStepsForPrepare_SubFlowFileHooks: a sub-file's hooklaunchApps are scanned,onFlowStart's first. Onmainall but thewhen:and inline cases fail.On an Android emulator (API 36), with Maestro 2.12.1 for reference: a file with its own
onFlowStartandonFlowComplete(evalScripts counting inoutput) run twice byrunFlow, then a check of the counts, passes on Maestro and with this change.Checklist
Additional Notes
Proposed CHANGELOG entry: