justinpark opened a new pull request, #24539: URL: https://github.com/apache/superset/pull/24539
### SUMMARY Following up [SIP-93](https://github.com/apache/superset/issues/21385), this commit implements the first step of non-blocking persistence mode for the current working sqllab editor activities. As described in [SIP-93](https://github.com/apache/superset/issues/21385), the existing PERSISTENCE logic causes a user interaction delay due to the network (or server side) lagging. For example, user had to wait the server response in order to update the tab name or query limit count. (see the before screenshot) Therefore, this commit aims to improve current tab activities by replacing the following blocking logics with a non-blocking way by cumulating the changes and syncing them with the latest updates asynchronously: ``` - querySuccess - queryFailed - toggleLeftBar - queryEditorSetDb - queryEditorSetSchema - queryEditorSetAutorun - queryEditorSetTitle - queryEditorSetSql - queryEditorSetQueryLimit - queryEditorSetTemplateParams ``` #### Mechanism for syncing unsaved changes  There can be unsaved changes since it is syncing in a non-blocking way and asynchronously. To address this issue, unsaved changes will be stored in local storage (using localStorage in persistence mode) until they are successfully saved on the server. This hybrid approach ensures that user data is not lost and that any unsaved changes are retrieved, even in the event of an unexpected interruption. #### Resolve conflicts When a user opens multiple windows, they may be overwritten by the inactive editor tab state. To prevent this unexpected overwrite, the latest update time will be compared with the local cache state, and the out-of-updated state will be discarded. This ensures that users can work on multiple windows without losing their progress or having their work overwritten. #### Following up Creating new tabs and removing tabs are still blocking way in this commit but will be migrated into the non-blocking way in future PRs. Additionally, the existing migrateQueryEditorFromLocalStorage logic will be consolidated or replaced by the AutoSync with mutation APIs in the upcoming PRs. These changes will further improve the user experience by making the entire process non-blocking and asynchronous. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF After: https://github.com/apache/superset/assets/1392866/3d5b2817-add5-41c8-9071-890e82e81615 Before: https://github.com/apache/superset/assets/1392866/7efa5a29-b7e0-4698-bb39-f4295693588d ### TESTING INSTRUCTIONS Set SQLLAB_BACKEND_PERSISTENCE true and play with the SQL Lab editor and keep hard refresh to verify the persisted states. ### ADDITIONAL INFORMATION - [x] Has associated issue: [SIP-93](https://github.com/apache/superset/issues/21385) - [x] Required feature flags: `SQLLAB_BACKEND_PERSISTENCE` - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [x] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
