[Fixes #461, #462, #463] Make loading auto-saved model changes opt-in - #464
Conversation
LaCuneta
left a comment
There was a problem hiding this comment.
Thank you for your work on this! I really like that I can keep using my existing model edits without much friction. I also appreciate the bug fixes.
Three issues I found:
- If you open a model with cached changes, then select to load those changes, things work as expected. But if I then upload a model that also has cached changes, I do not get prompted to apply them. If I refresh the page and re-upload, it does work, so it seems like the page state is getting set by the first model loaded from cache.
- This is a silly edge case, but if you open a model with cached changes then use your fleetest fingers to make an edit while the Load Changes toast is up, when you hit Load Changes it'll load the change you just made, not the one that was in the cache when the toast was shown. I think my preference is to just hide the toast early if someone dives into editing right away.
- Previously we displayed the source of the model (switch code from
createWorkInProgressAlert()when talking about it in the toast, now all models are "dismiss to keep the model as linked". I think being more specific is helpful, but I don't consider it a blocker to merge.
|
Hi @LaCuneta, thank you for taking the time to review this PR. I am glad it is going smooth. The devel direction right now is to get rid of the toast in favor of highlighting the I'll look into the remaining concerns and address them shortly. |
Toast no longer exists.
Toast no longer exists.
Toast no longer exists but I added it as a hover title on the "Load Changes" button. |
LaCuneta
left a comment
There was a problem hiding this comment.
Nice, looks good to me. The "load model, Load Changes, upload a model, don't see cached changes" bug is still there even without the toast, but I'll go ahead and merge this as I noticed a related existing bug with reverting that'll need fixing anyways. I'll take care of the other at the same time.
Make loading auto-saved model changes opt-in
Fixes #461, #462, and #463.
Changes
Behavior
API
fromNlogotakesworkInProgressNlogo: String | nulland compiles whatever it is handed.newSessionno longer takesworkInProgressState.WorkInProgressStategainsenabled-with-unloaded-wip.loadWipreturnsWipInfo | null._syncStatereturns the state sosetSessionreads it once.Call sites
loadWorkInProgressinsimulation.jsguards against a null listener or an empty cache.nlw-revert-wipcollapses toloadSource(wipListener.getNlogoSource(), null);revertWipclears the source title.loadHubNetWebupdated for the newnewSessionsignature.Why WIP handling moved out of Tortoise
Tortoise used to own WIP state because cached changes were applied at load time, so the loader was the only place that knew both which nlogo it compiled and whether it came from the cache. It derived
workInProgressStateand passed it throughnewSessionso the Revert button rendered correctly from the first frame, and the listener sometimes had to patch that state afterwards.Opt-in loading separates the two questions. The loader now compiles whatever
workInProgressNlogoit is handed, the page decides when to hand it over vialoadWipandloadSource, andWipListener.getState()derives state on demand from what only the listener knows. The loader could not computeenabled-with-unloaded-wipanyway, since that state never touches the compile path.#462 fix
Cached changes are always exported as nlogox XML by
compiler.exportNlogoXML, butTortoise.fromNlogowas picking the parser based on the format of the original file. Loading a legacy.nlogofile with cached changes therefore handed XML to the.nlogoparser and crashed the engine.fromNlogonow dispatches on the string it actually compiles, using the new exportedisOldFormatNlogohelper innlogo-source.coffee.#463 fix
Anchor links inside toasts inherited the page's default link color and were unreadable against the toast background. Toast anchors now get their own color and underline so they read at any toast variant.
Side effects
fromURLnow passesnullfor WIP, so URL-loaded NetTango models showdisabledinstead ofenabledwith an empty cache. This hides the Revert button, which was always disabled in that case anyway.Known limitations
workInProgress.enabled = falsesetting is ignored. No storage version bump. Why? The current storage version is1, which means no one had tried to update it before. I recall Jeremy's recent work on pinning engine versions, and I can imagine a scenario where the version stored is higher than the one expected.Testing
Chrome and Firefox:
Patch and World Size.nlogo, edit, refresh, click Load Changes. No crash (Engine crashes when loading a WIP.nlogofile #462).demomodels/All Widgets.coffeecompilescoffeelintandtestnode --check