Skip to content

fix(storage): defer binding updates until ensemble.storage.clear() finishes#2227

Closed
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-identification-9410
Closed

fix(storage): defer binding updates until ensemble.storage.clear() finishes#2227
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-identification-9410

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 20, 2026

Description

Fixes a race in EnsembleStorage.clear(): clearPublicStorage() is asynchronous, but storage binding listeners re-evaluate expressions by reading GetStorage after each event. Notifying listeners while keys were still present could refresh the UI from stale persisted values, so the screen could look uncleared until some unrelated rebuild.

Related Issue

None filed; found during review of recent ensemble.storage.clear() work (#2213).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

  • Dispatch ModelChangeEvent / dispatchStorageChanges only after StorageManager.clearPublicStorage() completes, using unawaited(... .then(...)) so the Invokable API stays synchronous for the script interpreter while ordering is correct for bindings.

How to Test

  1. From modules/ensemble, run flutter test (and optionally add a widget test that sets listenTitleBarHeightStorage, binds a header to ensemble.storage.*, calls clear(), and asserts the binding sees null after the async clear).
  2. Manually: enable storage-driven title bar height, clear public storage from an action, confirm bound UI updates to cleared state without requiring a second interaction.

Screenshots / Videos

N/A

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors

Note for reviewers: The Cursor Cloud image used for this automation did not have the Flutter SDK on PATH, so flutter analyze / flutter test were not executed here. Please run them locally per AGENTS.md.

Open in Web View Automation 

cursoragent and others added 2 commits May 20, 2026 11:03
EnsembleStorage.clear() fired ModelChangeEvent for each key while
clearPublicStorage() was still running asynchronously. Bindings
re-evaluate by reading GetStorage, so UI could refresh from stale values.
Defer dispatches until clearPublicStorage completes.

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.

2 participants