fix(storage): defer binding updates until ensemble.storage.clear() finishes#2227
Closed
cursor[bot] wants to merge 2 commits into
Closed
fix(storage): defer binding updates until ensemble.storage.clear() finishes#2227cursor[bot] wants to merge 2 commits into
cursor[bot] wants to merge 2 commits into
Conversation
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>
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.
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
What Has Changed
ModelChangeEvent/dispatchStorageChangesonly afterStorageManager.clearPublicStorage()completes, usingunawaited(... .then(...))so the Invokable API stays synchronous for the script interpreter while ordering is correct for bindings.How to Test
modules/ensemble, runflutter test(and optionally add a widget test that setslistenTitleBarHeightStorage, binds a header toensemble.storage.*, callsclear(), and asserts the binding sees null after the async clear).Screenshots / Videos
N/A
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests passNote for reviewers: The Cursor Cloud image used for this automation did not have the Flutter SDK on
PATH, soflutter analyze/flutter testwere not executed here. Please run them locally perAGENTS.md.