fix: undo coverage, safe loads, and persistence honesty#34
Merged
Conversation
Undo/autosave coverage: - Connection path-style buttons, state-connection role chips and the custom-variable distribution chip now end in _commit(), so those edits reach undo and autosave (they previously vanished on reload/undo). - The +/- resource steppers commit at rest (step 0), where the count is the serialized starting baseline; mid-run nudges stay transient. - _diagramAI no longer assigns rule.nodeId while rendering; an unset target only displays as the first interactive node and is written on change, so render can't drift undo snapshots. Destructive load: - Open file, library Load, share-URL and autosave restore now parse and validate on a throwaway Diagram (_canLoadDiagram) before touching the real one; corrupt input toasts and leaves the diagram untouched instead of wiping it and throwing (raw alert() replaced with _toast). - _initDiagram guards localStorage.getItem so blocked storage (Safari private mode / embedded iframe) can't abort the App constructor. State hygiene on replace: - _restoreState and _clearAll exit scrub mode, so undo/New no longer leave the renderer painting a dead run and a dead tl-range slider. - _clearAll resets diagram.seed to the constructor default and both _clearAll and _commitReplace drop session checkpoints/branches (_dropScenarioState), keeping the Branch panel and timeline in sync. Honest feedback and controls: - _saveLibrary/_saveComponents report write failures; callers toast a storage-full error instead of a false Saved. - Tool shortcuts ignore keystrokes while a <select> is focused. - Changing speed mid-run restarts the tick interval without resampling 'on play' custom variables (values preserved across stop/run). Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Batch 2 of the codebase review fixes: everything around undo/redo integrity, destructive loads, and persistence.
_canLoadDiagram()trial-loads untrusted payloads into a throwaway Diagram first. Open file, library Load, the share-URL path and autosave restore all validate before touching the real diagram, so corrupt input can no longer wipe your work (Open file previously destroyed the diagram and let autosave persist the wreckage). The library's rawalert()is now a toastlocalStorage.getItemin_initDiagramis wrapped, so blocked-storage contexts (embed iframes, strict privacy modes) boot instead of dying in the constructorVerification: 185 unit tests green, smoke test green, plus a targeted 16-check Playwright script exercising each fix end to end (commit-stack growth per control, corrupt-load leaving the diagram intact, scrub exit on undo/New, seed and checkpoint clearing, quota toast, select-focus suppression, on-play preservation across speed changes, blocked-storage boot).