An Android automation step taps Submit, waits for a confirmation, and times out. Repeating the tap seems like a reasonable recovery. It can also create a duplicate if the first request succeeded and only the confirmation was delayed or missed.
Treat a timeout after a consequential action as an unknown outcome. Observe the result before deciding whether another action is appropriate. Retry an observation more freely than an operation that creates a record, sends a message, or spends something.
Disclosure: This article is published by the LaiCai Screen Mirroring team with AI assistance. The example below is a design exercise for a test application. It is not a claim that a desktop automation tool can guarantee exactly-once behavior for an arbitrary third-party app.
Separate the action from evidence of completion
A UI click proves that input was issued. It does not prove that the application accepted the operation, that a remote service completed it, or that the result became visible. Those stages can fail independently.
Define the result you need before choosing a retry strategy. For a sample note-creation task, the result might be one saved note with a unique test label. A spinner disappearing is weaker evidence: it says something changed, but does not by itself identify the intended record.
Android's Espresso idling-resource documentation addresses synchronization with asynchronous work in app testing. A desktop UI workflow may not have access to the same internal signals. That makes the choice of observable completion evidence especially important.
Write three states in the design: confirmed success, confirmed failure before the action took effect, and unknown outcome. Do not force the unknown state into failure just because a timer expired. That distinction determines whether the next step should inspect, retry, or stop for review.
Retry the check before repeating the submission
After a timeout, capture fresh evidence from the current state. The screen may have changed since the earlier observation. A confirmation could be visible, the created item could be in a list, or the app could still be processing.
For the sample note task, check whether the unique test label exists in the destination list. If exactly one matching note is present, record success without tapping Submit again. If the app clearly rejected the operation before saving, recovery may be possible. If the result cannot be determined, stop the write path.
A useful conceptual sequence is:
- Prepare a uniquely identifiable test item.
- Submit once.
- Observe for the expected saved result within a bounded period.
- If the observation times out, inspect the destination state again.
- Retry the write only when the application's behavior and evidence justify it.
This is a workflow pattern, not an executable recipe for every app. The unique label is an aid to observation, not a substitute for a real idempotency key in a service you control. If the underlying app can create duplicates, the UI automation cannot make that risk disappear by naming the item carefully.
Put limits around observation loops
An observation loop should have a deadline and a deliberate response when that deadline is reached. Otherwise, the workflow can wait indefinitely, consume resources, or repeatedly inspect a state that will never change.
LaiCai's current node schema includes an Until Flow node with a target status, timeout, interval, and maximum-attempt setting. The schema was checked through the running application's read-only MCP interface for this article. The LaiCai Flow guide provides the product-level introduction.
Use the loop around a check that reports whether the intended result is present. Do not place the entire submit-and-check sequence inside a retry loop without considering whether the submit can run again. Repeating the child flow repeats the actions inside it; a descriptive name does not make those actions safe.
Choose limits from the behavior you have actually observed in your test environment. A fixed number copied from an example is not evidence that your app always completes within that time. On expiry, preserve the current state and report an unresolved outcome instead of silently restarting the whole task.
Test the ambiguous cases deliberately
A workflow that succeeds on a fast connection has not yet demonstrated safe recovery. Test the boundary where the action could have succeeded but confirmation is unavailable. Use disposable data and an environment where the test will not send real messages or create real purchases.
Useful test cases include a slow result screen, a lost desktop connection after submission, an unexpected dialog, and a result that exists but is outside the current view. For each case, write the expected next step before running the test.
The most revealing assertion is often that the second submission did not occur. Record how you verified this in the test application. If you control the backend, inspect the relevant test records or request identifiers. If you only observe the UI, state that limitation and avoid an exactly-once claim.
Also test recovery after a human review. A paused workflow should not resume at a stale button press after someone has already completed or canceled the operation. Refresh the state and choose the appropriate continuation explicitly. The original timeout is no longer the only relevant event.
Choose a tool around the result you can verify
An Android automation tool with AI model support can help build and inspect a workflow, but tool selection does not remove the application's transaction semantics. Ask how the workflow observes completion, limits retries, and exposes unknown outcomes.
AI-generated steps deserve the same review. A fluent explanation such as “retry until successful” can hide repeated writes. Inspect the actual loop body, the success condition, and the failure path. A plan that cannot explain what happens after an uncertain submission is incomplete.
Keep a test record containing the attempted operation, its identifier, the last observed state, the observation deadline, and whether another write occurred. That record is more useful for recovery than a generic “node failed” message alone.
Reliable recovery begins by admitting uncertainty. When the first operation may already have succeeded, the next action should establish what happened. That discipline protects both the data and the credibility of the automation's success report.
Top comments (0)