Skip to content

fix(wifi, action): correct callback routing and async apiMap restore#2286

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-remediation-aa33
Draft

fix(wifi, action): correct callback routing and async apiMap restore#2286
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-remediation-aa33

Conversation

@cursor

@cursor cursor Bot commented Jun 16, 2026

Copy link
Copy Markdown

Description

Fixes two critical correctness bugs found in recent commits: WiFi provisioning incorrectly firing error handlers on success, and reusable actions restoring scoped APIs before async body work completes.


Bug 1: WiFi onError fires after successful connect

Trigger: A connectToWifi action succeeds (result == true) but only defines onError (no onSuccess) — a common IoT provisioning pattern.

Impact: The app navigates to failure screens or shows error UI despite a successful WiFi join, causing provisioning retries, confused device state, and significant user-facing breakage.

Root cause: _handleWifiResult invoked onError whenever it was defined, without checking whether result == true after the success branch was skipped.

Fix: Return early on result == true when onSuccess is absent; only run onError for false/null results.


Bug 2: executeAction apiMap restored before async body completes

Trigger: A reusable action with a scoped API: block runs an async body (e.g. invokeAPI, nested executeAction, navigation).

Impact: Scoped API definitions are removed before the body finishes — causing Unable to find api definition crashes or routing requests to wrong/restored page-level endpoints.

Root cause: PR #2275 added snapshot/restore in a finally block but returned executeActionWithScope without await. In Dart, finally runs when the Future is returned, not when it completes.

Fix: return await ScreenController().executeActionWithScope(...).


Validation

  • Added modules/ensemble/test/wifi_action_test.dart for ConnectToWifiAction YAML parsing.
  • Extended modules/ensemble/test/action_scope_api_restore_test.dart with async finally timing tests documenting the await requirement.
  • Run from modules/ensemble:
    • flutter test test/wifi_action_test.dart
    • flutter test test/action_scope_api_restore_test.dart

Duplicate check

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
Open in Web View Automation 

cursoragent and others added 2 commits June 16, 2026 11:09
When connectToWifi succeeded but onSuccess was omitted, _handleWifiResult
still invoked onError because the error branch had no guard on result.
IoT provisioning flows that only define onError would navigate to failure
screens despite a successful WiFi join.

Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
The finally block in ExecuteActionAction ran as soon as the inner Future
was returned, not when async work finished. Scoped APIs were removed
before invokeAPI and other async body actions could run, causing crashes
or wrong endpoints for reusable actions with async bodies.

Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
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.

1 participant